Skip to content
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

Conversation

atiratree
Copy link
Member

@atiratree atiratree commented Sep 10, 2019

  • add edit nic functionality
  • refactor nic patches (create PatchBuilder utility)

depends on:

@openshift-ci-robot openshift-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 10, 2019
@openshift-ci-robot openshift-ci-robot added component/kubevirt Related to kubevirt-plugin component/shared Related to console-shared labels Sep 10, 2019
@atiratree
Copy link
Member Author

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 10, 2019
@atiratree atiratree force-pushed the kubevirt.createVMWizard.nicWizard branch from f578fb2 to 3aeb453 Compare September 10, 2019 21:25
@atiratree atiratree changed the base branch from master to master-4.3 September 18, 2019 12:55
@atiratree atiratree force-pushed the kubevirt.createVMWizard.nicWizard branch 5 times, most recently from bcd3d70 to 17ec684 Compare September 23, 2019 10:28
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 23, 2019
@atiratree atiratree force-pushed the kubevirt.createVMWizard.nicWizard branch from 17ec684 to 72b30a6 Compare September 23, 2019 11:32
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 23, 2019
@atiratree atiratree force-pushed the kubevirt.createVMWizard.nicWizard branch from 72b30a6 to 3d1f6b6 Compare September 24, 2019 13:45
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 24, 2019
@atiratree atiratree changed the base branch from master-4.3 to master September 26, 2019 09:31
@atiratree atiratree force-pushed the kubevirt.createVMWizard.nicWizard branch 6 times, most recently from d0d1f3c to 94b5db7 Compare September 30, 2019 14:39
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;
Copy link
Contributor

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;

Copy link
Member Author

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?

Copy link
Contributor

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.

Copy link
Member Author

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);
Copy link
Contributor

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)

Copy link
Contributor

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

Copy link
Member Author

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);
Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Contributor

@mareklibra mareklibra Oct 8, 2019

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.

<LoadingInline />
</div>
<Title headingLevel="h5" size="lg">
{makeSentence(`${getVMLikeModelName(isCreateTemplate)} is being created.`)}
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

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

@atiratree atiratree force-pushed the kubevirt.createVMWizard.nicWizard branch 2 times, most recently from 3eb420f to 1b3b828 Compare October 3, 2019 13:10
@atiratree atiratree force-pushed the kubevirt.createVMWizard.nicWizard branch from 1b3b828 to 9cfc598 Compare October 4, 2019 13:11
@atiratree
Copy link
Member Author

/retest

@atiratree atiratree force-pushed the kubevirt.createVMWizard.nicWizard branch from 9cfc598 to c9fabc5 Compare October 7, 2019 08:17
@atiratree
Copy link
Member Author

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 7, 2019
@atiratree atiratree force-pushed the kubevirt.createVMWizard.nicWizard branch from c9fabc5 to 8e2e8fd Compare October 7, 2019 11:46
@atiratree
Copy link
Member Author

screenshot

nic

@atiratree
Copy link
Member Author

/retest


export const useShowErrorToggler = (
initialShowError: boolean = false,
initialIsValid: boolean = false,
Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Contributor

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.

Copy link
Member Author

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);
Copy link
Contributor

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;
Copy link
Contributor

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?

Copy link
Member Author

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)
@atiratree atiratree force-pushed the kubevirt.createVMWizard.nicWizard branch from 8e2e8fd to a8928d2 Compare October 8, 2019 10:28
Copy link
Contributor

@mareklibra mareklibra left a 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)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
onChange={(v) => setName(v)}
onChange={setName}

Copy link
Member Author

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,
Copy link
Contributor

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.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 8, 2019
@openshift-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 96830d4 into openshift:master Oct 8, 2019
@spadgett spadgett added this to the v4.3 milestone Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/kubevirt Related to kubevirt-plugin component/shared Related to console-shared lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants