Tal Nisan has uploaded a new change for review. Change subject: webadmin: Allow actions on a VM list even if not available on all VMs ......................................................................
webadmin: Allow actions on a VM list even if not available on all VMs When selecting multiple VMs in the VM main tab, allow to run certain actions (Run, Suspend, Shutdown, Power Off, Reboot, Migrate, Cancel Migration) even if not all the selected VMs are elegible for running those actions Change-Id: Ic2f10f1992838ecef796989b83a6fa1f2e34d443 Bug-Url: https://bugzilla.redhat.com/1051388 Signed-off-by: Tal Nisan <[email protected]> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcActionUtils.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java 2 files changed, 25 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/15/38415/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcActionUtils.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcActionUtils.java index 6c469ca..08b7639 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcActionUtils.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcActionUtils.java @@ -335,4 +335,23 @@ } return true; } + + /** + * This method determines per list of entities whether the selected action can run at least on one item from the + * entities list + */ + public static boolean canExecutePartially(List<? extends BusinessEntityWithStatus<?, ?>> entities, + Class type, + VdcActionType action) { + if (_matrix.containsKey(type)) { + for (BusinessEntityWithStatus<?, ?> a : entities) { + if (a.getClass() == type && + (!_matrix.get(type).containsKey(a.getStatus()) + || !_matrix.get(type).get(a.getStatus()).contains(action))) { + return true; + } + } + } + return false; + } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java index 6ffd0dd..073d8eb 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java @@ -2266,21 +2266,21 @@ getRemoveCommand().setIsExecutionAllowed(items.size() > 0 && VdcActionUtils.canExecute(items, VM.class, VdcActionType.RemoveVm)); getRunCommand().setIsExecutionAllowed(items.size() > 0 - && VdcActionUtils.canExecute(items, VM.class, VdcActionType.RunVm)); + && VdcActionUtils.canExecutePartially(items, VM.class, VdcActionType.RunVm)); getCloneVmCommand().setIsExecutionAllowed(items.size() == 1 && VdcActionUtils.canExecute(items, VM.class, VdcActionType.CloneVm)); getPauseCommand().setIsExecutionAllowed(items.size() > 0 - && VdcActionUtils.canExecute(items, VM.class, VdcActionType.HibernateVm) + && VdcActionUtils.canExecutePartially(items, VM.class, VdcActionType.HibernateVm) && AsyncDataProvider.getInstance().canVmsBePaused(items)); getShutdownCommand().setIsExecutionAllowed(items.size() > 0 - && VdcActionUtils.canExecute(items, VM.class, VdcActionType.ShutdownVm)); + && VdcActionUtils.canExecutePartially(items, VM.class, VdcActionType.ShutdownVm)); getStopCommand().setIsExecutionAllowed(items.size() > 0 - && VdcActionUtils.canExecute(items, VM.class, VdcActionType.StopVm)); + && VdcActionUtils.canExecutePartially(items, VM.class, VdcActionType.StopVm)); getRebootCommand().setIsExecutionAllowed(AsyncDataProvider.getInstance().isRebootCommandExecutionAllowed(items)); getMigrateCommand().setIsExecutionAllowed(items.size() > 0 - && VdcActionUtils.canExecute(items, VM.class, VdcActionType.MigrateVm)); + && VdcActionUtils.canExecutePartially(items, VM.class, VdcActionType.MigrateVm)); getCancelMigrateCommand().setIsExecutionAllowed(items.size() > 0 - && VdcActionUtils.canExecute(items, VM.class, VdcActionType.CancelMigrateVm)); + && VdcActionUtils.canExecutePartially(items, VM.class, VdcActionType.CancelMigrateVm)); getNewTemplateCommand().setIsExecutionAllowed(items.size() == 1 && VdcActionUtils.canExecute(items, VM.class, VdcActionType.AddVmTemplate)); getRunOnceCommand().setIsExecutionAllowed(items.size() == 1 -- To view, visit https://gerrit.ovirt.org/38415 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic2f10f1992838ecef796989b83a6fa1f2e34d443 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tal Nisan <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
