-
Notifications
You must be signed in to change notification settings - Fork 22
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
MTV-1726: Edit VMs list in migration plan #1414
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,149 @@ | |||
import React, { useState } from 'react'; |
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 is basically a copy of packages/forklift-console-plugin/src/components/page/StandardPageWithSelection.tsx but without selection, only expansion
This variation is needed for Edit VMs case since there should be no checkboxes, just expandable rows.
@@ -0,0 +1 @@ | |||
export type PlanEditAction = 'PLAN' | 'VMS'; |
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.
it will allow us next (with small changes like this) to edit plans too
loadError: unknown; | ||
loaded?: boolean; | ||
loadError?: unknown; | ||
planMappingsState: PlanMappingsSectionState; |
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 lifted the state up so that we can reuse planmappings from Edit VMs case
|
||
import '../create/PlanCreatePage.style.css'; | ||
|
||
export const PlanEditPage: React.FC<{ |
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.
initially copied from PlanCreatePage, but there were enough changes to make it its own component
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #1414 +/- ##
==========================================
- Coverage 36.81% 36.20% -0.62%
==========================================
Files 158 159 +1
Lines 2548 2580 +32
Branches 599 616 +17
==========================================
- Hits 938 934 -4
- Misses 1428 1451 +23
- Partials 182 195 +13 ☔ View full report in Codecov by Sentry. |
[MTV-1686] Simplify/update migration plan status cell Signed-off-by: Joachim Schuler <[email protected]>
999f277
to
003bc27
Compare
Signed-off-by: Joachim Schuler <[email protected]>
Signed-off-by: Joachim Schuler <[email protected]>
Signed-off-by: Joachim Schuler <[email protected]>
Signed-off-by: Joachim Schuler <[email protected]>
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.
Hey @jschuler
I went over the PR, following our best practices, and I didn't comment on everything as I trust that you will understand from the comments that I did add and adjust in all the places that it fit. If something isn't clear, just let me know over Slack
}, [state.flow.editingDone]); | ||
}; | ||
|
||
async function updateMappings( |
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 redundant? Only moving args?
import { setAPiError } from './reducer/actions'; | ||
import { CreateVmMigrationPageState } from './types'; | ||
|
||
const updatePlan = async (plan: V1beta1Plan) => { |
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 export to a util file, and improve to a meaningful naming, ex. updatePlanSpecVMS
return; | ||
} | ||
|
||
Promise.all([ |
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.
can we convert to try catch with await ?
}); | ||
}; | ||
|
||
export const useUpdateEffect = ( |
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 are we updaing state in this hook? do we really need this hook? its not returning anything
namespace, | ||
}, | ||
spec: { | ||
...planTemplate?.spec, | ||
...plan?.spec, | ||
provider: { | ||
source: getObjectRef(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.
no need for ...plan?.spec?.provider here?
const migratedVmIds = plan?.status?.migration?.vms?.reduce((migrated, vm) => { | ||
if (getVMMigrationStatus(vm) === 'Succeeded') { | ||
migrated.push(vm.id); | ||
} | ||
return migrated; | ||
}, []); | ||
const migratedVms = vmData.filter((vm) => migratedVmIds?.includes(vm.vm.id)); | ||
const networkIdsUsedByMigratedVms = | ||
sourceProvider?.spec?.type !== 'ovirt' ? getNetworksUsedBySelectedVms(migratedVms, []) : []; | ||
const storageIdsUsedByMigratedVms = ['ovirt', 'openstack'].includes(sourceProvider?.spec?.type) | ||
? [] | ||
: getStoragesUsedBySelectedVms({}, migratedVms, []); |
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.
useMemo to prevent rendering and exporting to a util file
) : ( | ||
<Button | ||
onClick={onClick} | ||
variant="plain" |
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 can use ButtonVariant from PF
* // ...other props | ||
* /> | ||
*/ | ||
export function StandardPageWithExpansion<T>(props: StandardPageWithExpansionProps<T>) { |
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 consist with arrow functions
const { toId, onExpand, expandedIds, ...rest } = props; | ||
|
||
if (onExpand && (!toId || !expandedIds)) { | ||
throw new Error('Missing required properties: toId, expandedIds'); |
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.
do we have other places in code where UI is thowring?
* Contract: | ||
* 1. IDs provided with toId() function are unique and constant in time | ||
*/ | ||
export function withIdBasedExpansion<T>({ |
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.
arrow function and please avoid nested components
Signed-off-by: Joachim Schuler <[email protected]>
Quality Gate passedIssues Measures |
https://issues.redhat.com/browse/MTV-1726
Design story:
https://issues.redhat.com/browse/HPUX-166
Provide users the possibility to add more VMs (not just delete) to an existing plan.
See this table below for when it is possible to do so.
Basically, whenever you can update plan mappings, you can also update plan VMs.
For the mappings section, I reused the plan details mappings tab section, since it can patch existing mappings
See video of before (green border)/after:
Screen.Recording.2024-12-13.at.12.04.40.PM.mov