-
Notifications
You must be signed in to change notification settings - Fork 605
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: Edit VM flavor #2392
kubevirt: Edit VM flavor #2392
Conversation
@@ -13,6 +13,7 @@ import { VMLikeEntityKind } from '../../../types'; | |||
import { getDescription, getVMLikeModel } from '../../../selectors/selectors'; | |||
import { getUpdateDescriptionPatches } from '../../../k8s/patches/vm/vm-patches'; | |||
|
|||
// TODO: should be moved under kubevirt-plugin/src/style.scss |
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.
Looking for opinions: will we encapsulate styles with components or will we maintain single SASS hierarchy starting with frontend/public/style.scss
(or kubevirt-plugin/src/style.scss
).
The encapsulation has clearly its benefits, but we do not develop a library here. And the rest of the code follows the later approach.
@mareklibra thanks this looks great. A few questions: can we only adjust the height of the modal if they choose custom? That white space is a bit odd if they choose any other preset flavor. |
@matthewcarleton , I tried to resize the modal for non-custom entries but the dropdown shows badly as it hides its rows behind modal box content. Recently, there can be up to 5 options to select from. |
@mareklibra this would be an overflow issue on the content area of |
Thank you, @matthewcarleton , that's the issue. As we are still on PF3, what about following fix: I think it behaves better than "jumping on the fly", where the modal box would increase height when the dropdown is opened and resize back when an option is selected. If the dropdown is opened, there is no other action than select an option or dismiss. Wdyt? |
frontend/packages/kubevirt-plugin/src/components/modals/vm-flavor-modal/_vm-flavor-modal.scss
Outdated
Show resolved
Hide resolved
@mareklibra yes I agree this is much better IMO. |
/retest |
return convertToBaseValue(memory) / MB; | ||
}; | ||
|
||
const getFlavors = (vm: VMLikeEntityKind, templates: TemplateKind[]) => { |
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 move this to selectors ? I think it has a potential to be used in other places too
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, moved
const VMFlavorModal = withHandlePromise((props: VMFlavornModalProps) => { | ||
const { vmLike, templates, inProgress, errorMessage, handlePromise, close, cancel } = props; | ||
|
||
const flattenTemplates = _.get(templates, 'data', []) as TemplateKind[]; |
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.
loading/error state should be handled
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
}; | ||
|
||
let topClass = 'modal-content '; | ||
topClass += |
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'd rather use classNames
for 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.
done
<dt> | ||
Flavor | ||
{canUpdateTemplate && ( | ||
<button |
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 create component out of this ? Something like EditButton
?
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.
sure, done
import { getVMLikePatches } from '../vm-template'; | ||
import { isCPUEqual } from '../../../utils'; | ||
|
||
const getLabelsPatch = (vmLike: VMLikeEntityKind): Patch | 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.
const getLabelsPatch = (vmLike: VMLikeEntityKind): Patch | null => { | |
const getLabelsPatch = (vmLike: VMLikeEntityKind): Patch => { |
we dont have strict null check enabled, so no need to add | null
. Applies for others too
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.
leftover, removed
getTemplatesLabelValues(vmTemplates, TEMPLATE_WORKLOAD_LABEL); | ||
|
||
export const getTemplates = ( | ||
templates: TemplateKind[], |
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'd prefer to specify default type in function declaration
templates: TemplateKind[], | |
templates: TemplateKind[] = [], |
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
workload: string, | ||
flavor: string, | ||
) => | ||
(templates || []).filter((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.
(templates || []).filter((t) => { | |
templates.filter((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.
done
import { VirtualMachineModel } from '../../models'; | ||
import { selectVM } from '../vm-template/selectors'; | ||
|
||
export const isVM = (vmLikeEntity: VMLikeEntityKind): boolean => |
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 could be a type guard
export const isVM = (vmLikeEntity: VMLikeEntityKind): boolean => | |
export const isVM = (vmLikeEntity: VMLikeEntityKind): vmLikeEntity is VMKind => |
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.
good idea, done
return null; | ||
} | ||
|
||
if (isVM(vmLikeEntity)) { |
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 the above is converted to type guard you can just
if (isVM(vmLikeEntity)) { | |
return isVM(vmLikeEntity) ? vmLikeEntity : selectVM(vmLikeEntity); |
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
); | ||
}; | ||
|
||
type CPUType = { |
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.
type CPUType = { | |
type CPURaw = { |
?
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 not ... done
@mareklibra three little nitpicks:
|
sure, done
Our (KubeVirt) templates use values like I have newly added conversion to best-possible human readable decimal byte-unit, like
done with respect to the previous point |
@mareklibra that sounds reasonable to me. Thanks! |
The PR is retargeted to |
/retest |
Switching back to |
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mareklibra, rawagner 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 |
/test e2e-aws-console-olm |
This PR appears to be the cause of https://bugzilla.redhat.com/show_bug.cgi?id=1767853 attn: @mareklibra, @rawagner |
Specifically, git bisect pointed at ef3a10c |
The VM Detail is enriched for the Edit VM Flavor feature, implemented as a modal dialog.
TODO:
Note:
Integration tests will be added by a follow-up as they will need to be stacked on other open PRs recently.