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
kubevirt: refactor createNicRow to NICModal #2670
kubevirt: refactor createNicRow to NICModal #2670
Conversation
/hold |
f578fb2
to
3aeb453
Compare
bcd3d70
to
17ec684
Compare
17ec684
to
72b30a6
Compare
72b30a6
to
3d1f6b6
Compare
d0d1f3c
to
94b5db7
Compare
export const getVolumes = (vm: VMKind) => _.get(vm, 'spec.template.spec.volumes') || []; | ||
export const getDataVolumeTemplates = (vm: VMKind) => _.get(vm, 'spec.dataVolumeTemplates') || []; | ||
export const getDisks = (vm: VMKind, defaultValue = []) => | ||
_.get(vm, 'spec.template.spec.domain.devices.disks') || defaultValue; |
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.
Based on recent discussions, we moved from _.get()
to direct access like
return vm && vm.spec ? vm.spec.template : undefined;
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 do it consistently in one big PR instead?
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 change is simple and quick, much faster than long discussions and PR ping-pongs.
New PRs respect this "new" approach and we should not add new selectors which are not conforming it.
As an independent task, I would batch-change the older code.
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.
changed to new approach
export const getBootDeviceIndex = (devices, bootOrder) => | ||
devices.findIndex((device) => device.bootOrder === bootOrder); | ||
|
||
export const getDeviceBootOrder = (device, defaultValue?): number => | ||
_.get(device, 'bootOrder', defaultValue); |
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.
direct access (see another 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.
I still think we should not add more lodash-style selectors
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.
done
const devicesWithoutRemovedDevice = | ||
removedDeviceName == null | ||
? devices | ||
: devices.filter((device) => getSimpleName(device) !== removedDeviceName); |
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 think simple use of device.name !== removedDeviceName
would be more readable
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 would leave it for consistency because the same function is used on the device few lines bellow in setListRemove
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 agree with the opinion that the amount of indirections for simple things should be reduced. I do not see added value in these simple wrappers.
But let's not block this PR on that.
frontend/packages/kubevirt-plugin/src/k8s/patches/vm-template/index.ts
Outdated
Show resolved
Hide resolved
frontend/packages/kubevirt-plugin/src/components/modals/nic-modal/nic-modal-enhanced.tsx
Outdated
Show resolved
Hide resolved
frontend/packages/kubevirt-plugin/src/components/modals/modal/modal-footer.tsx
Outdated
Show resolved
Hide resolved
...packages/kubevirt-plugin/src/components/create-vm-wizard/tabs/result-tab/result-tab-row.scss
Outdated
Show resolved
Hide resolved
frontend/packages/kubevirt-plugin/src/components/create-vm-wizard/create-vm-wizard-footer.tsx
Outdated
Show resolved
Hide resolved
...d/packages/kubevirt-plugin/src/components/create-vm-wizard/tabs/result-tab/error-results.tsx
Outdated
Show resolved
Hide resolved
<LoadingInline /> | ||
</div> | ||
<Title headingLevel="h5" size="lg"> | ||
{makeSentence(`${getVMLikeModelName(isCreateTemplate)} is being created.`)} |
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 need for makeSentence()
can be workarounded by i.e. by staring the sentence with The
.
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 is no The
in the design (http://openshift.github.io/openshift-origin-design/web-console/knikubevirt/Create-vm/step-6-results/wizard-results) so I will leave it in the current state for now.
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.
resolved to a different solution
3eb420f
to
1b3b828
Compare
1b3b828
to
9cfc598
Compare
/retest |
9cfc598
to
c9fabc5
Compare
/hold cancel |
c9fabc5
to
8e2e8fd
Compare
/retest |
|
||
export const useShowErrorToggler = ( | ||
initialShowError: boolean = false, | ||
initialIsValid: boolean = false, |
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.
nit: if a default is set, the param should be optional
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.
default value makes it not optional and initialIsValid?
cannot be used
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 default value is applied if the parameter is omitted when calling, so it is optional.
If a parameter is not optional, then its value must be provided (either true or false in that case).
But it's not a blocker, imo.
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 get that it is actually optional for the caller but not according to typescript (which is probably concerned about the user of the parameter - the function?)
export const getBootDeviceIndex = (devices, bootOrder) => | ||
devices.findIndex((device) => device.bootOrder === bootOrder); | ||
|
||
export const getDeviceBootOrder = (device, defaultValue?): number => | ||
_.get(device, 'bootOrder', defaultValue); |
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 still think we should not add more lodash-style selectors
}; | ||
|
||
export type V1Network = { | ||
name?: string; |
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.
Just a question: Shouldn't there be at least one field which is not optional?
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 can be optional when it is initialized internally
- add edit nic functionality - refactor nic patches (create PatchBuilder utility)
8e2e8fd
to
a8928d2
Compare
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.
Just minor comments which do not block this from merging.
/lgtm
isRequired | ||
id={asId('name')} | ||
value={name} | ||
onChange={(v) => setName(v)} |
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.
nit:
onChange={(v) => setName(v)} | |
onChange={setName} |
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 does not work because the second argument is event and React.useState callback complains about that
|
||
export const useShowErrorToggler = ( | ||
initialShowError: boolean = false, | ||
initialIsValid: boolean = false, |
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 default value is applied if the parameter is omitted when calling, so it is optional.
If a parameter is not optional, then its value must be provided (either true or false in that case).
But it's not a blocker, imo.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mareklibra, suomiy The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
depends on: