From 60b5a76b9b9e67b0e3fddbd2e46ae3512a37ebf4 Mon Sep 17 00:00:00 2001 From: Sharon Gratch Date: Thu, 12 Dec 2024 18:43:20 +0200 Subject: [PATCH] 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 5826254a1..7dbce1ba3 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 3d22954f5..541d95c15 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 e99fbf42c..805573071 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 = [ + + } + size={ProgressSize.sm} + measureLocation={ProgressMeasureLocation.top} + variant={progressVariant} + /> + + ); +};