From f5cc7680a2d5315e86dd73942a7b38a76a757eca Mon Sep 17 00:00:00 2001 From: Sharon Gratch Date: Fri, 20 Dec 2024 01:08:49 +0200 Subject: [PATCH] Fix regression of omittig the plan name mandatory Reference: https://issues.redhat.com/browse/MTV-1845 Add back the 'plan name' mandatory field to be visible and set in the plan creation's wizard step 2, since otherwise creating the plan is blocked by the plan creation use cases. Signed-off-by: Sharon Gratch --- .../en/plugin__forklift-console-plugin.json | 2 + .../create/components/PlanCreateForm.tsx | 14 ------ .../migrate/components/PlansCreateForm.tsx | 46 ++++++++++++++++++- 3 files changed, 47 insertions(+), 15 deletions(-) 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 6ce5cda5..65463ecf 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 @@ -158,6 +158,7 @@ "Edit migration plan transfer network": "Edit migration plan transfer network", "Edit NetworkMap": "Edit NetworkMap", "Edit Plan": "Edit Plan", + "Edit plan name": "Edit plan name", "Edit Precopy interval (minutes)": "Edit Precopy interval (minutes)", "Edit Provider": "Edit Provider", "Edit Provider Credentials": "Edit Provider Credentials", @@ -267,6 +268,7 @@ "Multiple NICs on the same network": "Multiple NICs on the same network", "Name": "Name", "Name is primarily intended for creation idempotence and configuration definition. Cannot be updated.": "Name is primarily intended for creation idempotence and configuration definition. Cannot be updated.", + "Name is required and must be a unique within a namespace and valid Kubernetes name.": "Name is required and must be a unique within a namespace and valid Kubernetes name.", "Namespace": "Namespace", "Namespace defines the space within which each name must be unique.\n An empty namespace is equivalent to the \"default\" namespace, but \"default\" is the canonical representation.\n Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty.": "Namespace defines the space within which each name must be unique.\n An empty namespace is equivalent to the \"default\" namespace, but \"default\" is the canonical representation.\n Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty.", "Namespace defines the space within which each name must be unique.\n An empty namespace is equivalent to the \"default\" namespace, but \"default\" is the canonical representation.\n Not all objects are required to be scoped to a namespace -\n the value of this field for those objects will be empty.": "Namespace defines the space within which each name must be unique.\n An empty namespace is equivalent to the \"default\" namespace, but \"default\" is the canonical representation.\n Not all objects are required to be scoped to a namespace -\n the value of this field for those objects will be empty.", diff --git a/packages/forklift-console-plugin/src/modules/Plans/views/create/components/PlanCreateForm.tsx b/packages/forklift-console-plugin/src/modules/Plans/views/create/components/PlanCreateForm.tsx index 4916ba61..72941d91 100644 --- a/packages/forklift-console-plugin/src/modules/Plans/views/create/components/PlanCreateForm.tsx +++ b/packages/forklift-console-plugin/src/modules/Plans/views/create/components/PlanCreateForm.tsx @@ -5,7 +5,6 @@ import { VmData } from 'src/modules/Providers/views'; import { useCreateVmMigrationData } from 'src/modules/Providers/views/migrate'; import { PageAction, - setPlanName, setProjectName as setProjectNameAction, } from 'src/modules/Providers/views/migrate/reducer/actions'; import { CreateVmMigrationPageState } from 'src/modules/Providers/views/migrate/types'; @@ -20,7 +19,6 @@ import { PlanCreatePageState } from '../states'; import { ChipsToolbarProviders } from './ChipsToolbarProviders'; import { createProviderCardItems } from './createProviderCardItems'; import { FiltersToolbarProviders } from './FiltersToolbarProviders'; -import { PlanNameTextField } from './PlanNameTextField'; import { ProjectNameSelect } from './ProjectNameSelect'; export type PlanCreateFormProps = { @@ -42,7 +40,6 @@ export type PlanCreateFormProps = { export const PlanCreateForm: React.FC = ({ providers, filterState, - state, projectName, filterDispatch, dispatch, @@ -61,17 +58,6 @@ export const PlanCreateForm: React.FC = ({ return (
- { - dispatch(setPlanName(value?.trim() ?? '')); - setData({ ...data, planName: value }); - }} - /> - ({ diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/migrate/components/PlansCreateForm.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/migrate/components/PlansCreateForm.tsx index f34e00fc..bb61cdf2 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/migrate/components/PlansCreateForm.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/migrate/components/PlansCreateForm.tsx @@ -1,4 +1,4 @@ -import React, { ReactNode } from 'react'; +import React, { ReactNode, useState } from 'react'; import { FilterableSelect } from 'src/components'; import SectionHeading from 'src/components/headers/SectionHeading'; import { ForkliftTrans, useForkliftTranslation } from 'src/utils/i18n'; @@ -21,6 +21,7 @@ import { FormSelectOption, Stack, StackItem, + TextInput, } from '@patternfly/react-core'; import { DetailsItem, getIsTarget } from '../../../utils'; @@ -33,11 +34,13 @@ import { removeAlert, replaceNetworkMapping, replaceStorageMapping, + setPlanName, setPlanTargetNamespace, setPlanTargetProvider, } from '../reducer/actions'; import { CreateVmMigrationPageState, NetworkAlerts, StorageAlerts } from '../types'; +import { EditableDescriptionItem } from './EditableDescriptionItem'; import { MappingList } from './MappingList'; import { MappingListHeader } from './MappingListHeader'; import { StateAlerts } from './StateAlerts'; @@ -140,9 +143,17 @@ export const PlansCreateForm = ({ alerts, } = state; + const [isNameEdited, setIsNameEdited] = useState(true); + const networkMessages = buildNetworkMessages(t); const storageMessages = buildStorageMessages(t); + const onChangePlan: (value: string, event: React.FormEvent) => void = ( + value, + ) => { + dispatch(setPlanName(value?.trim() ?? '')); + }; + const onChangeTargetProvider: ( value: string, event: React.FormEvent, @@ -159,6 +170,39 @@ export const PlansCreateForm = ({ default: '1Col', }} > + {isNameEdited || validation.planName === 'error' ? ( + + + onChangePlan(v, e)} + /> + + + ) : ( + setIsNameEdited(true)} + isDisabled={flow.editingDone} + /> + )} +