Skip to content

Commit

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

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

---------

Signed-off-by: Ian Bolton <ibolton@redhat.com>
  • Loading branch information
ibolton336 committed Apr 15, 2024
1 parent c5265bd commit 9dc6433
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 @@ -123,9 +124,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 @@ -143,3 +142,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 9dc6433

Please sign in to comment.