Skip to content

Commit

Permalink
Disable the cutover action for an archived plan.
Browse files Browse the repository at this point in the history
Reference: https://issues.redhat.com/browse/MTV-1729

Disable the cutover action for an archived plan.

Signed-off-by: Sharon Gratch <[email protected]>
  • Loading branch information
sgratch committed Dec 3, 2024
1 parent 54656ca commit e1ca773
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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');

Expand Down Expand Up @@ -67,7 +75,11 @@ export const PlanActionsDropdownItems = ({ data }: PlanActionsDropdownItemsProps
{buttonStartLabel}
</DropdownItem>,

<DropdownItem key="cutover" isDisabled={!isWarmAndExecuting} onClick={onClickPlanCutover}>
<DropdownItem
key="cutover"
isDisabled={!isWarmAndExecuting || isArchived}
onClick={onClickPlanCutover}
>
{t('Cutover')}
</DropdownItem>,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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 ? <ReStartIcon /> : <StartIcon />;
Expand Down Expand Up @@ -50,7 +56,7 @@ export const ActionsCell = ({ data }: CellProps) => {
</FlexItem>
)}

{isWarmAndExecuting && (
{isWarmAndExecuting && !isArchived && (
<FlexItem align={{ default: 'alignRight' }}>
<Button
variant="secondary"
Expand Down

0 comments on commit e1ca773

Please sign in to comment.