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

Alert when stopping a vm with logged in users #5733

Merged

Conversation

yaacov
Copy link
Member

@yaacov yaacov commented Jun 15, 2020

Alert when stoping a vm with logged in users

Desing: http://openshift.github.io/openshift-origin-design/designs/virtualization/4.x/expose-guest-data/expose%20guest%20data.html#details-tab

  • separate different vm delete modals
  • add a special delete modal for vmi
  • add special modals for stop / restart
  • add users logged in warning to delete/stop/restart modals

Screenshot:
screenshot-localhost_9000-2020 06 17-15_23_30
screenshot-localhost_9000-2020 06 17-15_29_14
screenshot-localhost_9000-2020 06 17-15_29_51(1)

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. component/kubevirt Related to kubevirt-plugin labels Jun 15, 2020
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 15, 2020
@yaacov
Copy link
Member Author

yaacov commented Jun 15, 2020

@pcbailey please review

@yaacov yaacov force-pushed the alert-stop-vm-with-users branch 5 times, most recently from 30b7ab7 to 176ba44 Compare June 17, 2020 12:25
@yaacov yaacov changed the title [WIP] Alert when stoping a vm with logged in users Alert when stoping a vm with logged in users Jun 17, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 17, 2020
@yaacov yaacov changed the title Alert when stoping a vm with logged in users Alert when stopping a vm with logged in users Jun 17, 2020
Copy link
Contributor

@pcbailey pcbailey left a comment

Choose a reason for hiding this comment

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

Just a few minor comments for the moment.

};

return (
<form onSubmit={submit} className="modal-content">
<ModalTitle>
<YellowExclamationTriangleIcon className="co-icon-space-r" /> Delete{' '}
{isTemplate(vmLikeEntity) ? 'Virtual Machine Template' : entityModel.label}?
{VirtualMachineModel.label}?
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that the ternary operator is removed, I think this can be written more cleanly as a template literal.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

Are you sure you want to delete{' '}
<strong className="co-break-word">{getName(vmLikeEntity)}</strong> in namespace{' '}
<strong>{getNamespace(vmLikeEntity)}</strong> ?
Are you sure you want to delete <strong className="co-break-word">{name}</strong> in
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks much cleaner. =)

<form onSubmit={submit} className="modal-content">
<ModalTitle>
<YellowExclamationTriangleIcon className="co-icon-space-r" /> Delete Virtual Machine
Template ?
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be a space before all of the question marks here? I see several like this.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

import { VMIKind } from '../../../types';
import { VirtualMachineInstanceModel } from '../../../models';

const redirectFn = (vmi: VMIKind) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this should be made more general and shared among all the different modals.

Copy link
Member Author

Choose a reason for hiding this comment

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

moved to a utils file

@yaacov yaacov force-pushed the alert-stop-vm-with-users branch 3 times, most recently from bf65f18 to 667789b Compare June 17, 2020 13:47
deleteOwnedVolumeResources: deleteDisks,
});
}
const promise = deleteVM(vmUpToDate, {
Copy link
Member

Choose a reason for hiding this comment

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

+1 for splitting the functionality, makes it more readable

import { useUpToDateVMLikeEntity } from '../../../hooks/use-vm-like-entity';
import { deleteVMTemplate } from '../../../k8s/requests/vmtemplate/actions';

const redirectFn = (vmLikeEntity: TemplateKind) => {
Copy link
Member

Choose a reason for hiding this comment

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

naming

Copy link
Contributor

Choose a reason for hiding this comment

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

How about something like redirectAfterDeletion?

Copy link
Member Author

Choose a reason for hiding this comment

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

renamed

}
};

export const DeleteVMIModal = withHandlePromise((props: DeleteVMIProps) => {
Copy link
Member

Choose a reason for hiding this comment

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

Should we also ask for disk removal in standalone VMIs which do not belong to any VM resource?

Copy link
Member Author

Choose a reason for hiding this comment

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

added :-)


const name = getName(vmi);
const namespace = getNamespace(vmi);
const alertHref = `/k8s/ns/${namespace}/virtualmachines/${name}/details#logged-in-users`;
Copy link
Member

Choose a reason for hiding this comment

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

what about standalone VMIs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks !!! wow, no I remember why I took it out to be a separate modal !

</>
);
} else if (userListLength > 1) {
alertBody = (
Copy link
Member

Choose a reason for hiding this comment

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

this feels like it should be parametrized

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. I think this can be done in one Button component using pluralize. I don't think it will hurt anything if we use a numeral 1 instead of "One".

Copy link
Member Author

Choose a reason for hiding this comment

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

+2 :-) fixing

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@yaacov yaacov force-pushed the alert-stop-vm-with-users branch 5 times, most recently from c81de9f to b8ffdb6 Compare June 17, 2020 14:58
import { getName, getNamespace } from '@console/shared/src/selectors/common';
import { VMILikeEntityKind } from 'packages/kubevirt-plugin/src/types/vmLike';

export const redirectAfterVMDeletion = (vmi: VMILikeEntityKind) => {
Copy link
Member

Choose a reason for hiding this comment

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

can we use this one for the template as well? And parametrize the /virtualization part? I guess better name could be redirectToList

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, made it one method, much nicer now

<form onSubmit={submit} className="modal-content">
<ModalTitle>
<YellowExclamationTriangleIcon className="co-icon-space-r" /> Delete Virtual Machine
Instanse ?
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Instanse ?
Instance ?

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@yaacov
Copy link
Member Author

yaacov commented Jun 22, 2020

@suomiy @pcbailey addressed all comments, please re-review

namespace <strong>{namespace}</strong>?
{numOfAllResources > 0 && (
<p>
The following resources will be deleted along with this virtual machine instance.
Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand this correctly, this message is wrong. It looks like this is displaying the number of disks and giving a single checkbox to indicate consent to delete them or not. This message implies that there should be a list containing each of the individual resources with their own checkbox, where the user can pick which resources to delete and which to leave.

import { getName, getNamespace } from '@console/shared/src/selectors/common';
import { VMGenericLikeEntityKind } from 'packages/kubevirt-plugin/src/types/vmLike';

export const redirectToList = (vmi: VMGenericLikeEntityKind, tab?: 'templates' | '' | null) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Yay! =)

<Button variant="link" isInline onClick={onLinkClick}>
{pluralize(userListLength, 'User')}
</Button>{' '}
currently logged in to this VM. Proceeding with this operation may cause logged in users data
Copy link
Contributor

Choose a reason for hiding this comment

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

I would change the last sentence to "Proceeding with this operation may cause logged in users to lose data."

@pcbailey
Copy link
Contributor

I'm going to approve this. We can fix these two messages in a follow-up.
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 23, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pcbailey, yaacov

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-merge-robot openshift-merge-robot merged commit 2a7bbf4 into openshift:master Jun 23, 2020
@spadgett spadgett added this to the v4.6 milestone Jun 24, 2020
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 lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants