From 202f240534f3d5c7185b706fee1c80a4f7e6d1fc Mon Sep 17 00:00:00 2001
From: "red-hat-konflux[bot]"
<126015336+red-hat-konflux[bot]@users.noreply.github.com>
Date: Sat, 14 Dec 2024 08:09:31 +0000
Subject: [PATCH 1/4] chore(deps): update konflux references
Signed-off-by: red-hat-konflux <126015336+red-hat-konflux[bot]@users.noreply.github.com>
---
.../forklift-console-plugin-pull-request.yaml | 18 +++++++++---------
.tekton/forklift-console-plugin-push.yaml | 18 +++++++++---------
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/.tekton/forklift-console-plugin-pull-request.yaml b/.tekton/forklift-console-plugin-pull-request.yaml
index 46e91896..bb5a4c47 100644
--- a/.tekton/forklift-console-plugin-pull-request.yaml
+++ b/.tekton/forklift-console-plugin-pull-request.yaml
@@ -134,7 +134,7 @@ spec:
- name: name
value: init
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-init:0.2@sha256:0523b51c28375a3f222da91690e22eff11888ebc98a0c73c468af44762265c69
+ value: quay.io/konflux-ci/tekton-catalog/task-init:0.2@sha256:60063fefe88e111d129cb59caff97c912722927c8a0f750253553d4c527a2396
- name: kind
value: task
resolver: bundles
@@ -225,7 +225,7 @@ spec:
- name: name
value: buildah-oci-ta
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-buildah-oci-ta:0.2@sha256:decef0e000a05daad9dd43b707c8b3a96b6125ff5a4ee096fd3e8c23a2881b9e
+ value: quay.io/konflux-ci/tekton-catalog/task-buildah-oci-ta:0.2@sha256:e0f1ec1ec43ba0f9533dd70fe76a3c24ac3ca14ddd83036099c8073c94dc8258
- name: kind
value: task
resolver: bundles
@@ -254,7 +254,7 @@ spec:
- name: name
value: build-image-index
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-build-image-index:0.1@sha256:a89c141c8d35b2e9d9904c92c9b128f7ccf36681adac7f7422b4537b8bb077e7
+ value: quay.io/konflux-ci/tekton-catalog/task-build-image-index:0.1@sha256:37328a4b2fc686435531ba423c26c2051822a4e70b06088c4d8eaf0e8fa6d65b
- name: kind
value: task
resolver: bundles
@@ -304,7 +304,7 @@ spec:
- name: name
value: deprecated-image-check
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-deprecated-image-check:0.4@sha256:5a1a165fa02270f0a947d8a2131ee9d8be0b8e9d34123828c2bef589e504ee84
+ value: quay.io/konflux-ci/tekton-catalog/task-deprecated-image-check:0.4@sha256:f8efb0b22692fad908a1a75f8d5c0b6ed3b0bcd2a9853577e7be275e5bac1bb8
- name: kind
value: task
resolver: bundles
@@ -326,7 +326,7 @@ spec:
- name: name
value: clair-scan
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-clair-scan:0.2@sha256:0a5421111e7092740398691d5bd7c125cc0896f29531d19414bb5724ae41692a
+ value: quay.io/konflux-ci/tekton-catalog/task-clair-scan:0.2@sha256:e428b37d253621365ffb24d4053e5f3141988ae6a30fce1c8ba73b7211396eb0
- name: kind
value: task
resolver: bundles
@@ -372,7 +372,7 @@ spec:
- name: name
value: sast-snyk-check-oci-ta
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-sast-snyk-check-oci-ta:0.3@sha256:1119722a2d31b831d1aa336fd8cced0a5016c95466b6b59a58bbf3585735850f
+ value: quay.io/konflux-ci/tekton-catalog/task-sast-snyk-check-oci-ta:0.3@sha256:6d232347739a0366dcfc4e40afbcb5d1937dd3fea8952afb1bd6a4b0c5d1c1f5
- name: kind
value: task
resolver: bundles
@@ -394,7 +394,7 @@ spec:
- name: name
value: clamav-scan
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-clamav-scan:0.2@sha256:6e08cf608240f57442ca5458f3c0dade3558f4f2953be8ea939232f5d5378d58
+ value: quay.io/konflux-ci/tekton-catalog/task-clamav-scan:0.2@sha256:d78221853f7ff2befc6669dd0eeb91e6611ae84ac7754150ea0f071d92ff41cb
- name: kind
value: task
resolver: bundles
@@ -414,7 +414,7 @@ spec:
- name: name
value: apply-tags
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-apply-tags:0.1@sha256:87fd7fc0e937aad1a8db9b6e377d7e444f53394dafde512d68adbea6966a4702
+ value: quay.io/konflux-ci/tekton-catalog/task-apply-tags:0.1@sha256:0767c115d4ba4854d106c9cdfabdc1f1298bc2742a3fea4fefbac4b9c5873d6e
- name: kind
value: task
resolver: bundles
@@ -454,7 +454,7 @@ spec:
- name: name
value: rpms-signature-scan
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-rpms-signature-scan:0.2@sha256:8f3b23bf1b0ef55cc79d28604d2397a0101ac9c0c42ae26e26532eb2778c801b
+ value: quay.io/konflux-ci/tekton-catalog/task-rpms-signature-scan:0.2@sha256:ec536e55a039052823ba74e07db3175554fb046649671d1fefd776ca064d00ac
- name: kind
value: task
resolver: bundles
diff --git a/.tekton/forklift-console-plugin-push.yaml b/.tekton/forklift-console-plugin-push.yaml
index 9d0a4646..3a856910 100644
--- a/.tekton/forklift-console-plugin-push.yaml
+++ b/.tekton/forklift-console-plugin-push.yaml
@@ -133,7 +133,7 @@ spec:
- name: name
value: init
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-init:0.2@sha256:0523b51c28375a3f222da91690e22eff11888ebc98a0c73c468af44762265c69
+ value: quay.io/konflux-ci/tekton-catalog/task-init:0.2@sha256:60063fefe88e111d129cb59caff97c912722927c8a0f750253553d4c527a2396
- name: kind
value: task
resolver: bundles
@@ -224,7 +224,7 @@ spec:
- name: name
value: buildah-oci-ta
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-buildah-oci-ta:0.2@sha256:decef0e000a05daad9dd43b707c8b3a96b6125ff5a4ee096fd3e8c23a2881b9e
+ value: quay.io/konflux-ci/tekton-catalog/task-buildah-oci-ta:0.2@sha256:e0f1ec1ec43ba0f9533dd70fe76a3c24ac3ca14ddd83036099c8073c94dc8258
- name: kind
value: task
resolver: bundles
@@ -253,7 +253,7 @@ spec:
- name: name
value: build-image-index
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-build-image-index:0.1@sha256:a89c141c8d35b2e9d9904c92c9b128f7ccf36681adac7f7422b4537b8bb077e7
+ value: quay.io/konflux-ci/tekton-catalog/task-build-image-index:0.1@sha256:37328a4b2fc686435531ba423c26c2051822a4e70b06088c4d8eaf0e8fa6d65b
- name: kind
value: task
resolver: bundles
@@ -303,7 +303,7 @@ spec:
- name: name
value: deprecated-image-check
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-deprecated-image-check:0.4@sha256:5a1a165fa02270f0a947d8a2131ee9d8be0b8e9d34123828c2bef589e504ee84
+ value: quay.io/konflux-ci/tekton-catalog/task-deprecated-image-check:0.4@sha256:f8efb0b22692fad908a1a75f8d5c0b6ed3b0bcd2a9853577e7be275e5bac1bb8
- name: kind
value: task
resolver: bundles
@@ -325,7 +325,7 @@ spec:
- name: name
value: clair-scan
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-clair-scan:0.2@sha256:0a5421111e7092740398691d5bd7c125cc0896f29531d19414bb5724ae41692a
+ value: quay.io/konflux-ci/tekton-catalog/task-clair-scan:0.2@sha256:e428b37d253621365ffb24d4053e5f3141988ae6a30fce1c8ba73b7211396eb0
- name: kind
value: task
resolver: bundles
@@ -371,7 +371,7 @@ spec:
- name: name
value: sast-snyk-check-oci-ta
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-sast-snyk-check-oci-ta:0.3@sha256:1119722a2d31b831d1aa336fd8cced0a5016c95466b6b59a58bbf3585735850f
+ value: quay.io/konflux-ci/tekton-catalog/task-sast-snyk-check-oci-ta:0.3@sha256:6d232347739a0366dcfc4e40afbcb5d1937dd3fea8952afb1bd6a4b0c5d1c1f5
- name: kind
value: task
resolver: bundles
@@ -393,7 +393,7 @@ spec:
- name: name
value: clamav-scan
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-clamav-scan:0.2@sha256:6e08cf608240f57442ca5458f3c0dade3558f4f2953be8ea939232f5d5378d58
+ value: quay.io/konflux-ci/tekton-catalog/task-clamav-scan:0.2@sha256:d78221853f7ff2befc6669dd0eeb91e6611ae84ac7754150ea0f071d92ff41cb
- name: kind
value: task
resolver: bundles
@@ -413,7 +413,7 @@ spec:
- name: name
value: apply-tags
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-apply-tags:0.1@sha256:87fd7fc0e937aad1a8db9b6e377d7e444f53394dafde512d68adbea6966a4702
+ value: quay.io/konflux-ci/tekton-catalog/task-apply-tags:0.1@sha256:0767c115d4ba4854d106c9cdfabdc1f1298bc2742a3fea4fefbac4b9c5873d6e
- name: kind
value: task
resolver: bundles
@@ -453,7 +453,7 @@ spec:
- name: name
value: rpms-signature-scan
- name: bundle
- value: quay.io/konflux-ci/tekton-catalog/task-rpms-signature-scan:0.2@sha256:8f3b23bf1b0ef55cc79d28604d2397a0101ac9c0c42ae26e26532eb2778c801b
+ value: quay.io/konflux-ci/tekton-catalog/task-rpms-signature-scan:0.2@sha256:ec536e55a039052823ba74e07db3175554fb046649671d1fefd776ca064d00ac
- name: kind
value: task
resolver: bundles
From 60b5a76b9b9e67b0e3fddbd2e46ae3512a37ebf4 Mon Sep 17 00:00:00 2001
From: Sharon Gratch
Date: Thu, 12 Dec 2024 18:43:20 +0200
Subject: [PATCH 2/4] Refactoring: replace plan phases strigs with const enums
Reference: https://github.com/kubev2v/forklift-console-plugin/pull/1395#discussion_r1861292874
Signed-off-by: Sharon Gratch
---
.../en/plugin__forklift-console-plugin.json | 6 +
.../actions/PlanActionsDropdownItems.tsx | 5 +-
.../src/modules/Plans/modals/ArchiveModal.tsx | 6 +-
.../modules/Plans/modals/PlanDeleteModal.tsx | 6 +-
.../Plans/utils/constants/planPhases.ts | 24 ++--
.../Plans/utils/helpers/getPhaseLabel.ts | 30 -----
.../Plans/utils/helpers/getPlanPhase.ts | 42 +++----
.../utils/helpers/getPlanProgressVariant.ts | 14 +--
.../src/modules/Plans/utils/helpers/index.ts | 1 -
.../modules/Plans/utils/types/PlanPhase.ts | 39 ++++---
.../components/MigrationsTable.tsx | 11 +-
.../details/components/PlanPageHeadings.tsx | 4 +-
.../views/list/components/ErrorStatusCell.tsx | 4 +-
.../views/list/components/PlanStatusCell.tsx | 12 +-
.../views/list/components/StatusCell.tsx | 29 +++++
.../views/list/components/VMsProgressCell.tsx | 103 ++++++++++++++++++
16 files changed, 229 insertions(+), 107 deletions(-)
delete mode 100644 packages/forklift-console-plugin/src/modules/Plans/utils/helpers/getPhaseLabel.ts
create mode 100644 packages/forklift-console-plugin/src/modules/Plans/views/list/components/StatusCell.tsx
create mode 100644 packages/forklift-console-plugin/src/modules/Plans/views/list/components/VMsProgressCell.tsx
diff --git a/packages/forklift-console-plugin/locales/en/plugin__forklift-console-plugin.json b/packages/forklift-console-plugin/locales/en/plugin__forklift-console-plugin.json
index 5826254a..7dbce1ba 100644
--- a/packages/forklift-console-plugin/locales/en/plugin__forklift-console-plugin.json
+++ b/packages/forklift-console-plugin/locales/en/plugin__forklift-console-plugin.json
@@ -1,15 +1,19 @@
{
"{{Canceled}} canceled": "{{Canceled}} canceled",
+ "{{canceled}} VMs canceled": "{{canceled}} VMs canceled",
"{{completed}} / {{total}}": "{{completed}} / {{total}}",
"{{dateLabel}} Failed: {{value}}": "{{dateLabel}} Failed: {{value}}",
"{{dateLabel}} Running: {{value}}": "{{dateLabel}} Running: {{value}}",
"{{dateLabel}} Succeeded: {{value}}": "{{dateLabel}} Succeeded: {{value}}",
+ "{{error}} VMs failed": "{{error}} VMs failed",
"{{label}} field is missing from the secret data.": "{{label}} field is missing from the secret data.",
"{{name}} Details": "{{name}} Details",
"{{selectedLength}} hosts selected.": "{{selectedLength}} hosts selected.",
"{{success}} of {{total}} VMs migrated": "{{success}} of {{total}} VMs migrated",
+ "{{success}} VMs succeeded": "{{success}} VMs succeeded",
"{{total}} VM": "{{total}} VM",
"{{total}} VM_plural": "{{total}} VMs",
+ "{{total}} VMs": "{{total}} VMs",
"{{vmCount}} VMs selected ": "{{vmCount}} VMs selected ",
"{children}": "{children}",
"24 hours": "24 hours",
@@ -454,6 +458,7 @@
"Start migration": "Start migration",
"Started at": "Started at",
"Status": "Status",
+ "Status details": "Status details",
"Storage": "Storage",
"Storage classes": "Storage classes",
"Storage domains": "Storage domains",
@@ -508,6 +513,7 @@
"Token": "Token",
"Total CPU count:": "Total CPU count:",
"Total memory:": "Total memory:",
+ "Total of {{total}} VMs are planned for migration:": "Total of {{total}} VMs are planned for migration:",
"Total virtual machines": "Total virtual machines",
"Total: {{length}}": "Total: {{length}}",
"Transfer Network": "Transfer Network",
diff --git a/packages/forklift-console-plugin/src/modules/Plans/actions/PlanActionsDropdownItems.tsx b/packages/forklift-console-plugin/src/modules/Plans/actions/PlanActionsDropdownItems.tsx
index 3d22954f..541d95c1 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/actions/PlanActionsDropdownItems.tsx
+++ b/packages/forklift-console-plugin/src/modules/Plans/actions/PlanActionsDropdownItems.tsx
@@ -21,6 +21,7 @@ import {
isPlanArchived,
isPlanExecuting,
PlanData,
+ PlanPhase,
} from '../utils';
export const PlanActionsDropdownItems = ({ data }: PlanActionsDropdownItemsProps) => {
@@ -93,7 +94,9 @@ export const PlanActionsDropdownItems = ({ data }: PlanActionsDropdownItemsProps
{t('Archive Plan')}
diff --git a/packages/forklift-console-plugin/src/modules/Plans/modals/ArchiveModal.tsx b/packages/forklift-console-plugin/src/modules/Plans/modals/ArchiveModal.tsx
index e99fbf42..80557307 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/modals/ArchiveModal.tsx
+++ b/packages/forklift-console-plugin/src/modules/Plans/modals/ArchiveModal.tsx
@@ -8,7 +8,7 @@ import { PlanModel, V1beta1Plan } from '@kubev2v/types';
import { K8sModel, k8sPatch } from '@openshift-console/dynamic-plugin-sdk';
import { Alert, Button, Modal, ModalVariant } from '@patternfly/react-core';
-import { getPlanPhase } from '../utils';
+import { getPlanPhase, PlanPhase } from '../utils';
/**
* Props for the DeleteModal component
@@ -70,7 +70,7 @@ export const ArchiveModal: React.FC = ({ title, resource, red
const actions = [
}
- {phase === 'Running' && }
+ {phase === PlanPhase.Running && }
{alertMessage}
);
diff --git a/packages/forklift-console-plugin/src/modules/Plans/modals/PlanDeleteModal.tsx b/packages/forklift-console-plugin/src/modules/Plans/modals/PlanDeleteModal.tsx
index d87c4828..6336879a 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/modals/PlanDeleteModal.tsx
+++ b/packages/forklift-console-plugin/src/modules/Plans/modals/PlanDeleteModal.tsx
@@ -9,7 +9,7 @@ import { V1beta1Plan } from '@kubev2v/types';
import { k8sDelete, K8sGroupVersionKind, K8sModel } from '@openshift-console/dynamic-plugin-sdk';
import { Alert, Button, Modal, ModalVariant } from '@patternfly/react-core';
-import { getPlanPhase } from '../utils';
+import { getPlanPhase, PlanPhase } from '../utils';
/**
* Props for the DeleteModal component
@@ -131,8 +131,8 @@ export const PlanDeleteModal: React.FC = ({
Are you sure you want to delete {name}?
)}
- {phase === 'Running' && }
- {phase !== 'Archived' && }
+ {phase === PlanPhase.Running && }
+ {phase !== PlanPhase.Archived && }
{typeof owner === 'object' && }
{alertMessage}
diff --git a/packages/forklift-console-plugin/src/modules/Plans/utils/constants/planPhases.ts b/packages/forklift-console-plugin/src/modules/Plans/utils/constants/planPhases.ts
index cb6a2b05..0ca05c48 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/utils/constants/planPhases.ts
+++ b/packages/forklift-console-plugin/src/modules/Plans/utils/constants/planPhases.ts
@@ -9,16 +9,16 @@ import { PlanPhase } from '../types';
* This array is intended to be used for creating filter dropdowns, where users can select a plan phase to filter the results shown.
*/
export const planPhases: { id: PlanPhase; label: string }[] = [
- { id: 'Error', label: 'Error' },
- { id: 'vmError', label: 'VM Error' },
- { id: 'Unknown', label: 'Unknown' },
- { id: 'Archiving', label: 'Archiving' },
- { id: 'Archived', label: 'Archived' },
- { id: 'Failed', label: 'Failed' },
- { id: 'Canceled', label: 'Canceled' },
- { id: 'Succeeded', label: 'Succeeded' },
- { id: 'Running', label: 'Running' },
- { id: 'Ready', label: 'Ready' },
- { id: 'Warning', label: 'Warning' },
- { id: 'NotReady', label: 'Not Ready' },
+ { id: PlanPhase.Error, label: PlanPhase.Error },
+ { id: PlanPhase.vmError, label: PlanPhase.vmError },
+ { id: PlanPhase.Unknown, label: PlanPhase.Unknown },
+ { id: PlanPhase.Archiving, label: PlanPhase.Archiving },
+ { id: PlanPhase.Archived, label: PlanPhase.Archived },
+ { id: PlanPhase.Failed, label: PlanPhase.Failed },
+ { id: PlanPhase.Canceled, label: PlanPhase.Canceled },
+ { id: PlanPhase.Succeeded, label: PlanPhase.Succeeded },
+ { id: PlanPhase.Running, label: PlanPhase.Running },
+ { id: PlanPhase.Ready, label: PlanPhase.Ready },
+ { id: PlanPhase.Warning, label: PlanPhase.Warning },
+ { id: PlanPhase.NotReady, label: PlanPhase.NotReady },
];
diff --git a/packages/forklift-console-plugin/src/modules/Plans/utils/helpers/getPhaseLabel.ts b/packages/forklift-console-plugin/src/modules/Plans/utils/helpers/getPhaseLabel.ts
deleted file mode 100644
index 1c5daa41..00000000
--- a/packages/forklift-console-plugin/src/modules/Plans/utils/helpers/getPhaseLabel.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { PlanPhase } from '../types';
-
-export const getPhaseLabel = (phase: PlanPhase) => phaseLabels?.[phase] ?? 'Unknown';
-
-const phaseLabels: Record = {
- // t('Ready')
- Ready: 'Ready',
- // t('Not Ready')
- NotReady: 'Not Ready',
- // t('Running')
- Running: 'Running',
- // t('Succeeded')
- Succeeded: 'Succeeded',
- // t('Canceled')
- Canceled: 'Canceled',
- // t('Failed')
- Failed: 'Failed',
- // t('Archived')
- Archived: 'Archived',
- // t('Archiving')
- Archiving: 'Archiving',
- // t('Error')
- Error: 'Error',
- // t('Warning')
- Warning: 'Warning',
- // t('Some VMs Failed')
- vmError: 'Some VMs Failed',
- // t('Unknown')
- Unknown: 'Unknown',
-};
diff --git a/packages/forklift-console-plugin/src/modules/Plans/utils/helpers/getPlanPhase.ts b/packages/forklift-console-plugin/src/modules/Plans/utils/helpers/getPlanPhase.ts
index c5712f3c..ce480752 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/utils/helpers/getPlanPhase.ts
+++ b/packages/forklift-console-plugin/src/modules/Plans/utils/helpers/getPlanPhase.ts
@@ -5,37 +5,37 @@ import { PlanData, PlanPhase } from '../types';
export const getPlanPhase = (data: PlanData): PlanPhase => {
const plan = data?.obj;
- if (!plan) return 'Unknown';
+ if (!plan) return PlanPhase.Unknown;
// Check condition type
const conditions = getConditions(plan);
if (!conditions || conditions?.length < 1) {
- return 'Unknown';
+ return PlanPhase.Unknown;
}
// Check for Archived
if (plan?.spec?.archived && !conditions.includes('Archived')) {
- return 'Archiving';
+ return PlanPhase.Archiving;
}
if (conditions.includes('Archived')) {
- return 'Archived';
+ return PlanPhase.Archived;
}
// Check for Succeeded
if (conditions.includes('Succeeded')) {
- return 'Succeeded';
+ return PlanPhase.Succeeded;
}
// Check for Canceled
if (conditions.includes('Canceled')) {
- return 'Canceled';
+ return PlanPhase.Canceled;
}
// CHeck for Running
if (conditions.includes('Executing')) {
- return 'Running';
+ return PlanPhase.Running;
}
// Check condition category
@@ -44,18 +44,18 @@ export const getPlanPhase = (data: PlanData): PlanPhase => {
);
if (isCritical) {
- return 'Error';
+ return PlanPhase.Error;
}
// Check for vm errors
const vmError = plan?.status?.migration?.vms?.find((vm) => vm?.error);
if (conditions.includes('Failed')) {
- return 'Failed';
+ return PlanPhase.Failed;
}
if (vmError) {
- return 'vmError';
+ return PlanPhase.vmError;
}
// Check condition category
@@ -64,14 +64,14 @@ export const getPlanPhase = (data: PlanData): PlanPhase => {
);
if (isWarn) {
- return 'Warning';
+ return PlanPhase.Warning;
}
if (conditions.includes('Ready')) {
- return 'Ready';
+ return PlanPhase.Ready;
}
- return 'NotReady';
+ return PlanPhase.NotReady;
};
export const canPlanStart = (plan: V1beta1Plan) => {
@@ -107,20 +107,20 @@ export const isPlanEditable = (plan: V1beta1Plan) => {
const planStatus = getPlanPhase({ obj: plan });
return (
- planStatus === 'Unknown' ||
- planStatus === 'Canceled' ||
- planStatus === 'Error' ||
- planStatus === 'Failed' ||
- planStatus === 'vmError' ||
- planStatus === 'Warning' ||
- planStatus === 'Ready'
+ planStatus === PlanPhase.Unknown ||
+ planStatus === PlanPhase.Canceled ||
+ planStatus === PlanPhase.Error ||
+ planStatus === PlanPhase.Failed ||
+ planStatus === PlanPhase.vmError ||
+ planStatus === PlanPhase.Warning ||
+ planStatus === PlanPhase.Ready
);
};
export const isPlanArchived = (plan: V1beta1Plan) => {
const planStatus = getPlanPhase({ obj: plan });
- return planStatus === 'Archiving' || planStatus === 'Archived';
+ return planStatus === PlanPhase.Archiving || planStatus === PlanPhase.Archived;
};
const getConditions = (obj: V1beta1Plan) =>
diff --git a/packages/forklift-console-plugin/src/modules/Plans/utils/helpers/getPlanProgressVariant.ts b/packages/forklift-console-plugin/src/modules/Plans/utils/helpers/getPlanProgressVariant.ts
index 249fa34a..c8ff964d 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/utils/helpers/getPlanProgressVariant.ts
+++ b/packages/forklift-console-plugin/src/modules/Plans/utils/helpers/getPlanProgressVariant.ts
@@ -6,17 +6,17 @@ export const getPlanProgressVariant = (phase: PlanPhase): ProgressVariant => {
let progressVariant;
switch (phase) {
- case 'Error':
- case 'Failed':
+ case PlanPhase.Error:
+ case PlanPhase.Failed:
progressVariant = ProgressVariant.danger;
break;
- case 'Unknown':
- case 'Archived':
- case 'Canceled':
- case 'vmError':
+ case PlanPhase.Unknown:
+ case PlanPhase.Archived:
+ case PlanPhase.Canceled:
+ case PlanPhase.vmError:
progressVariant = ProgressVariant.warning;
break;
- case 'Succeeded':
+ case PlanPhase.Succeeded:
progressVariant = ProgressVariant.success;
break;
}
diff --git a/packages/forklift-console-plugin/src/modules/Plans/utils/helpers/index.ts b/packages/forklift-console-plugin/src/modules/Plans/utils/helpers/index.ts
index d2865d95..f499b37f 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/utils/helpers/index.ts
+++ b/packages/forklift-console-plugin/src/modules/Plans/utils/helpers/index.ts
@@ -1,7 +1,6 @@
// @index(['./*', /style/g], f => `export * from '${f.path}';`)
export * from './getMigrationPhase';
export * from './getMigrationVmsCounts';
-export * from './getPhaseLabel';
export * from './getPlanPhase';
export * from './getPlanProgressVariant';
// @endindex
diff --git a/packages/forklift-console-plugin/src/modules/Plans/utils/types/PlanPhase.ts b/packages/forklift-console-plugin/src/modules/Plans/utils/types/PlanPhase.ts
index 249f56b6..67d31e06 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/utils/types/PlanPhase.ts
+++ b/packages/forklift-console-plugin/src/modules/Plans/utils/types/PlanPhase.ts
@@ -1,13 +1,26 @@
-export type PlanPhase =
- | 'Error'
- | 'vmError'
- | 'Unknown'
- | 'Archiving'
- | 'Archived'
- | 'Failed'
- | 'Canceled'
- | 'Succeeded'
- | 'Running'
- | 'Ready'
- | 'Warning'
- | 'NotReady';
+export enum PlanPhase {
+ // t('Error')
+ Error = 'Error',
+ // t('Some VMs Failed')
+ vmError = 'Some VMs Failed',
+ // t('Unknown')
+ Unknown = 'Unknown',
+ // t('Archiving')
+ Archiving = 'Archiving',
+ // t('Archived')
+ Archived = 'Archived',
+ // t('Failed')
+ Failed = 'Failed',
+ // t('Canceled')
+ Canceled = 'Canceled',
+ // t('Succeeded')
+ Succeeded = 'Succeeded',
+ // t('Running')
+ Running = 'Running',
+ // t('Ready')
+ Ready = 'Ready',
+ // t('Warning')
+ Warning = 'Warning',
+ // t('Not Ready')
+ NotReady = 'Not Ready',
+}
diff --git a/packages/forklift-console-plugin/src/modules/Plans/views/details/components/MigrationsSection/components/MigrationsTable.tsx b/packages/forklift-console-plugin/src/modules/Plans/views/details/components/MigrationsSection/components/MigrationsTable.tsx
index 39042db1..d05377bb 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/views/details/components/MigrationsSection/components/MigrationsTable.tsx
+++ b/packages/forklift-console-plugin/src/modules/Plans/views/details/components/MigrationsSection/components/MigrationsTable.tsx
@@ -1,10 +1,6 @@
import React from 'react';
import { ConsoleTimestamp } from 'src/components/ConsoleTimestamp';
-import {
- getMigrationVmsCounts,
- getPhaseLabel,
- getPlanProgressVariant,
-} from 'src/modules/Plans/utils';
+import { getMigrationVmsCounts, getPlanProgressVariant, PlanPhase } from 'src/modules/Plans/utils';
import { getMigrationPhase } from 'src/modules/Plans/utils/helpers/getMigrationPhase';
import { useForkliftTranslation } from 'src/utils/i18n';
@@ -90,8 +86,9 @@ const VMsLabel: React.FC<{ migration: V1beta1Migration }> = ({ migration }) => {
const { t } = useForkliftTranslation();
const phase = getMigrationPhase(migration);
- const phaseLabel = t(getPhaseLabel(phase));
- const progressVariant = getPlanProgressVariant(phase);
+ const phaseLabel = PlanPhase[phase] ? t(PlanPhase[phase]) : PlanPhase.Unknown;
+
+ const progressVariant = getPlanProgressVariant(PlanPhase[phase]);
const counters = getMigrationVmsCounts(migration?.status?.vms);
if (!counters?.total || counters.total === 0) {
diff --git a/packages/forklift-console-plugin/src/modules/Plans/views/details/components/PlanPageHeadings.tsx b/packages/forklift-console-plugin/src/modules/Plans/views/details/components/PlanPageHeadings.tsx
index b69cdda7..2e528937 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/views/details/components/PlanPageHeadings.tsx
+++ b/packages/forklift-console-plugin/src/modules/Plans/views/details/components/PlanPageHeadings.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import { PlanActionsDropdown } from 'src/modules/Plans/actions';
import { PlanStartMigrationModal } from 'src/modules/Plans/modals';
-import { canPlanReStart, canPlanStart, getPlanPhase } from 'src/modules/Plans/utils';
+import { canPlanReStart, canPlanStart, getPlanPhase, PlanPhase } from 'src/modules/Plans/utils';
import { useGetDeleteAndEditAccessReview } from 'src/modules/Providers/hooks';
import { useModal } from 'src/modules/Providers/modals';
import { PageHeadings } from 'src/modules/Providers/utils';
@@ -81,7 +81,7 @@ export const PlanPageHeadings: React.FC<{ name: string; namespace: string }> = (
const handleAlerts = () => {
// alerts are not relevant to display if plan was completed successfully
- if (planStatus === 'Succeeded') return;
+ if (planStatus === PlanPhase.Succeeded) return;
if (criticalCondition) {
alerts.push(
diff --git a/packages/forklift-console-plugin/src/modules/Plans/views/list/components/ErrorStatusCell.tsx b/packages/forklift-console-plugin/src/modules/Plans/views/list/components/ErrorStatusCell.tsx
index 910718e1..f5ccc91c 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/views/list/components/ErrorStatusCell.tsx
+++ b/packages/forklift-console-plugin/src/modules/Plans/views/list/components/ErrorStatusCell.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import Linkify from 'react-linkify';
import { Link } from 'react-router-dom';
-import { getPhaseLabel, getPlanPhase } from 'src/modules/Plans/utils';
+import { getPlanPhase } from 'src/modules/Plans/utils';
import { getResourceUrl, TableIconCell } from 'src/modules/Providers/utils';
import { useForkliftTranslation } from 'src/utils/i18n';
@@ -16,7 +16,7 @@ export const ErrorStatusCell: React.FC = ({ data }) => {
const { obj: plan } = data;
const phase = getPlanPhase(data);
- const phaseLabel = getPhaseLabel(phase);
+ const phaseLabel: string = phase;
const planURL = getResourceUrl({
reference: PlanModelRef,
diff --git a/packages/forklift-console-plugin/src/modules/Plans/views/list/components/PlanStatusCell.tsx b/packages/forklift-console-plugin/src/modules/Plans/views/list/components/PlanStatusCell.tsx
index b023cd40..0aba151a 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/views/list/components/PlanStatusCell.tsx
+++ b/packages/forklift-console-plugin/src/modules/Plans/views/list/components/PlanStatusCell.tsx
@@ -6,6 +6,7 @@ import {
getPlanPhase,
isPlanArchived,
isPlanExecuting,
+ PlanPhase,
} from 'src/modules/Plans/utils';
import { useModal } from 'src/modules/Providers/modals';
import { getResourceUrl } from 'src/modules/Providers/utils';
@@ -48,7 +49,8 @@ export const PlanStatusCell: React.FC = ({ data }) => {
);
const phase = getPlanPhase(data);
- const isPlanLoading = !isWaitingForCutover && (phase === 'Running' || phase === 'Archiving');
+ const isPlanLoading =
+ !isWaitingForCutover && (phase === PlanPhase.Running || phase === PlanPhase.Archiving);
const planURL = getResourceUrl({
reference: PlanModelRef,
name: plan?.metadata?.name,
@@ -60,7 +62,7 @@ export const PlanStatusCell: React.FC = ({ data }) => {
// Could possibly use a querystring to dictate a table filter for the list of VMs.
const vmCountLinkPath = `${planURL}/vms`;
- if (phase === 'Ready') {
+ if (phase === PlanPhase.Ready) {
return (