Skip to content

Commit

Permalink
Merge pull request #1858 from metalice/CNV-38270-changing-snapshot-st…
Browse files Browse the repository at this point in the history
…atus

CNV-38270: Changing snapshot status
  • Loading branch information
openshift-merge-bot[bot] authored Apr 3, 2024
2 parents 090ad90 + 8c6dc08 commit 5ff8db8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React, { FC } from 'react';

import { ColoredIconProps, StatusIconAndText } from '@openshift-console/dynamic-plugin-sdk';

Expand All @@ -8,14 +8,10 @@ type SnapshotStatusIconProps = {
phase: string;
};

const SnapshotStatusIcon: React.FC<SnapshotStatusIconProps> = ({ phase }) => {
const StatusIcon: React.FC<ColoredIconProps> = iconMapper[phase];
const SnapshotStatusIcon: FC<SnapshotStatusIconProps> = ({ phase }) => {
const StatusIcon: FC<ColoredIconProps> = iconMapper?.[phase] || iconMapper.default;

return (
<>
<StatusIconAndText icon={<StatusIcon />} title={phase} />
</>
);
return <StatusIconAndText icon={<StatusIcon />} title={phase} />;
};

export default SnapshotStatusIcon;
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const SnapshotRow: React.FC<
> = ({ activeColumnIDs, obj: snapshot, rowData: { isVMRunning, restores } }) => {
const relevantRestore: V1alpha1VirtualMachineRestore = restores?.[snapshot?.metadata?.name];
const isRestoreDisabled = isVMRunning || snapshot?.status?.phase !== snapshotStatuses.Succeeded;
const readyCondition = snapshot?.status?.conditions?.find(({ type }) => type === 'Ready');
return (
<>
<TableData activeColumnIDs={activeColumnIDs} id="name">
Expand All @@ -35,7 +36,7 @@ const SnapshotRow: React.FC<
<Timestamp timestamp={snapshot?.metadata?.creationTimestamp} />
</TableData>
<TableData activeColumnIDs={activeColumnIDs} id="status">
<SnapshotStatusIcon phase={snapshot?.status?.phase} />
<SnapshotStatusIcon phase={readyCondition?.reason || readyCondition?.status} />
</TableData>
<TableData activeColumnIDs={activeColumnIDs} id="last-restored">
<Timestamp timestamp={relevantRestore?.status?.restoreTime} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ export const snapshotStatuses = {
};

export const iconMapper = {
default: GreenCheckCircleIcon,
Error: RedExclamationCircleIcon,
Failed: RedExclamationCircleIcon,
InProgress: YellowExclamationTriangleIcon,
'Not ready': YellowExclamationTriangleIcon,
Succeeded: GreenCheckCircleIcon,
};

Expand Down

0 comments on commit 5ff8db8

Please sign in to comment.