Skip to content

Commit

Permalink
Status.tsx: show as many different error types as possible (HMS-1442)
Browse files Browse the repository at this point in the history
  • Loading branch information
schuellerf committed May 8, 2024
1 parent 67b4b15 commit f2dd9ed
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions src/Components/ImagesTable/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,27 @@ type ErrorStatusPropTypes = {

const ErrorStatus = ({ icon, text, error }: ErrorStatusPropTypes) => {
let reason = '';
const detailsArray: string[] = [];
if (typeof error === 'string') {
reason = error;
} else {
if (error.reason) {
reason = error.reason;
}
if (error.details?.reason) {
if (reason !== '') {
reason = `${reason}\n\n${error.details?.reason}`;
} else {
reason = error.details.reason;
if (Array.isArray(error.details)) {
for (const line in error.details) {
detailsArray.push(`${error.details[line]}`);
}
}
if (typeof error.details === 'string') {
detailsArray.push(error.details);
}
if (error.details?.reason) {
detailsArray.push(`${error.details.reason}`);
}
if (error.details?.s) {
detailsArray.push(`${error.details.s}`);
}
}

return (
Expand All @@ -316,10 +324,22 @@ const ErrorStatus = ({ icon, text, error }: ErrorStatusPropTypes) => {
<Panel isScrollable>
<PanelMain maxHeight="25rem">
<div className="pf-u-mt-sm">
<p>{reason}</p>
<div className="pf-v5-c-code-block">
<div className="pf-v5-c-code-block__header">{reason}</div>
<div className="pf-v5-c-code-block__content">
<pre className="pf-v5-c-code-block__pre">
{detailsArray.join('\n')}
<code className="pf-v5-c-code-block__code"></code>
</pre>
</div>
</div>
<Button
variant="link"
onClick={() => navigator.clipboard.writeText(reason)}
onClick={() =>
navigator.clipboard.writeText(
reason + '\n\n' + detailsArray.join('\n')
)
}
className="pf-u-pl-0 pf-u-mt-md"
>
Copy error text to clipboard <CopyIcon />
Expand Down

0 comments on commit f2dd9ed

Please sign in to comment.