Skip to content
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

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const FileAllIncidentsTable: React.FC<
{...getTdProps({ columnKey: "message" })}
>
<ReactMarkdown components={markdownPFComponents}>
{`${incident.message.split("\n")[0]} ...`}
{`${getFirstNonEmptyLine(incident.message)} ...`}
</ReactMarkdown>
Copy link
Member

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!

</Td>
</TableRowContentWithControls>
Expand All @@ -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.";
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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 _(empty message)_ or some such, but it would make more sense up in the <Td>.

};
Loading