-
Notifications
You must be signed in to change notification settings - Fork 670
Show only the allowed storage interfaces on Disk-modal #4028
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
Show only the allowed storage interfaces on Disk-modal #4028
Conversation
bbbd1fc to
87311ec
Compare
87311ec to
e25f8a0
Compare
|
/retest |
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.
- doesn't work with justWarning validations
- doesn't work well with CDs - no errors + no possibility to edit
- there should be a different default picked for new disks if VirtIO is not present in allowedBuses
- no validation for already created VMs (just a reminder for a followup)
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 have something akin to iGetRelevantTemplate - getTemplateValidations and getTemplateValidation ?
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.
and call console.warn when there are multiple of them - as that should not happen?
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.
we could call this after the first if
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 need for the spread here
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.
we could use getTemplateValidation here as well
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.
still probably better check this is not null
frontend/packages/kubevirt-plugin/src/utils/validations/template/template-validations.ts
Outdated
Show resolved
Hide resolved
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.
what happens when allowedBusses become null here?
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.
also you could use joinGrammaticallyListOfItems
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 dont we use this? and also pass validation to FormRow?
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 suppose the Invalid is good as well, but can we also add isDisabled ?
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.
probably the validation + isDisabled should be enough
f5d75d8 to
02b6ecc
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.
the default is all right? Let's rather do this
| const allowedBusses = templateValidation ? templateValidation.getAllowedBusses() : null; | |
| const allowedBusses = (templateValidation || new TemplateValidations()).getAllowedBusses(); |
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.
let's move these to ../template.ts ? as these do not return immutable objects
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.
we can do the same trick here as well
(templateValidations || new TemplateValidations()).getAllowedBusses()
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.
probably not here though as this is just the modal
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.
lets remove this line and let DiskModal take care of it 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.
First, this is just for now, there will be a followup. Second, this is DiskModal prop, it has to get the default value.
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.
fair enough, let's do it in a followup. Anyway the DiskModal could contain the default value by itself
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.
easier to read
| : Array.from(allowedBusses)[0]), | |
| : [...allowedBusses][0]), |
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 the same thing here and just map the thing without any conditions?
| {DiskBus.getAll().map((b) => | |
| {(allowedBusses || new Set(DiskBus.getAll())).map((b) => |
we probably should check if allowedBusses are null in the begiining and assing new Set(DiskBus.getAll()) so we can use it everywhere without a fear
frontend/packages/kubevirt-plugin/src/utils/validations/template/interval-validation-result.ts
Outdated
Show resolved
Hide resolved
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.
https://github.com/openshift/console/pull/4028/files#r369505305, so you don't have to do it here before the return
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.
and you can do
| if (allowedBusses.size === 0) { | |
| return new Set(allowedBusses.size === 0 ? DiskBus.getAll() : allowedBusses) |
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 disk condition should still be here or we could get stuck in cdroms
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.
what are you suggesting?:
- remove the line
- keep the line and add a comment above for a followup
- comment the line and add a comment about a followup
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 call toString here
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 pass validation to FormRow as it is not visible
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.
IMO in that case we can remove Invalid here as it would be shown twice
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.
sorry it does not work with isDisabled - lets remove it
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.
02b6ecc to
7c6ab42
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.
I meant, lets revert it to the same state it was before. Thumbs up for the TODO.
| // TODO: implement CDROM disk bus validation | |
| // TODO: implement CDROM disk bus validation | |
| if (disk.getType() === DiskType.DISK) { | |
| addRequired(allowedBusses.has(disk.getDiskBus())); | |
| validations.diskInterface = validateBus(disk.getDiskBus(), allowedBusses); | |
| } |
7c6ab42 to
11960d5
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.
really no need for this check - it will always return true
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.
Ok, I suppose the user should know it is not selectable
We could try to make the disabled work in the future
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.
ow sorry it should just read:
| addRequired(allowedBusses.has(disk.getDiskBus())); | |
| addRequired(disk.getDiskBus()); |
this just checks the value is not null
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 this above the method as this talks about the whole thing
11960d5 to
874fcbe
Compare
|
works great! /lgtm now let's proceed with the folowups :)
|
Fixes: CNV-2914 Enforce the validations from common and user templates so the user can choose only from the allowed values in the Disk-modal at the storage tab. Depends on: openshift#3909 Signed-off-by: Ido Rosenzwig <irosenzw@redhat.com>
874fcbe to
aaa0c77
Compare
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: irosenzw, suomiy The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/test analyze |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
| const templateValidations = getTemplateValidations(state, id); | ||
| if (templateValidations && templateValidations.length > 0) { | ||
| templateValidations.length > 1 && | ||
| console.warn('WARNING: getTemplateValidation: multiple template validations detected!'); |
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.
@suomiy @irosenzw
If this is an error that should be handled, ensure there is something in place, otherwise, if its something that is sufficiently handled with the console statement, then please add:
// eslint-disable-next-line no-console
console.warn('....');Otherwise the errors appear every time we build the app.
@jcaianirh
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 in #3949



Fixes: CNV-2914
Enforce the validations from common and user templates
so the user can choose only from the allowed values in the Disk-modal
at the storage tab.
Depends on: #3909
Signed-off-by: Ido Rosenzwig irosenzw@redhat.com