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 701b473ba..62f7d9ce1 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
@@ -128,6 +128,7 @@
"Delete Provider": "Delete Provider",
"Delete StorageMap": "Delete StorageMap",
"Delete virtual machines from migration plan": "Delete virtual machines from migration plan",
+ "Deleting virtual machines from an archived migration plan is not allowed.": "Deleting virtual machines from an archived migration plan is not allowed.",
"Description": "Description",
"Details": "Details",
"Determines the frequency with which the system checks the status of snapshot creation or removal during oVirt warm migration. The default value is 10 seconds.": "Determines the frequency with which the system checks the status of snapshot creation or removal during oVirt warm migration. The default value is 10 seconds.",
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/details/tabs/VirtualMachines/Migration/MigrationVirtualMachinesList.tsx b/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/VirtualMachines/Migration/MigrationVirtualMachinesList.tsx
index 194f69b65..abfc0ed6a 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/VirtualMachines/Migration/MigrationVirtualMachinesList.tsx
+++ b/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/VirtualMachines/Migration/MigrationVirtualMachinesList.tsx
@@ -5,7 +5,7 @@ import {
StandardPageWithSelectionProps,
} from 'src/components/page/StandardPageWithSelection';
import { usePlanMigration } from 'src/modules/Plans/hooks/usePlanMigration';
-import { isPlanExecuting } from 'src/modules/Plans/utils';
+import { isPlanArchived, isPlanExecuting } from 'src/modules/Plans/utils';
import { useForkliftTranslation } from 'src/utils/i18n';
import { loadUserSettings, ResourceFieldFactory } from '@kubev2v/common';
@@ -244,10 +244,11 @@ export const MigrationVirtualMachinesList: FC<{ obj: PlanData }> = ({ obj }) =>
}));
const isExecuting = isPlanExecuting(plan);
+ const isArchived = isPlanArchived(plan);
- // If plan executing allow to cancel vms, o/w remove from plan
+ // If plan executing and not archived (happens when archiving a running plan), allow to cancel vms, o/w remove from plan
let actions: PageGlobalActions;
- if (isExecuting) {
+ if (isExecuting && !isArchived) {
actions = [
({ selectedIds }) => (
diff --git a/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/VirtualMachines/modals/PlanVMsDeleteModal.tsx b/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/VirtualMachines/modals/PlanVMsDeleteModal.tsx
index bae968dd8..a65f48ee3 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/VirtualMachines/modals/PlanVMsDeleteModal.tsx
+++ b/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/VirtualMachines/modals/PlanVMsDeleteModal.tsx
@@ -1,4 +1,5 @@
import React, { ReactNode, useCallback, useState } from 'react';
+import { isPlanArchived } from 'src/modules/Plans/utils';
import { useToggle } from 'src/modules/Providers/hooks';
import { AlertMessageForModals, useModal } from 'src/modules/Providers/modals';
import { useForkliftTranslation } from 'src/utils/i18n';
@@ -23,6 +24,15 @@ export const PlanVMsDeleteModal: React.FC = ({ plan, se
const vms = (plan?.spec?.vms || []).filter((vm) => !selected.includes(vm.id)) || [];
React.useEffect(() => {
+ if (isPlanArchived(plan)) {
+ setAlertMessage(
+ ,
+ );
+ return;
+ }
if (vms.length < 1) {
setAlertMessage(
= ({ plan, se
/>,
);
}
- }, [vms]);
+ }, [vms, plan]);
const handleSave = useCallback(async () => {
toggleIsLoading();
@@ -63,7 +73,7 @@ export const PlanVMsDeleteModal: React.FC = ({ plan, se
key="confirm"
onClick={handleSave}
variant="danger"
- isDisabled={vms.length < 1}
+ isDisabled={vms.length < 1 || isPlanArchived(plan)}
isLoading={isLoading}
>
{t('Delete')}