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

CNV-38270: Changing snapshot status #1858

Merged
Show file tree
Hide file tree
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
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
Loading