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

Conversation

ibolton336
Copy link
Member

Signed-off-by: Ian Bolton <ibolton@redhat.com>
@ibolton336 ibolton336 added the cherry-pick/release-0.3 This PR should be cherry-picked to release-0.3 branch. label Apr 11, 2024

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

Copy link
Member

@sjd78 sjd78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't not realize some stuff could be markdown! Craziness


const getFirstNonEmptyLine = (message: string) => {
const lines = message.split("\n");
return lines.find((line) => line.trim() !== "") || "No content available.";
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>.

Comment on lines 126 to 128
<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!

@ibolton336
Copy link
Member Author

Screenshot 2024-04-12 at 5 36 37 PM Screenshot 2024-04-12 at 5 35 48 PM

Copy link
Member

@sjd78 sjd78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a non-blocking nit-pick on the function component

return nonEmptyLine || null;
};

const messageDisplayComponent = (message: string) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const messageDisplayComponent = (message: string) => {
const MessageDisplayComponent: React.FC<{message: string}> = ({ message }) => {

<ReactMarkdown components={markdownPFComponents}>
{`${incident.message.split("\n")[0]} ...`}
</ReactMarkdown>
{messageDisplayComponent(incident.message)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{messageDisplayComponent(incident.message)}
<MessageDisplayComponent message={incident.message} />

@sjd78 sjd78 added this to the v0.3.2 milestone Apr 15, 2024
@ibolton336 ibolton336 merged commit 9dc6433 into konveyor:main Apr 15, 2024
7 checks passed
github-actions bot pushed a commit that referenced this pull request Apr 15, 2024
Resolves https://issues.redhat.com/browse/MTA-1959

---------

Signed-off-by: Ian Bolton <ibolton@redhat.com>
Signed-off-by: Cherry Picker <noreply@github.com>
sjd78 pushed a commit that referenced this pull request Apr 15, 2024
…1851)

Resolves https://issues.redhat.com/browse/MTA-1959

---------
Backport-of: #1841
Signed-off-by: Ian Bolton <ibolton@redhat.com>
Signed-off-by: Cherry Picker <noreply@github.com>
Co-authored-by: Scott Dickerson <sdickers@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick/release-0.3 This PR should be cherry-picked to release-0.3 branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants