Skip to content

Commit 709e8b2

Browse files
authored
Add markdown to collapsed Autofix step (#75179)
Adds markdown parsing to the active log displayed when the running step in Autofix is collapsed. <img width="972" alt="Screenshot 2024-07-29 at 11 43 23 AM" src="https://github.com/user-attachments/assets/035f7722-3b7d-41e7-88f0-328bf04f6dde">
1 parent 91b183f commit 709e8b2

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

static/app/components/events/autofix/autofixSteps.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ function isProgressLog(
100100
return 'message' in item && 'timestamp' in item;
101101
}
102102

103+
function replaceHeadersWithBold(markdown: string) {
104+
const headerRegex = /^(#{1,6})\s+(.*)$/gm;
105+
const boldMarkdown = markdown.replace(headerRegex, (_match, _hashes, content) => {
106+
return ` **${content}** `;
107+
});
108+
109+
return boldMarkdown;
110+
}
111+
103112
function Progress({
104113
progress,
105114
groupId,
@@ -111,15 +120,6 @@ function Progress({
111120
progress: AutofixProgressItem | AutofixStep;
112121
runId: string;
113122
}) {
114-
function replaceHeadersWithBold(markdown: string) {
115-
const headerRegex = /^(#{1,6})\s+(.*)$/gm;
116-
const boldMarkdown = markdown.replace(headerRegex, (_match, _hashes, content) => {
117-
return ` **${content}** `;
118-
});
119-
120-
return boldMarkdown;
121-
}
122-
123123
if (isProgressLog(progress)) {
124124
const html = progress.message.includes('\n')
125125
? marked(replaceHeadersWithBold(progress.message), {
@@ -213,7 +213,11 @@ export function ExpandableStep({
213213
}}
214214
/>
215215
{activeLog && !isExpanded && (
216-
<StepHeaderDescription>{activeLog}</StepHeaderDescription>
216+
<StepHeaderDescription
217+
dangerouslySetInnerHTML={{
218+
__html: singleLineRenderer(replaceHeadersWithBold(activeLog)),
219+
}}
220+
/>
217221
)}
218222
</StepHeaderLeft>
219223
<StepHeaderRight>

0 commit comments

Comments
 (0)