-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Show first non-empty line in incident message overflow tab #1841
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,7 +124,7 @@ export const FileAllIncidentsTable: React.FC< | |
{...getTdProps({ columnKey: "message" })} | ||
> | ||
<ReactMarkdown components={markdownPFComponents}> | ||
{`${incident.message.split("\n")[0]} ...`} | ||
{`${getFirstNonEmptyLine(incident.message)} ...`} | ||
</ReactMarkdown> | ||
</Td> | ||
</TableRowContentWithControls> | ||
|
@@ -143,3 +143,8 @@ export const FileAllIncidentsTable: React.FC< | |
</> | ||
); | ||
}; | ||
|
||
const getFirstNonEmptyLine = (message: string) => { | ||
const lines = message.split("\n"); | ||
return lines.find((line) => line.trim() !== "") || "No content available."; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO the no-content label should be styled as a placeholder to clearly distinguish from the analyzed code. If not possible I would use empty string. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this text is parsed as Markdown, there are some edge cases that could be a problem. If the first non-empty line is triple back-tick (like for a code block), weird things could happen. I don't mind if there is markdown message here like |
||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe more like "if message is blank (i.e. only has whitespace, is empty string, or is falsey), then render a "no message" placeholder else render the
ReactMarkdown
component.Then
getFirstNonEmptyLine()
can be assured there is a line to find!