Skip to content

Commit fbc0a79

Browse files
🐛 Show first non-empty line in incident message overflow tab (#1841) (#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]>
1 parent 1f5c60d commit fbc0a79

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.empty-cell {
2+
color: #6a6e73;
3+
font-style: italic;
4+
}

client/src/app/pages/issues/issue-detail-drawer/file-incidents-detail-modal/file-all-incidents-table.tsx

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "./file-all-incidents-table.css";
12
import * as React from "react";
23
import { Table, Thead, Tr, Th, Tbody, Td } from "@patternfly/react-table";
34
import { useSelectionState } from "@migtools/lib-ui";
@@ -122,9 +123,7 @@ export const FileAllIncidentsTable: React.FC<
122123
colSpan={2}
123124
{...getTdProps({ columnKey: "message" })}
124125
>
125-
<ReactMarkdown components={markdownPFComponents}>
126-
{`${incident.message.split("\n")[0]} ...`}
127-
</ReactMarkdown>
126+
{messageDisplayComponent(incident.message)}
128127
</Td>
129128
</TableRowContentWithControls>
130129
</Tr>
@@ -142,3 +141,19 @@ export const FileAllIncidentsTable: React.FC<
142141
</>
143142
);
144143
};
144+
145+
const getFirstNonEmptyLine = (message: string): string | null => {
146+
const lines = message.split("\n");
147+
const nonEmptyLine = lines.find((line) => line.trim() !== "");
148+
return nonEmptyLine || null;
149+
};
150+
151+
const messageDisplayComponent = (message: string) => {
152+
const content = getFirstNonEmptyLine(message);
153+
if (content === null) {
154+
return <div className="empty-cell">No content available.</div>;
155+
}
156+
return (
157+
<ReactMarkdown components={markdownPFComponents}>{content}</ReactMarkdown>
158+
);
159+
};

0 commit comments

Comments
 (0)