CA-161524: Resource report menu item is only shown when you're on the pool node

- changes following code review: menu item available if multiple items selected inside the same pool

Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
Mihaela Stoica 2015-05-20 10:17:00 +01:00
parent f2b9882238
commit 16a1d19b0b

View File

@ -63,29 +63,17 @@ namespace XenAdmin.Commands
protected override void ExecuteCore(SelectedItemCollection selection)
{
if (selection.Count == 1)
if (selection.FirstAsXenObject != null)
{
if (CanExecute(selection[0]))
{
Execute(selection[0].Connection);
}
Execute(selection.FirstAsXenObject.Connection);
}
}
protected override bool CanExecuteCore(SelectedItemCollection selection)
{
if (selection.Count == 1)
{
return CanExecute(selection[0]);
}
return false;
}
private static bool CanExecute(SelectedItem selection)
{
if (selection.Connection != null && selection.Connection.IsConnected &&
(selection.PoolAncestor != null || selection.HostAncestor != null))
return !Helpers.FeatureForbidden(selection.Connection, Host.RestrictExportResourceData);
if (selection.FirstAsXenObject != null && selection.FirstAsXenObject.Connection != null && selection.FirstAsXenObject.Connection.IsConnected &&
(selection.PoolAncestor != null || selection.HostAncestor != null)) // this check ensures there's no cross-pool
return !Helpers.FeatureForbidden(selection.FirstAsXenObject.Connection, Host.RestrictExportResourceData);
return false;
}