Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status.tsx: show as many different error types as possible (HMS-1442) #2066

Merged
merged 1 commit into from
May 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions src/Components/ImagesTable/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import './ImageBuildStatus.scss';
import {
Alert,
Button,
CodeBlock,
CodeBlockCode,
Flex,
Panel,
PanelMain,
Popover,
Skeleton,
Text,
} from '@patternfly/react-core';
import {
CheckCircleIcon,
Expand Down Expand Up @@ -288,19 +291,24 @@ 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}`);
}
}

return (
Expand All @@ -309,24 +317,29 @@ const ErrorStatus = ({ icon, text, error }: ErrorStatusPropTypes) => {
<Popover
data-testid="errorstatus-popover"
position="bottom"
minWidth="30rem"
minWidth="40rem"
bodyContent={
<>
<Alert variant="danger" title={text} isInline isPlain />
<Text className="pf-u-pt-md pf-u-pb-md">{reason}</Text>
<Panel isScrollable>
<PanelMain maxHeight="25rem">
<div className="pf-u-mt-sm">
<p>{reason}</p>
<Button
variant="link"
onClick={() => navigator.clipboard.writeText(reason)}
className="pf-u-pl-0 pf-u-mt-md"
>
Copy error text to clipboard <CopyIcon />
</Button>
</div>
<CodeBlock>
<CodeBlockCode>{detailsArray.join('\n')}</CodeBlockCode>
</CodeBlock>
</PanelMain>
</Panel>
<Button
variant="link"
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 />
</Button>
</>
}
>
Expand Down
Loading