mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 20:36:33 +01:00
CP-21500: Updates wizard: Show new versions that are available as updates
In the Updates wizard: New versions that are available as updates will be listed in the "Download Updates from Citrix" section, before any other updates. If XenCenter is not the latest version, these rows will be greyed out, with a tooltip. Signed-off-by: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>
This commit is contained in:
parent
e73b989c72
commit
1317e5a4e3
37
XenAdmin/Alerts/NewVersionPriorityAlertComparer.cs
Normal file
37
XenAdmin/Alerts/NewVersionPriorityAlertComparer.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace XenAdmin.Alerts
|
||||
{
|
||||
public class NewVersionPriorityAlertComparer : IComparer<Alert>
|
||||
{
|
||||
public int Compare(Alert alert1, Alert alert2)
|
||||
{
|
||||
if (alert1 == null || alert2 == null)
|
||||
return 0;
|
||||
|
||||
int sortResult = 0;
|
||||
|
||||
if (IsVersionOrVersionUpdateAlert(alert1) && !IsVersionOrVersionUpdateAlert(alert2))
|
||||
sortResult = 1;
|
||||
|
||||
if (!IsVersionOrVersionUpdateAlert(alert1) && IsVersionOrVersionUpdateAlert(alert2))
|
||||
sortResult = -1;
|
||||
|
||||
if (sortResult == 0)
|
||||
sortResult = Alert.CompareOnDate(alert1, alert2);
|
||||
|
||||
return -sortResult;
|
||||
}
|
||||
|
||||
private bool IsVersionOrVersionUpdateAlert(Alert alert)
|
||||
{
|
||||
return alert is XenServerPatchAlert && (alert as XenServerPatchAlert).NewServerVersion != null
|
||||
|| alert is XenServerVersionAlert
|
||||
|| alert is XenCenterUpdateAlert;
|
||||
}
|
||||
}
|
||||
}
|
@ -1009,33 +1009,6 @@ namespace XenAdmin.TabPages
|
||||
labelProgress.MaximumSize = new Size(tableLayoutPanel3.Width - 60, tableLayoutPanel3.Size.Height);
|
||||
}
|
||||
|
||||
public class NewVersionPriorityAlertComparer : IComparer<Alert>
|
||||
{
|
||||
public int Compare(Alert alert1, Alert alert2)
|
||||
{
|
||||
if (alert1 == null || alert2 == null)
|
||||
return 0;
|
||||
|
||||
int sortResult = 0;
|
||||
|
||||
if (IsVersionOrVersionUpdateAlert(alert1) && !IsVersionOrVersionUpdateAlert(alert2))
|
||||
sortResult = 1;
|
||||
|
||||
if (!IsVersionOrVersionUpdateAlert(alert1) && IsVersionOrVersionUpdateAlert(alert2))
|
||||
sortResult = -1;
|
||||
|
||||
if (sortResult == 0)
|
||||
sortResult = Alert.CompareOnDate(alert1, alert2);
|
||||
|
||||
return -sortResult;
|
||||
}
|
||||
|
||||
private bool IsVersionOrVersionUpdateAlert(Alert alert)
|
||||
{
|
||||
return alert is XenServerPatchAlert && (alert as XenServerPatchAlert).NewServerVersion != null
|
||||
|| alert is XenServerVersionAlert
|
||||
|| alert is XenCenterUpdateAlert;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,8 +62,6 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
|
||||
labelWithAutomatedUpdates.Visible = automatedUpdatesOptionLabel.Visible = AutomatedUpdatesRadioButton.Visible = false;
|
||||
downloadUpdateRadioButton.Checked = true;
|
||||
|
||||
dataGridViewPatches.Sort(ColumnDate, ListSortDirection.Descending);
|
||||
}
|
||||
|
||||
private void CheckForUpdates_CheckForUpdatesStarted()
|
||||
@ -255,7 +253,15 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
private void PopulatePatchesBox()
|
||||
{
|
||||
dataGridViewPatches.Rows.Clear();
|
||||
var updates = new List<Alert>(Updates.UpdateAlerts);
|
||||
|
||||
var alerts = Updates.UpdateAlerts.ToList();
|
||||
if (dataGridViewPatches.SortedColumn == null)
|
||||
{
|
||||
alerts.Sort(new NewVersionPriorityAlertComparer());
|
||||
}
|
||||
|
||||
var updates = new List<Alert>(alerts);
|
||||
|
||||
if (dataGridViewPatches.SortedColumn != null)
|
||||
{
|
||||
if (dataGridViewPatches.SortedColumn.Index == ColumnUpdate.Index)
|
||||
@ -268,16 +274,25 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
if (dataGridViewPatches.SortOrder == SortOrder.Descending)
|
||||
updates.Reverse();
|
||||
}
|
||||
foreach (Alert alert in updates)
|
||||
{
|
||||
if (alert is XenServerPatchAlert)
|
||||
{
|
||||
PatchGridViewRow row = new PatchGridViewRow(alert);
|
||||
if (!dataGridViewPatches.Rows.Contains(row))
|
||||
{
|
||||
dataGridViewPatches.Rows.Add(row);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Alert alert in updates)
|
||||
{
|
||||
var patchAlert = alert as XenServerPatchAlert;
|
||||
|
||||
if (patchAlert != null)
|
||||
{
|
||||
PatchGridViewRow row = new PatchGridViewRow(patchAlert);
|
||||
if (!dataGridViewPatches.Rows.Contains(row))
|
||||
{
|
||||
dataGridViewPatches.Rows.Add(row);
|
||||
|
||||
if (patchAlert.RequiredXenCenterVersion != null)
|
||||
{
|
||||
row.Enabled = false;
|
||||
row.SetToolTip(string.Format(Messages.UPDATES_WIZARD_NEWER_XENCENTER_REQUIRED, patchAlert.RequiredXenCenterVersion.Version));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -592,6 +607,19 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
return this.Equals((PatchGridViewRow)obj);
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetToolTip(string toolTip)
|
||||
{
|
||||
foreach (var c in Cells)
|
||||
{
|
||||
if (c is DataGridViewLinkCell)
|
||||
continue;
|
||||
|
||||
var cell = c as DataGridViewCell;
|
||||
if (c != null)
|
||||
((DataGridViewCell)c).ToolTipText = toolTip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -103,6 +103,7 @@
|
||||
<Compile Include="Actions\GUIActions\IgnorePatchAction.cs" />
|
||||
<Compile Include="Actions\GUIActions\SaveDataSourceStateAction.cs" />
|
||||
<Compile Include="Actions\GUIActions\SearchAction.cs" />
|
||||
<Compile Include="Alerts\NewVersionPriorityAlertComparer.cs" />
|
||||
<Compile Include="Alerts\Types\AlarmMessageAlert.cs" />
|
||||
<Compile Include="Alerts\Types\XenServerUpdateAlert.cs" />
|
||||
<Compile Include="Alerts\Types\DuplicateIqnAlert.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user