Skip to content

Commit 78f1a53

Browse files
committed
Resolves: MTV-3742 | Standartize plan mappings tab
Signed-off-by: Aviv Turgeman <[email protected]>
1 parent 426ec5a commit 78f1a53

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1154
-1838
lines changed

locales/en/plugin__forklift-console-plugin.json

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@
212212
"Click on \"Create migration plan\".": "Click on \"Create migration plan\".",
213213
"Click the pencil for setting provider web UI link": "Click the pencil for setting provider web UI link",
214214
"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.",
215-
"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.",
216215
"Click to select a different provider from the list.": "Click to select a different provider from the list.",
217216
"Click to unselect": "Click to unselect",
218217
"Close": "Close",
@@ -295,7 +294,6 @@
295294
"Defines the CPU limits allocated to the main container in the controller pod. The default value is 500 milliCPU.": "Defines the CPU limits allocated to the main container in the controller pod. The default value is 500 milliCPU.",
296295
"Delete": "Delete",
297296
"Delete {{model.label}}": "Delete {{model.label}}",
298-
"Delete mapping": "Delete mapping",
299297
"Delete network map": "Delete network map",
300298
"Delete plan": "Delete plan",
301299
"Delete provider": "Delete provider",
@@ -339,7 +337,6 @@
339337
"Edit default transfer network": "Edit default transfer network",
340338
"Edit description": "Edit description",
341339
"Edit labels": "Edit labels",
342-
"Edit mappings": "Edit mappings",
343340
"Edit migration plan target project": "Edit migration plan target project",
344341
"Edit migration plan transfer network": "Edit migration plan transfer network",
345342
"Edit network map": "Edit network map",
@@ -634,7 +631,6 @@
634631
"Network map is required.": "Network map is required.",
635632
"Network map name": "Network map name",
636633
"Network map YAML": "Network map YAML",
637-
"Network map:": "Network map:",
638634
"Network maps": "Network maps",
639635
"Network maps ensure that the network configurations of your migrating virtual machines (VMs) are correctly translated and applied in the target environment.": "Network maps ensure that the network configurations of your migrating virtual machines (VMs) are correctly translated and applied in the target environment.",
640636
"Network name template": "Network name template",
@@ -658,7 +654,6 @@
658654
"No network mappings selected": "No network mappings selected",
659655
"No network maps found": "No network maps found",
660656
"No network maps found in project <1>{namespace}</1>.": "No network maps found in project <1>{namespace}</1>.",
661-
"No networks in this category": "No networks in this category",
662657
"No node selectors defined": "No node selectors defined",
663658
"No options available": "No options available",
664659
"No owner": "No owner",
@@ -679,7 +674,6 @@
679674
"No storage maps found": "No storage maps found",
680675
"No storage maps found in project <1>{namespace}</1>.": "No storage maps found in project <1>{namespace}</1>.",
681676
"No storages available": "No storages available",
682-
"No storages in this category": "No storages in this category",
683677
"No value for provider web UI link": "No value for provider web UI link",
684678
"No VMs have been selected": "No VMs have been selected",
685679
"Node": "Node",
@@ -688,7 +682,6 @@
688682
"Node labels": "Node labels",
689683
"Node selector enables constraining virtual machines scheduling to specific nodes, based on node labels. Adding labels below will schedule virtual machines only on nodes which contain the specified labels.": "Node selector enables constraining virtual machines scheduling to specific nodes, based on node labels. Adding labels below will schedule virtual machines only on nodes which contain the specified labels.",
690684
"None": "None",
691-
"Not available": "Not available",
692685
"Not in": "Not in",
693686
"Not Ready": "Not Ready",
694687
"not started": "not started",
@@ -742,10 +735,8 @@
742735
"OpenStack token for authentication using a user name. [required]": "OpenStack token for authentication using a user name. [required]",
743736
"Operator": "Operator",
744737
"Other networks present on the source provider": "Other networks present on the source provider",
745-
"Other networks present on the source provider ": "Other networks present on the source provider ",
746738
"Other settings (optional)": "Other settings (optional)",
747739
"Other storages present on the source provider": "Other storages present on the source provider",
748-
"Other storages present on the source provider ": "Other storages present on the source provider ",
749740
"OvaPath": "OvaPath",
750741
"Overview": "Overview",
751742
"Owner": "Owner",
@@ -979,7 +970,6 @@
979970
"Storage map name": "Storage map name",
980971
"Storage map type": "Storage map type",
981972
"Storage map YAML": "Storage map YAML",
982-
"Storage map:": "Storage map:",
983973
"Storage maps": "Storage maps",
984974
"Storage maps define how the storage of source VMs will be provisioned on the target cluster by linking source storage entities to target storage classes.": "Storage maps define how the storage of source VMs will be provisioned on the target cluster by linking source storage entities to target storage classes.",
985975
"Storage product": "Storage product",
@@ -1014,7 +1004,6 @@
10141004
"The commercial product name or model of the storage system being used. This helps ensure the correct features and APIs will be used.": "The commercial product name or model of the storage system being used. This helps ensure the correct features and APIs will be used.",
10151005
"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.",
10161006
"The default setting is \"Providers default,\" which uses the default network configured for your source and target providers. You can select a specific NetworkAttachmentDefinition from the dropdown list if you want to use a dedicated network for migration data to improve performance or security.": "The default setting is \"Providers default,\" which uses the default network configured for your source and target providers. You can select a specific NetworkAttachmentDefinition from the dropdown list if you want to use a dedicated network for migration data to improve performance or security.",
1017-
"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.",
10181007
"The Manager CA certificate unless it was replaced by a third-party certificate, in which case, enter the Manager Apache CA certificate.": "The Manager CA certificate unless it was replaced by a third-party certificate, in which case, enter the Manager Apache CA certificate.",
10191008
"The mapping data from the inventory is not available, {{resourcesError}}.": "The mapping data from the inventory is not available, {{resourcesError}}.",
10201009
"The password for the ESXi host admin": "The password for the ESXi host admin",
@@ -1044,10 +1033,8 @@
10441033
"The provider name is required.": "The provider name is required.",
10451034
"The repository or virtualization platform you want to migrate your virtual machines from into the OpenShift cluster.": "The repository or virtualization platform you want to migrate your virtual machines from into the OpenShift cluster.",
10461035
"The Secret was not loaded. Try reloading the page or check if the secret exists. ": "The Secret was not loaded. Try reloading the page or check if the secret exists. ",
1047-
"The source mapping data from the inventory is not available: {{resourcesError}}.": "The source mapping data from the inventory is not available: {{resourcesError}}.",
10481036
"The storage device or partition that contains the root filesystem. For example, naming a root device \"sdb2/boot/dev\" would mean to use the second partition on the first hard drive.": "The storage device or partition that contains the root filesystem. For example, naming a root device \"sdb2/boot/dev\" would mean to use the second partition on the first hard drive.",
10491037
"The target project is the project, within your selected target provider, that your virtual machines will be migrated to. This is different from the project that your migration plan will be created in and where your provider was created.": "The target project is the project, within your selected target provider, that your virtual machines will be migrated to. This is different from the project that your migration plan will be created in and where your provider was created.",
1050-
"The target storage mapping data from the inventory is not available: {{resourcesError}}.": "The target storage mapping data from the inventory is not available: {{resourcesError}}.",
10511038
"The uploaded file name extension should be .ova": "The uploaded file name extension should be .ova",
10521039
"The URL is invalid. URL should include the schema, for example: https://example.com:6443.": "The URL is invalid. URL should include the schema, for example: https://example.com:6443.",
10531040
"The URL is required. URL should include the schema and path, for example: https://rhv-host-example.com/ovirt-engine/api": "The URL is required. URL should include the schema and path, for example: https://rhv-host-example.com/ovirt-engine/api",
@@ -1100,7 +1087,6 @@
11001087
"Unknown power state": "Unknown power state",
11011088
"Unsupported provider type": "Unsupported provider type",
11021089
"Update credentials": "Update credentials",
1103-
"Update mappings": "Update mappings",
11041090
"Updated": "Updated",
11051091
"updating the hooks will override the current configuration.": "updating the hooks will override the current configuration.",
11061092
"updating the LUKS decryption keys will override the current configuration.": "updating the LUKS decryption keys will override the current configuration.",

src/networkMaps/create/utils/buildNetworkMappings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const getDestinationNetName = (
111111
return DEFAULT_NETWORK;
112112
};
113113

114-
export const buildFormNetworkMapping = (
114+
export const getNetworkMappingValues = (
115115
specMapping: V1beta1NetworkMapSpecMap[] | undefined,
116116
sourceProvider: V1beta1Provider | undefined,
117117
sourceNetworks: InventoryNetwork[] = [],

src/networkMaps/details/tabs/Details/NetworkMapDetailsTab.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type FC, useMemo } from 'react';
22
import SectionHeading from 'src/components/headers/SectionHeading';
33
import { useOpenShiftNetworks, useSourceNetworks } from 'src/modules/Providers/hooks/useNetworks';
4-
import { buildFormNetworkMapping } from 'src/networkMaps/create/utils/buildNetworkMappings';
4+
import { getNetworkMappingValues } from 'src/networkMaps/create/utils/buildNetworkMappings';
55
import NetworkMapReviewTable from 'src/plans/create/steps/review/NetworkMapReviewTable';
66
import { useForkliftTranslation } from 'src/utils/i18n';
77

@@ -69,7 +69,7 @@ const NetworkMapDetailsTab: FC<NetworkMapDetailsTabProps> = ({ name, namespace }
6969

7070
const currentMappings = useMemo(
7171
() =>
72-
buildFormNetworkMapping(
72+
getNetworkMappingValues(
7373
networkMap?.spec?.map,
7474
sourceProvider,
7575
sourceNetworks,

src/plans/create/hooks/useInitializeMappings.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { isEmpty } from '@utils/helpers';
55

66
import type { MappingFieldIds, MappingValue } from '../types';
77
import { fillUnmappedSources } from '../utils/fillUnmappedSources';
8-
98
type UseInitializeMappingsParams<T extends Record<string, unknown>> = {
109
isLoading: boolean;
1110
currentMap: T[] | undefined;
@@ -75,7 +74,7 @@ export const useInitializeMappings = <T extends Record<string, unknown>>({
7574
[fieldIds.targetField]: targetValue,
7675
};
7776

78-
setValue(fieldIds.mapField, [emptyMapping]);
77+
setValue(fieldIds.mapField, [emptyMapping], { shouldDirty: true, shouldValidate: true });
7978
hasInitializedRef.current = true;
8079
return;
8180
}
@@ -95,11 +94,11 @@ export const useInitializeMappings = <T extends Record<string, unknown>>({
9594
unmappedSources,
9695
});
9796

98-
setValue(fieldIds.mapField, updatedMappings);
97+
setValue(fieldIds.mapField, updatedMappings, { shouldDirty: true, shouldValidate: true });
9998

10099
// Trigger validation to ensure form state is correct
101100
setTimeout(async () => {
102-
await trigger(fieldIds.mapField);
101+
await trigger();
103102
}, 0);
104103

105104
unmappedSources.forEach((source) => {

src/plans/create/steps/network-map/constants.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { IgnoreNetwork } from 'src/plans/details/tabs/Mappings/utils/constants';
2+
13
import { DEFAULT_NETWORK } from '@utils/constants';
24
import { t } from '@utils/i18n';
35

46
import type { MappingValue } from '../../types';
5-
67
export enum NetworkMapFieldId {
78
NetworkMap = 'networkMap',
89
ExistingNetworkMap = 'existingNetworkMap',
@@ -29,6 +30,11 @@ export const defaultNetMapping: NetworkMapping = {
2930
[NetworkMapFieldId.TargetNetwork]: { name: DEFAULT_NETWORK },
3031
};
3132

33+
export const ignoreNetMapping: NetworkMapping = {
34+
[NetworkMapFieldId.SourceNetwork]: { name: '' },
35+
[NetworkMapFieldId.TargetNetwork]: { name: IgnoreNetwork.Label },
36+
};
37+
3238
export enum NetworkMapType {
3339
New = 'new',
3440
Existing = 'existing',

src/plans/create/steps/network-map/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { hasMultiplePodNetworkMappings } from '../../utils/hasMultiplePodNetwork
1616
import { getMapResourceLabel } from '../utils';
1717

1818
import { defaultNetMapping, NetworkMapFieldId, type NetworkMapping } from './constants';
19-
2019
type NetworkMappingId = `${NetworkMapFieldId.NetworkMap}.${number}.${keyof NetworkMapping}`;
2120

2221
type ValidateNetworkMapParams = {

src/plans/create/steps/review/NetworkMapReviewTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ const NetworkMapReviewTable: FC<NetworkMapReviewTableProps> = ({ networkMap }) =
2222
<Table aria-label="Network map review table" variant={TableVariant.compact} borders>
2323
<Thead>
2424
<Tr>
25-
<Th>{t('Source network')}</Th>
26-
<Th>{t('Target network')}</Th>
25+
<Th width={50}>{t('Source network')}</Th>
26+
<Th width={50}>{t('Target network')}</Th>
2727
</Tr>
2828
</Thead>
2929

src/plans/create/steps/review/StorageMapReviewTable.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ const StorageMapReviewTable: FC<StorageMapReviewTableProps> = ({ storageMap }) =
4646
<Table aria-label="Storage map review table" variant={TableVariant.compact} borders>
4747
<Thead>
4848
<Tr>
49-
{hasOffloadStorage && <Th />}
50-
<Th>{storageMapFieldLabels[CreatePlanStorageMapFieldId.SourceStorage]}</Th>
51-
<Th>{storageMapFieldLabels[CreatePlanStorageMapFieldId.TargetStorage]}</Th>
49+
{hasOffloadStorage && <Th width={10} />}
50+
<Th width={hasOffloadStorage ? 45 : 50}>
51+
{storageMapFieldLabels[CreatePlanStorageMapFieldId.SourceStorage]}
52+
</Th>
53+
<Th width={hasOffloadStorage ? 45 : 50}>
54+
{storageMapFieldLabels[CreatePlanStorageMapFieldId.TargetStorage]}
55+
</Th>
5256
</Tr>
5357
</Thead>
5458

src/plans/create/utils/hasMultiplePodNetworkMappings.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ export const hasMultiplePodNetworkMappings = (
2727
return mappedNetworks.length >= 2;
2828
});
2929
};
30+
31+
export const hasPodNetworkMappings = (networkMap: NetworkMapping[]) => {
32+
return networkMap.some(({ targetNetwork }) => targetNetwork?.name === DefaultNetworkLabel.Source);
33+
};

src/plans/details/hooks/usePlanPages.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import PlanMappingsPage from '../tabs/Mappings/PlanMappingsPage';
99
import PlanResourcesPage from '../tabs/Resources/PlanResourcesPage';
1010
import PlanVirtualMachinesPage from '../tabs/VirtualMachines/PlanVirtualMachinesPage';
1111
import PlanYAMLPage from '../tabs/YAML/PlanYAMLPage';
12-
1312
const usePlanPages = (name: string, namespace: string) => {
1413
const { t } = useForkliftTranslation();
1514

0 commit comments

Comments
 (0)