-
Notifications
You must be signed in to change notification settings - Fork 41
Resolves: MTV-3743 | Standartize plan mappings tab #2147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2147 +/- ##
===========================================
- Coverage 36.81% 13.40% -23.41%
===========================================
Files 158 1065 +907
Lines 2548 20095 +17547
Branches 599 3900 +3301
===========================================
+ Hits 938 2694 +1756
- Misses 1428 17391 +15963
+ Partials 182 10 -172 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
66a0635 to
78f1a53
Compare
sgratch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, the mappings tab works much better now so this is a great improvement.
Please see my comments below.
| }, | ||
| tooltip: (index) => { | ||
| if (networkMappingFields.length <= 1) { | ||
| return t('At least one network mapping must be provided.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This validation is not accurate.
There are cases in which there is no network mappings exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean we should allow an empty mapping?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this tooltip appears on the delete button when disabling the delete button when we have just one mapping
| }; | ||
|
|
||
| export const buildFormNetworkMapping = ( | ||
| export const getNetworkMappingValues = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the calculation of the source network entries for oVirt is not taking into account the data center (i.e. it's set to net1 instead of data-center1/net1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed I was getting the name from the inventory network and not the name from the map resource
| plan: V1beta1Plan, | ||
| sourceProvider: V1beta1Provider, | ||
| ): Record<string, ProviderVirtualMachine> => { | ||
| const [providerVmData, isVmDataLoading] = useInventoryVms({ provider: sourceProvider }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const [providerVmData, isVmDataLoading] = useInventoryVms({ provider: sourceProvider }); | |
| const [providerVmData, isVmDataLoading, error] = useInventoryVms({ provider: sourceProvider }); |
Worth adding error handling for fetching vms from the inventory
| [availableTargetNetworks, targetProject], | ||
| ); | ||
|
|
||
| const message = useMemo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move lines 92 -115 to be located after calculating the isLoading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't, everything is wrapped in useMemo as we have get all the data here, and all hooks must run all the times meaning I can't move that block
| sourceStorages={sourceStorages} | ||
| targetNetworks={targetNetworks} | ||
| targetStorages={targetStorages} | ||
| <SectionHeadingWithEdit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth adding a link ot a string of the created mappings entity name for both network and storage, the same as was in old UI. Otherwise it will be hard for the user to find this mapping in the network, storage maps list page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it to the UI, this is the best location I could think of, @mmenestr can you have an opinion on this

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Editing names of resources in kubernetes like network maps/plan/providers is not allowed, but I will change the display accordingly, Thank you
| loadError: Error | null; | ||
| }; | ||
|
|
||
| const PlanNetworkMapFieldsTable: FC<PlanNetworkMapFieldsTableProps> = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PlanNetworkMapFieldsTable component and PlanStorageMapFieldsTableshare a lot of logic. Can we combine it into a shared component used by both or is it too complicated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've explored this possibility myself, however I already use a similar component, soI can extract the logic above the component to a custom hook but it wasn't saving code, infact it doubled the code, and the the readability didn't improved (since we now also have another generic-ish hook that needs to be in use)
| targetNetworks: Record<string, MappingValue>; | ||
| }; | ||
|
|
||
| const TargetNetworkField: FC<TargetNetworkFieldProps> = ({ fieldId, targetNetworks }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 3 components that at least 2 of them look identical, one for create and one for edit plans and the 3d for network maps editing:
- networkMaps/create/fields/TargetNetworkField
- plans/create/steps/network-map/TargetNetworkField
-plans/details/tabs/Mappings/components/PlanNetworkMapEdit/components TargetNetworkField
Can we combine them and use one component for all?
| otherSourceNetworks: MappingValue[]; | ||
| }; | ||
|
|
||
| const SourceNetworkField: FC<SourceNetworkFieldProps> = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two components that looks identical, one for create and one for edit plans:
details/tabs/Mappings/components/PlanNetworkMapEdit/components/SourceNetworkFieldcreate/steps/network-map/SourceNetworkField
Can we combine them and use one component for both?
| title={t('Edit network map')} | ||
| closeModal={closeModal} | ||
| variant={ModalVariant.medium} | ||
| isDisabled={!isValid || !isDirty} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please handle cases in which you can't edit the plan mappings and it should be disabled. E.g. plan is completed, archived, running while at least one vm was finished the migration successfully..)
Maybe even better to handle that in SectionHeadingWithEdit and not here.
| title={t('Edit storage map')} | ||
| closeModal={closeModal} | ||
| variant={ModalVariant.medium} | ||
| isDisabled={!isValid || !isDirty} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please handle cases in which you can't edit the plan mappings and it should be disabled. E.g. plan is completed, archived, running while at least one vm was finished the migration successfully..)
Maybe even better to handle that in SectionHeadingWithEdit and not here.
0689873 to
5378a2a
Compare
| }); | ||
|
|
||
| useEffect(() => { | ||
| setTimeout(async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when trying the pattern of const func = async () => { await trigger(); }; func() I'm getting the following eslint error:
Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator @typescript-eslint/no-floating-promises
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
u sure u need the await?
src/components/mappings/network-mappings/SourceNetworkField.tsx
Outdated
Show resolved
Hide resolved
5378a2a to
782530f
Compare
|
/retest |
782530f to
e1b91bc
Compare
|
/retest |
src/components/mappings/network-mappings/SourceNetworkField.tsx
Outdated
Show resolved
Hide resolved
src/components/mappings/network-mappings/SourceNetworkField.tsx
Outdated
Show resolved
Hide resolved
src/components/mappings/network-mappings/SourceNetworkField.tsx
Outdated
Show resolved
Hide resolved
src/components/mappings/network-mappings/TargetNetworkField.tsx
Outdated
Show resolved
Hide resolved
...details/tabs/Mappings/components/PlanNetworkMapEdit/components/PlanNetworkMapFieldsTable.tsx
Outdated
Show resolved
Hide resolved
| useEffect(() => { | ||
| setTimeout(async () => { | ||
| await trigger(); | ||
| }, 0); | ||
| }, [trigger]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? we dont any other way then this effect and timeout? IIRC check other hooks such as useLAyouteffect or others
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well we do have something like:
useEffect(() => {
const triggerFunc = async () => {
try {
await trigger();
} catch {
// handle error if needed
}
};
(async () => {
await triggerFunc();
})();
}, [trigger]);
src/plans/details/tabs/Mappings/components/PlanNetworkMapEdit/PlanNetworkMapEdit.tsx
Show resolved
Hide resolved
src/plans/details/tabs/Mappings/components/PlanStorageMapEdit/PlanStorageMapEdit.tsx
Show resolved
Hide resolved
| const [networkMap] = networkMapResult ?? []; | ||
| const [sourceNetworks] = sourceNetworksResult ?? []; | ||
| const [targetNetworks] = targetNetworksResult ?? []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems redundent, do it directly getNetworkMappingValues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the getNetworkMappingValues is also used elsewhere so that would cause more changes
src/plans/details/tabs/Mappings/hooks/usePlanStorageMapResources.ts
Outdated
Show resolved
Hide resolved
6cd748c to
2f1f880
Compare
| }, | ||
| tooltip: (index) => { | ||
| if (storageMappingFields.length <= 1) { | ||
| return t('At least one network mapping must be provided.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message should read "storage" mapping instead of "network".
...details/tabs/Mappings/components/PlanNetworkMapEdit/components/PlanNetworkMapFieldsTable.tsx
Show resolved
Hide resolved
...details/tabs/Mappings/components/PlanStorageMapEdit/components/PlanStorageMapFieldsTable.tsx
Show resolved
Hide resolved
Signed-off-by: Aviv Turgeman <[email protected]>
2f1f880 to
9b6a144
Compare
|





📝 Links
https://issues.redhat.com/browse/MTV-3743
📝 Description
Standardize the mappings tab under plan details page
🎥 Demo
plan-mappings-section.mp4
plan-mappings-section2.mp4
plan-mappings-section3.mp4
📝 CC://