Skip to content

Commit

Permalink
🐛 Show first non-empty line in incident message overflow tab (#1841) (#…
Browse files Browse the repository at this point in the history
…1851)

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

---------
Backport-of: #1841
Signed-off-by: Ian Bolton <[email protected]>
Signed-off-by: Cherry Picker <[email protected]>
Co-authored-by: Scott Dickerson <[email protected]>
  • Loading branch information
konveyor-ci-bot[bot] authored Apr 15, 2024
1 parent 1f5c60d commit fbc0a79
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.empty-cell {
color: #6a6e73;
font-style: italic;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "./file-all-incidents-table.css";
import * as React from "react";
import { Table, Thead, Tr, Th, Tbody, Td } from "@patternfly/react-table";
import { useSelectionState } from "@migtools/lib-ui";
Expand Down Expand Up @@ -122,9 +123,7 @@ export const FileAllIncidentsTable: React.FC<
colSpan={2}
{...getTdProps({ columnKey: "message" })}
>
<ReactMarkdown components={markdownPFComponents}>
{`${incident.message.split("\n")[0]} ...`}
</ReactMarkdown>
{messageDisplayComponent(incident.message)}
</Td>
</TableRowContentWithControls>
</Tr>
Expand All @@ -142,3 +141,19 @@ export const FileAllIncidentsTable: React.FC<
</>
);
};

const getFirstNonEmptyLine = (message: string): string | null => {
const lines = message.split("\n");
const nonEmptyLine = lines.find((line) => line.trim() !== "");
return nonEmptyLine || null;
};

const messageDisplayComponent = (message: string) => {
const content = getFirstNonEmptyLine(message);
if (content === null) {
return <div className="empty-cell">No content available.</div>;
}
return (
<ReactMarkdown components={markdownPFComponents}>{content}</ReactMarkdown>
);
};

0 comments on commit fbc0a79

Please sign in to comment.