diff --git a/XenAdmin/Commands/DestroyHostCommand.cs b/XenAdmin/Commands/DestroyHostCommand.cs index 1ba408aba..474f51090 100644 --- a/XenAdmin/Commands/DestroyHostCommand.cs +++ b/XenAdmin/Commands/DestroyHostCommand.cs @@ -32,7 +32,6 @@ using System.Collections.Generic; using XenAdmin.Actions; using XenAdmin.Core; using XenAPI; -using System.Linq; namespace XenAdmin.Commands { @@ -57,6 +56,7 @@ namespace XenAdmin.Commands protected override void RunCore(SelectedItemCollection selection) { List actions = new List(); + foreach (Host host in selection.AsXenObjects()) { Pool pool = Helpers.GetPool(host.Connection); @@ -79,10 +79,13 @@ namespace XenAdmin.Commands protected override bool CanRunCore(SelectedItemCollection selection) { - if (!selection.AllItemsAre() || selection.Count > 1) - return false; - - return CanRun(selection.AsXenObjects().FirstOrDefault()); + foreach (var selectedItem in selection) + { + if (!(selectedItem.XenObject is Host host) || !CanRun(host)) + return false; + } + + return true; } public override string ContextMenuText => Messages.DESTROY_HOST_CONTEXT_MENU_ITEM_TEXT; @@ -94,17 +97,35 @@ namespace XenAdmin.Commands get { SelectedItemCollection selection = GetSelection(); - if (selection.Count > 0) + + if (selection.Count == 1) { Host host = (Host)selection[0].XenObject; - return string.Format(Messages.CONFIRM_DESTROY_HOST, host.Name()); } + + if (selection.Count > 1) + return Messages.CONFIRM_DESTROY_HOST_MANY; + return null; } } - protected override string ConfirmationDialogTitle => Messages.CONFIRM_DESTROY_HOST_TITLE; + protected override string ConfirmationDialogTitle + { + get + { + SelectedItemCollection selection = GetSelection(); + + if (selection.Count == 1) + return Messages.CONFIRM_DESTROY_HOST_TITLE; + + if (selection.Count > 1) + return Messages.CONFIRM_DESTROY_HOST_TITLE_MANY; + + return null; + } + } protected override string ConfirmationDialogYesButtonLabel => Messages.CONFIRM_DESTROY_HOST_YES_BUTTON_LABEL; diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 40292c88f..1e764f780 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -8438,7 +8438,7 @@ namespace XenAdmin { /// Looks up a localized string similar to Are you sure you want to destroy '{0}'? /// ///You should only need to destroy a server if it has physically failed. - ///Destroying this server will permanently remove it from the pool along with its local SRs, DVD drives and removable storage. The server will need to be reinstalled before it can be used again. + ///Destroying a server will permanently remove it from the pool along with its local SRs, DVD drives and removable storage. The server will need to be reinstalled before it can be used again. /// ///This action is final and unrecoverable.. /// @@ -8448,6 +8448,20 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to Are you sure you want to destroy the selected servers? + /// + ///You should only need to destroy servers if they have physically failed. + ///Destroying servers will permanently remove them from the pool along with their local SRs, DVD drives and removable storage. The servers will need to be reinstalled before they can be used again. + /// + ///This action is final and unrecoverable.. + /// + public static string CONFIRM_DESTROY_HOST_MANY { + get { + return ResourceManager.GetString("CONFIRM_DESTROY_HOST_MANY", resourceCulture); + } + } + /// /// Looks up a localized string similar to Destroy Server. /// @@ -8457,6 +8471,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to Destroy Multiple Servers. + /// + public static string CONFIRM_DESTROY_HOST_TITLE_MANY { + get { + return ResourceManager.GetString("CONFIRM_DESTROY_HOST_TITLE_MANY", resourceCulture); + } + } + /// /// Looks up a localized string similar to &Yes, Destroy. /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index 0d8211f6f..ff69bc1c8 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -3053,13 +3053,24 @@ This will also delete its VMs. Are you sure you want to destroy '{0}'? You should only need to destroy a server if it has physically failed. -Destroying this server will permanently remove it from the pool along with its local SRs, DVD drives and removable storage. The server will need to be reinstalled before it can be used again. +Destroying a server will permanently remove it from the pool along with its local SRs, DVD drives and removable storage. The server will need to be reinstalled before it can be used again. + +This action is final and unrecoverable. + + + Are you sure you want to destroy the selected servers? + +You should only need to destroy servers if they have physically failed. +Destroying servers will permanently remove them from the pool along with their local SRs, DVD drives and removable storage. The servers will need to be reinstalled before they can be used again. This action is final and unrecoverable. Destroy Server + + Destroy Multiple Servers + &Yes, Destroy