From fe6bb353297df4fa4d689417e5b5924788e15c27 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 --- .../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/StatusCell.tsx | 18 ++++---- .../views/list/components/VMsProgressCell.tsx | 3 +- 14 files changed, 94 insertions(+), 113 deletions(-) delete mode 100644 packages/forklift-console-plugin/src/modules/Plans/utils/helpers/getPhaseLabel.ts 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 = [