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 835f5ae72..bbbd50982 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
@@ -58,6 +58,8 @@
"Boot from the second hard drive": "Boot from the second hard drive",
"Boot from the second partition on the first hard drive": "Boot from the second partition on the first hard drive",
"Boot from the second partition on the second hard drive": "Boot from the second partition on the second hard drive",
+ "Button is disabled since the plan status does not enable editing.": "Button is disabled since the plan status does not enable editing.",
+ "Button is disabled until a change is detected.": "Button is disabled until a change is detected.",
"CA certificate": "CA certificate",
"CA certificate - disabled when 'Skip certificate validation' is selected": "CA certificate - disabled when 'Skip certificate validation' is selected",
"CA certificate - leave empty to use system CA certificates": "CA certificate - leave empty to use system CA certificates",
@@ -74,7 +76,7 @@
"Clear all filters": "Clear all filters",
"Click the pencil for setting provider web UI link": "Click the pencil for setting provider web UI link",
"Click the update credentials button to save your changes, button is disabled until a change is detected.": "Click the update credentials button to save your changes, button is disabled until a change is detected.",
- "Click the update hooks button to save your changes, button is disabled until a change is detected.": "Click the update hooks button to save your changes, button is disabled until a change is detected.",
+ "Click the update hooks button to save your changes.": "Click the update hooks button to save your changes.",
"Click the update mappings button to save your changes, button is disabled until a change is detected.": "Click the update mappings button to save your changes, button is disabled until a change is detected.",
"Click to select a different provider from the list.": "Click to select a different provider from the list.",
"Click to unselect.": "Click to unselect.",
@@ -484,7 +486,7 @@
"The certificate is not a valid PEM-encoded X.509 certificate": "The certificate is not a valid PEM-encoded X.509 certificate",
"The chosen provider is no longer available.": "The chosen provider is no longer available.",
"The current certificate does not match the certificate fetched from URL. Manually validate the fingerprint before proceeding.": "The current certificate does not match the certificate fetched from URL. Manually validate the fingerprint before proceeding.",
- "The edit mappings button is disabled if the plan started running and at least one virtual machine was migrated successfully.": "The edit mappings button is disabled if the plan started running and at least one virtual machine was migrated successfully.",
+ "The edit mappings button is disabled if the plan started running and at least one virtual machine was migrated successfully or when the plan status does not enable editing.": "The edit mappings button is disabled if the plan started running and at least one virtual machine was migrated successfully or when the plan status does not enable editing.",
"The interval in minutes for precopy. Default value is 60.": "The interval in minutes for precopy. Default value is 60.",
"The interval in seconds for snapshot pooling. Default value is 10.": "The interval in seconds for snapshot pooling. Default value is 10.",
"The limit for CPU usage by the controller, specified in milliCPU. Default value is 500m.": "The limit for CPU usage by the controller, specified in milliCPU. Default value is 500m.",
diff --git a/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/Hooks/PlanHooks.tsx b/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/Hooks/PlanHooks.tsx
index 2a9e747b5..c648a1c49 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/Hooks/PlanHooks.tsx
+++ b/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/Hooks/PlanHooks.tsx
@@ -1,6 +1,7 @@
import React, { useEffect, useReducer } from 'react';
import { Base64 } from 'js-base64';
import SectionHeading from 'src/components/headers/SectionHeading';
+import { isPlanEditable } from 'src/modules/Plans/utils';
import { AlertMessageForModals } from 'src/modules/Providers/modals';
import { useForkliftTranslation } from 'src/utils/i18n';
@@ -58,6 +59,19 @@ export const PlanHooks: React.FC<{ name: string; namespace: string }> = ({ name,
});
};
+ const buttonHelperMsg = () => {
+ let updateButtonDisabledMsg = '';
+
+ if (!isPlanEditable(plan))
+ updateButtonDisabledMsg = t(
+ 'Button is disabled since the plan status does not enable editing.',
+ );
+ else if (!state.hasChanges)
+ updateButtonDisabledMsg = t('Button is disabled until a change is detected.');
+
+ return t('Click the update hooks button to save your changes.') + ' ' + updateButtonDisabledMsg;
+ };
+
const HooksTabAction = (
<>
@@ -65,7 +79,7 @@ export const PlanHooks: React.FC<{ name: string; namespace: string }> = ({ name,
-
-
- {t(
- 'Click the update hooks button to save your changes, button is disabled until a change is detected.',
- )}
-
+ {buttonHelperMsg()}
@@ -231,7 +240,7 @@ export const PlanHooks: React.FC<{ name: string; namespace: string }> = ({ name,
value={state.postHook?.spec?.image}
type="url"
onChange={(e, v) => onChangePostHookImage(v, e)}
- aria-label="pre hook image"
+ aria-label="post hook image"
/>
diff --git a/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/Mappings/PlanMappingsSection.tsx b/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/Mappings/PlanMappingsSection.tsx
index 66e001cea..5bf78ae11 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/Mappings/PlanMappingsSection.tsx
+++ b/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/Mappings/PlanMappingsSection.tsx
@@ -1,4 +1,5 @@
import React, { ReactNode, useReducer, useState } from 'react';
+import { isPlanEditable } from 'src/modules/Plans/utils';
import { InventoryNetwork } from 'src/modules/Providers/hooks/useNetworks';
import { InventoryStorage } from 'src/modules/Providers/hooks/useStorages';
import { useForkliftTranslation } from 'src/utils/i18n';
@@ -35,8 +36,8 @@ import Pencil from '@patternfly/react-icons/dist/esm/icons/pencil-alt-icon';
import { Mapping, MappingList } from '../../components';
import {
canDeleteAndPatchPlanHooks,
- hasPlanEditable,
hasPlanMappingsChanged,
+ hasSomeCompleteRunningVMs,
mapSourceNetworksIdsToLabels,
mapSourceStoragesIdsToLabels,
mapTargetNetworksIdsToLabels,
@@ -564,7 +565,7 @@ export const PlanMappingsSection: React.FC = ({
const PlanMappingsSectionViewMode: React.FC = () => {
const { t } = useForkliftTranslation();
- const DisableEditMappings = !hasPlanEditable(plan);
+ const DisableEditMappings = hasSomeCompleteRunningVMs(plan) || !isPlanEditable(plan);
return (
<>
@@ -583,7 +584,7 @@ export const PlanMappingsSection: React.FC = ({
{t(
- 'The edit mappings button is disabled if the plan started running and at least one virtual machine was migrated successfully.',
+ 'The edit mappings button is disabled if the plan started running and at least one virtual machine was migrated successfully or when the plan status does not enable editing.',
)}
diff --git a/packages/forklift-console-plugin/src/modules/Plans/views/details/utils/hasPlanEditable.ts b/packages/forklift-console-plugin/src/modules/Plans/views/details/utils/hasSomeCompleteRunningVMs.ts
similarity index 75%
rename from packages/forklift-console-plugin/src/modules/Plans/views/details/utils/hasPlanEditable.ts
rename to packages/forklift-console-plugin/src/modules/Plans/views/details/utils/hasSomeCompleteRunningVMs.ts
index ef1b85dc4..50ca64360 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/views/details/utils/hasPlanEditable.ts
+++ b/packages/forklift-console-plugin/src/modules/Plans/views/details/utils/hasSomeCompleteRunningVMs.ts
@@ -1,6 +1,6 @@
import { V1beta1Plan } from '@kubev2v/types';
-export const hasPlanEditable = (plan: V1beta1Plan) => {
+export const hasSomeCompleteRunningVMs = (plan: V1beta1Plan) => {
const planHasNeverStarted = !plan.status?.migration?.started ? true : false;
const migrationHasSomeCompleteRunningVMs =
@@ -10,5 +10,5 @@ export const hasPlanEditable = (plan: V1beta1Plan) => {
vm.phase !== 'Completed',
).length > 0 || false;
- return planHasNeverStarted || !migrationHasSomeCompleteRunningVMs;
+ return !planHasNeverStarted && migrationHasSomeCompleteRunningVMs;
};
diff --git a/packages/forklift-console-plugin/src/modules/Plans/views/details/utils/index.ts b/packages/forklift-console-plugin/src/modules/Plans/views/details/utils/index.ts
index 0af5f24d7..46a7383f7 100644
--- a/packages/forklift-console-plugin/src/modules/Plans/views/details/utils/index.ts
+++ b/packages/forklift-console-plugin/src/modules/Plans/views/details/utils/index.ts
@@ -4,8 +4,8 @@ export * from './constants';
export * from './getInventoryApiUrl';
export * from './getValueByJsonPath';
export * from './hasPipelineCompleted';
-export * from './hasPlanEditable';
export * from './hasPlanMappingsChanged';
+export * from './hasSomeCompleteRunningVMs';
export * from './hasTaskCompleted';
export * from './mapMappingsIdsToLabels';
export * from './patchPlanMappingsData';