From 3962e38ba462571cfe5f0e1b3c0c0b22e40daf5b Mon Sep 17 00:00:00 2001 From: Sharon Gratch Date: Mon, 2 Dec 2024 23:47:27 +0200 Subject: [PATCH] : short summary under 50 chars Reference: https://issues.redhat.com/browse/MTV-1729 Disable the cutover action for an archived plan. Signed-off-by: Sharon Gratch --- .../Plans/actions/PlanActionsDropdownItems.tsx | 16 ++++++++++++++-- .../modules/Plans/utils/helpers/getPlanPhase.ts | 6 ++++++ .../Plans/views/list/components/ActionsCell.tsx | 10 ++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) 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 1a86e7661..3d22954f5 100644 --- a/packages/forklift-console-plugin/src/modules/Plans/actions/PlanActionsDropdownItems.tsx +++ b/packages/forklift-console-plugin/src/modules/Plans/actions/PlanActionsDropdownItems.tsx @@ -14,7 +14,14 @@ import { PlanDeleteModal, PlanStartMigrationModal, } from '../modals'; -import { canPlanReStart, canPlanStart, getPlanPhase, isPlanExecuting, PlanData } from '../utils'; +import { + canPlanReStart, + canPlanStart, + getPlanPhase, + isPlanArchived, + isPlanExecuting, + PlanData, +} from '../utils'; export const PlanActionsDropdownItems = ({ data }: PlanActionsDropdownItemsProps) => { const { t } = useForkliftTranslation(); @@ -33,6 +40,7 @@ export const PlanActionsDropdownItems = ({ data }: PlanActionsDropdownItemsProps const canStart = canPlanStart(plan); const canReStart = canPlanReStart(plan); const isWarmAndExecuting = plan?.spec?.warm && isPlanExecuting(plan); + const isArchived = isPlanArchived(plan); const buttonStartLabel = canReStart ? t('Restart migration') : t('Start migration'); @@ -67,7 +75,11 @@ export const PlanActionsDropdownItems = ({ data }: PlanActionsDropdownItemsProps {buttonStartLabel} , - + {t('Cutover')} , 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 44dd18a5b..c5712f3c8 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 @@ -117,5 +117,11 @@ export const isPlanEditable = (plan: V1beta1Plan) => { ); }; +export const isPlanArchived = (plan: V1beta1Plan) => { + const planStatus = getPlanPhase({ obj: plan }); + + return planStatus === 'Archiving' || planStatus === 'Archived'; +}; + const getConditions = (obj: V1beta1Plan) => obj?.status?.conditions?.filter((c) => c.status === 'True').map((c) => c.type); diff --git a/packages/forklift-console-plugin/src/modules/Plans/views/list/components/ActionsCell.tsx b/packages/forklift-console-plugin/src/modules/Plans/views/list/components/ActionsCell.tsx index a75a4d885..8a9fe3527 100644 --- a/packages/forklift-console-plugin/src/modules/Plans/views/list/components/ActionsCell.tsx +++ b/packages/forklift-console-plugin/src/modules/Plans/views/list/components/ActionsCell.tsx @@ -1,7 +1,12 @@ import React from 'react'; import { PlanActionsDropdown } from 'src/modules/Plans/actions'; import { PlanCutoverMigrationModal, PlanStartMigrationModal } from 'src/modules/Plans/modals'; -import { canPlanReStart, canPlanStart, isPlanExecuting } from 'src/modules/Plans/utils'; +import { + canPlanReStart, + canPlanStart, + isPlanArchived, + isPlanExecuting, +} from 'src/modules/Plans/utils'; import { useModal } from 'src/modules/Providers/modals'; import { useForkliftTranslation } from 'src/utils/i18n'; @@ -23,6 +28,7 @@ export const ActionsCell = ({ data }: CellProps) => { const canReStart = canPlanReStart(plan); const isWarmAndExecuting = plan?.spec?.warm && isPlanExecuting(plan); + const isArchived = isPlanArchived(plan); const buttonStartLabel = canReStart ? t('Restart') : t('Start'); const buttonStartIcon = canReStart ? : ; @@ -50,7 +56,7 @@ export const ActionsCell = ({ data }: CellProps) => { )} - {isWarmAndExecuting && ( + {isWarmAndExecuting && !isArchived && (