Skip to content

Commit 9dc6433

Browse files
authored
🐛 Show first non-empty line in incident message overflow tab (#1841)
Resolves https://issues.redhat.com/browse/MTA-1959 --------- Signed-off-by: Ian Bolton <[email protected]>
1 parent c5265bd commit 9dc6433

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";
@@ -123,9 +124,7 @@ export const FileAllIncidentsTable: React.FC<
123124
colSpan={2}
124125
{...getTdProps({ columnKey: "message" })}
125126
>
126-
<ReactMarkdown components={markdownPFComponents}>
127-
{`${incident.message.split("\n")[0]} ...`}
128-
</ReactMarkdown>
127+
{messageDisplayComponent(incident.message)}
129128
</Td>
130129
</TableRowContentWithControls>
131130
</Tr>
@@ -143,3 +142,19 @@ export const FileAllIncidentsTable: React.FC<
143142
</>
144143
);
145144
};
145+
146+
const getFirstNonEmptyLine = (message: string): string | null => {
147+
const lines = message.split("\n");
148+
const nonEmptyLine = lines.find((line) => line.trim() !== "");
149+
return nonEmptyLine || null;
150+
};
151+
152+
const messageDisplayComponent = (message: string) => {
153+
const content = getFirstNonEmptyLine(message);
154+
if (content === null) {
155+
return <div className="empty-cell">No content available.</div>;
156+
}
157+
return (
158+
<ReactMarkdown components={markdownPFComponents}>{content}</ReactMarkdown>
159+
);
160+
};

0 commit comments

Comments
 (0)