Skip to content

Commit

Permalink
IH-414: Resolve PR review comments from Tina
Browse files Browse the repository at this point in the history
  • Loading branch information
BengangY committed Nov 22, 2023
1 parent c1b2f03 commit 84e514f
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 104 deletions.
119 changes: 85 additions & 34 deletions XenAdmin/Wizards/ConversionWizard/VmSelectionPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using System.Linq;
using System.Windows.Forms;
using XenAdmin.Controls;
using XenAdmin.Core;
using XenAdmin.XCM;


Expand All @@ -44,13 +45,13 @@ public partial class VmSelectionPage : XenTabPage

private bool _buttonNextEnabled;
private bool _updating;
private string _currentConversionVersion;
private string _currentXSVersion;
private bool _supportVersionChecking;


public VmSelectionPage()
{
InitializeComponent();
tableLayoutPanelError.Visible = false;
}

#region XenTabPage implementation
Expand All @@ -68,7 +69,21 @@ public override bool EnableNext()

protected override void PageLoadedCore(PageLoadedDirection direction)
{
_currentConversionVersion = ConversionClient.GetVpxVersion();
tableLayoutPanelError.Visible = false;
_supportVersionChecking = IsSupportGuestVersionChecking();
if (_supportVersionChecking)
{
tableLayoutPanelVersion.Visible = true;
columnRemarks.Visible = true;
showOnlySupportedGuestCheckBox.Checked = true;
}
else
{
tableLayoutPanelVersion.Visible = false;
columnRemarks.Visible = false;
showOnlySupportedGuestCheckBox.Checked = false;
}
_currentXSVersion = Helpers.HostProductVersion(Helpers.GetCoordinator(Connection));
if (direction == PageLoadedDirection.Forward)
Build();
}
Expand All @@ -89,7 +104,7 @@ public VmInstance[] SelectedVms
get
{
return (from SourceVmRow row in dataGridViewVms.Rows
where row.IsChecked
where row.IsChecked && row.Visible
select row.Vm).ToArray();
}
}
Expand All @@ -100,7 +115,7 @@ private bool SelectedVmsExist
{
foreach (SourceVmRow row in dataGridViewVms.Rows)
{
if (row.IsChecked)
if (row.Visible && row.IsChecked)
return true;
}

Expand All @@ -109,24 +124,17 @@ private bool SelectedVmsExist
}

// The feature of unsupported guest version warning is available on 8.3.1
private Version LowestGuestCheckingConversionVersion => new Version("8.3.1");
private bool IsSupportGuestVersionChecking()
{
string currentConversionVersion = ConversionClient.GetVpxVersion();
return Version.TryParse(currentConversionVersion, out Version result)
&& result.CompareTo(new Version("8.3.1")) >= 0;
}

private void Build()
{
try
{
if (Version.TryParse(_currentConversionVersion, out Version result) &&
result.CompareTo(LowestGuestCheckingConversionVersion) >= 0)
{
tableLayoutPanelVersion.Visible = true;
columnRemarks.Visible = true;
}
else
{
tableLayoutPanelVersion.Visible = false;
columnRemarks.Visible = false;
}

dataGridViewVms.SuspendLayout();
dataGridViewVms.Rows.Clear();

Expand All @@ -140,12 +148,10 @@ private void Build()
continue;
}

bool supported = IsSupportedGuest(vm);
if (showOnlySupportedGuestCheckBox.Checked && !supported)
{
continue;
}
dataGridViewVms.Rows.Add(new SourceVmRow(vm, supported));
bool supported = !_supportVersionChecking || IsSupportedGuest(vm);
SourceVmRow row = new SourceVmRow(vm, supported);
dataGridViewVms.Rows.Add(row);
row.Visible = !showOnlySupportedGuestCheckBox.Checked || supported;
}
}
finally
Expand All @@ -158,6 +164,7 @@ private void Build()
private void UpdateButtons()
{
_buttonNextEnabled = SelectedVmsExist;
UpdateSelectAllAndClearAllButton();
OnPageUpdated();
}

Expand All @@ -174,24 +181,48 @@ private void BulkCheck(bool check)
finally
{
_updating = false;
SupportedVersionCheck();
CheckIfExistUnsupportedVersion();
UpdateButtons();
}
}

private void SupportedVersionCheck()
private void UpdateSelectAllAndClearAllButton()
{
tableLayoutPanelError.Visible = false;
int total = 0;
int check = 0;
foreach (SourceVmRow row in dataGridViewVms.Rows)
{
if (row.IsChecked && !row.IsSupportedGuest())
if (row.Visible)
{
total++;
if (row.IsChecked)
{
check++;
}
}
}

buttonSelectAll.Enabled = total != check;
buttonClearAll.Enabled = check != 0;
}

private void CheckIfExistUnsupportedVersion()
{
if (!_supportVersionChecking)
{
return;
}
foreach (SourceVmRow row in dataGridViewVms.Rows)
{
if (row.Visible && row.IsChecked && !row.IsSupportedGuest())
{
pictureBoxError.Image = Images.StaticImages._000_Alert2_h32bit_16;
labelError.Text = Messages.CONVERSION_UNSUPPORTED_VM_SELECTED_WARNING;
tableLayoutPanelError.Visible = true;
return;
}
}
tableLayoutPanelError.Visible = false;
}

private void UpdateComponentEnabledStatusWhenRefresh(bool enabled)
Expand All @@ -210,7 +241,7 @@ private bool IsSupportedGuest(VmInstance vm)
}
foreach (string supportedVersion in vm.SupportedXSVersions)
{
if (_currentConversionVersion.StartsWith(supportedVersion))
if (_currentXSVersion.StartsWith(supportedVersion))
{
return true;
}
Expand Down Expand Up @@ -291,24 +322,44 @@ private void dataGridViewVms_CellValueChanged(object sender, DataGridViewCellEve

if (e.ColumnIndex != 0 || e.RowIndex < 0 || e.RowIndex >= dataGridViewVms.RowCount)
return;
SupportedVersionCheck();
CheckIfExistUnsupportedVersion();
UpdateButtons();
}

private void showOnlySupportedGuestCheckBox_CheckedChanged(object sender, EventArgs e)
{
RefreshData();
bool existCheckedUnsupportedGuest = false;
foreach (SourceVmRow row in dataGridViewVms.Rows)
{
if (!row.IsSupportedGuest())
{
row.Visible = !showOnlySupportedGuestCheckBox.Checked;
existCheckedUnsupportedGuest = row.IsChecked;
}
}
if (!showOnlySupportedGuestCheckBox.Checked && existCheckedUnsupportedGuest)
{
pictureBoxError.Image = Images.StaticImages._000_Alert2_h32bit_16;
labelError.Text = Messages.CONVERSION_UNSUPPORTED_VM_SELECTED_WARNING;
tableLayoutPanelError.Visible = true;
}
else
{
tableLayoutPanelError.Visible = false;
}

UpdateButtons();
}

private void supportedOSLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (_currentConversionVersion.StartsWith("8.2"))
if (_currentXSVersion.StartsWith("8.2"))
{
System.Diagnostics.Process.Start(Messages.CONVERSION_DOC_PATH_82);
System.Diagnostics.Process.Start(InvisibleMessages.CONVERSION_DOC_PATH_82);
}
else
{
System.Diagnostics.Process.Start(Messages.CONVERSION_DOC_PATH_LATEST);
System.Diagnostics.Process.Start(InvisibleMessages.CONVERSION_DOC_PATH_LATEST);
}
}

Expand Down
33 changes: 12 additions & 21 deletions XenAdmin/Wizards/ConversionWizard/VmSelectionPage.resx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Note that only VMs that are currently shut down are listed here.</value>
<value>518, 268</value>
</data>
<data name="dataGridViewVms.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
<value>1</value>
</data>
<data name="&gt;&gt;dataGridViewVms.Name" xml:space="preserve">
<value>dataGridViewVms</value>
Expand Down Expand Up @@ -242,7 +242,7 @@ Note that only VMs that are currently shut down are listed here.</value>
<value>75, 23</value>
</data>
<data name="buttonSelectAll.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
<value>2</value>
</data>
<data name="buttonSelectAll.Text" xml:space="preserve">
<value>&amp;Select All</value>
Expand All @@ -266,7 +266,7 @@ Note that only VMs that are currently shut down are listed here.</value>
<value>75, 23</value>
</data>
<data name="buttonClearAll.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
<value>3</value>
</data>
<data name="buttonClearAll.Text" xml:space="preserve">
<value>&amp;Clear All</value>
Expand All @@ -290,7 +290,7 @@ Note that only VMs that are currently shut down are listed here.</value>
<value>75, 23</value>
</data>
<data name="buttonRefresh.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
<value>4</value>
</data>
<data name="buttonRefresh.Text" xml:space="preserve">
<value>&amp;Refresh</value>
Expand Down Expand Up @@ -350,29 +350,23 @@ Note that only VMs that are currently shut down are listed here.</value>
<value>2</value>
</data>
<data name="supportedOSLinkLabel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left</value>
<value>Left</value>
</data>
<data name="supportedOSLinkLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="supportedOSLinkLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>280, 0</value>
</data>
<data name="supportedOSLinkLabel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 3, 3</value>
<value>286, 5</value>
</data>
<data name="supportedOSLinkLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>103, 20</value>
<value>103, 13</value>
</data>
<data name="supportedOSLinkLabel.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
<value>6</value>
</data>
<data name="supportedOSLinkLabel.Text" xml:space="preserve">
<value>Supported guest OS</value>
</data>
<data name="supportedOSLinkLabel.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleLeft</value>
</data>
<data name="&gt;&gt;supportedOSLinkLabel.Name" xml:space="preserve">
<value>supportedOSLinkLabel</value>
</data>
Expand All @@ -386,25 +380,22 @@ Note that only VMs that are currently shut down are listed here.</value>
<value>0</value>
</data>
<data name="showOnlySupportedGuestCheckBox.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left</value>
<value>Left</value>
</data>
<data name="showOnlySupportedGuestCheckBox.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="showOnlySupportedGuestCheckBox.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 3</value>
</data>
<data name="showOnlySupportedGuestCheckBox.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 0, 3</value>
</data>
<data name="showOnlySupportedGuestCheckBox.Size" type="System.Drawing.Size, System.Drawing">
<value>277, 17</value>
</data>
<data name="showOnlySupportedGuestCheckBox.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
<value>5</value>
</data>
<data name="showOnlySupportedGuestCheckBox.Text" xml:space="preserve">
<value>Show only guest OS supported in the current version.</value>
<value>Show only guest &amp;OS supported in the current version.</value>
</data>
<data name="&gt;&gt;showOnlySupportedGuestCheckBox.Name" xml:space="preserve">
<value>showOnlySupportedGuestCheckBox</value>
Expand Down Expand Up @@ -575,7 +566,7 @@ Note that only VMs that are currently shut down are listed here.</value>
<value>0</value>
</data>
<data name="tableLayoutPanelVmSelection.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="dataGridViewVms" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="tableLayoutPanel3" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="versionTableLayoutPanel" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="tableLayoutPanelError" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,Percent,100,AutoSize,0,AutoSize,0,Absolute,30" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="labelDesc" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="dataGridViewVms" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="tableLayoutPanelButtons" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="tableLayoutPanelVersion" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="tableLayoutPanelError" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,Percent,100,AutoSize,0,AutoSize,0,Absolute,30" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<metadata name="_backgroundWorker.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
Expand Down
18 changes: 18 additions & 0 deletions XenModel/InvisibleMessages.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions XenModel/InvisibleMessages.resx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@
<data name="CLIENT_ID_URL" xml:space="preserve">
<value>https://support.citrix.com/xencenterclientiddownload</value>
</data>
<data name="CONVERSION_DOC_PATH_82" xml:space="preserve">
<value>https://docs.xenserver.com/en-us/xencenter/8-2/conversion-manager.html#citrix-hypervisor-environment-considerations</value>
</data>
<data name="CONVERSION_DOC_PATH_LATEST" xml:space="preserve">
<value>https://docs.xenserver.com/en-us/xencenter/current-release/conversion-manager.html#xenserver-environment-considerations</value>
</data>
<data name="CSS_URL" xml:space="preserve">
<value>https://www.citrix.com/support/programs/</value>
</data>
Expand Down
Loading

0 comments on commit 84e514f

Please sign in to comment.