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 1b70175bf..44dd18a5b 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 @@ -103,5 +103,19 @@ export const isPlanSucceeded = (plan: V1beta1Plan) => { return conditions?.includes('Succeeded'); }; +export const isPlanEditable = (plan: V1beta1Plan) => { + const planStatus = getPlanPhase({ obj: plan }); + + return ( + planStatus === 'Unknown' || + planStatus === 'Canceled' || + planStatus === 'Error' || + planStatus === 'Failed' || + planStatus === 'vmError' || + planStatus === 'Warning' || + planStatus === 'Ready' + ); +}; + 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/components/SettingsSection/components/PreserveClusterCpuModelDetailsItem.tsx b/packages/forklift-console-plugin/src/modules/Plans/views/details/components/SettingsSection/components/PreserveClusterCpuModelDetailsItem.tsx index 3772d869f..65b16f6fe 100644 --- a/packages/forklift-console-plugin/src/modules/Plans/views/details/components/SettingsSection/components/PreserveClusterCpuModelDetailsItem.tsx +++ b/packages/forklift-console-plugin/src/modules/Plans/views/details/components/SettingsSection/components/PreserveClusterCpuModelDetailsItem.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import { isPlanEditable } from 'src/modules/Plans/utils'; import { useModal } from 'src/modules/Providers/modals'; import { DetailsItem } from 'src/modules/Providers/utils'; import { useForkliftTranslation } from 'src/utils/i18n'; @@ -40,6 +41,7 @@ export const PreserveClusterCpuModelDetailsItem: React.FC crumbs={['spec', 'preserveClusterCpuModel']} onEdit={ canPatch && + isPlanEditable(resource) && (() => showModal( = ({ crumbs={['spec', 'preserveStaticIPs']} onEdit={ canPatch && + isPlanEditable(resource) && (() => showModal( = ({ helpContent={helpContent ?? defaultHelpContent} moreInfoLink={VIRT_V2V_HELP_LINK} crumbs={['spec', 'vms', 'rootDisk']} - onEdit={canPatch && (() => showModal())} + onEdit={ + canPatch && + isPlanEditable(resource) && + (() => showModal()) + } /> ); }; diff --git a/packages/forklift-console-plugin/src/modules/Plans/views/details/components/SettingsSection/components/SetLUKSEncryptionPasswordsDetailsItem.tsx b/packages/forklift-console-plugin/src/modules/Plans/views/details/components/SettingsSection/components/SetLUKSEncryptionPasswordsDetailsItem.tsx index 4ad01e9f8..3658fab51 100644 --- a/packages/forklift-console-plugin/src/modules/Plans/views/details/components/SettingsSection/components/SetLUKSEncryptionPasswordsDetailsItem.tsx +++ b/packages/forklift-console-plugin/src/modules/Plans/views/details/components/SettingsSection/components/SetLUKSEncryptionPasswordsDetailsItem.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import { isPlanEditable } from 'src/modules/Plans/utils'; import { useModal } from 'src/modules/Providers/modals'; import { DetailsItem } from 'src/modules/Providers/utils'; import { useForkliftTranslation } from 'src/utils/i18n'; @@ -43,6 +44,7 @@ export const SetLUKSEncryptionPasswordsDetailsItem: React.FC showModal( = ({ crumbs={['spec', 'targetNamespace ']} onEdit={ canPatch && + isPlanEditable(resource) && (() => showModal( = ({ crumbs={['spec', 'transferNetwork ']} onEdit={ canPatch && + isPlanEditable(resource) && (() => showModal( = ({ crumbs={['spec', 'warm ']} onEdit={ canPatch && + isPlanEditable(resource) && (() => showModal()) }