diff --git a/XenAdmin/Controls/CheckableDataGridView/CheckableDataGridView.cs b/XenAdmin/Controls/CheckableDataGridView/CheckableDataGridView.cs index 3089235a0..3d9469dac 100644 --- a/XenAdmin/Controls/CheckableDataGridView/CheckableDataGridView.cs +++ b/XenAdmin/Controls/CheckableDataGridView/CheckableDataGridView.cs @@ -291,7 +291,16 @@ namespace XenAdmin.Controls.CheckableDataGridView if (rowIndex < 0 || rowIndex >= Rows.Count) return; - CurrentCell = Rows[rowIndex].Cells[0]; + CurrentCell = null; + // Set CurrentCell to first visible cell + for (int i = 0; i < Rows[rowIndex].Cells.Count; i++) + { + if (Rows[rowIndex].Cells[i].Visible) + { + CurrentCell = Rows[rowIndex].Cells[i]; + break; + } + } Rows[rowIndex].Selected = highlightStatus; } diff --git a/XenAdmin/Core/Registry.cs b/XenAdmin/Core/Registry.cs index 4967342c5..1a75b7fb8 100644 --- a/XenAdmin/Core/Registry.cs +++ b/XenAdmin/Core/Registry.cs @@ -388,6 +388,12 @@ namespace XenAdmin.Core { return HiddenFeatures != null && HiddenFeatures.Contains(UPLOAD_OPTION_HIDDEN); } } + internal static bool LicenseOperationsHidden + { + get + { return HiddenFeatures != null && HiddenFeatures.Contains(LICENSE_OPERATIONS_HIDDEN); } + } + private const string SSL_CERTIFICATES_CHANGED_ONLY = "CHANGED"; private const string SSL_CERTIFICATES_ALL = "ALL"; private const string SSL_CERTIFICATES_KEY = "ForceSSLCertificates"; @@ -417,8 +423,9 @@ namespace XenAdmin.Core private const string TOOL_STRIP_MENU_ITEM_HIDDEN = "tool_strip_menu_item"; private const string CROSS_SERVER_PRIVATE_NETWORK_HIDDEN = "cross_server_private_network"; private const string COPYRIGHT_HIDDEN = "copyright"; - private const string HEALTH_CHECK_HIDDEN = "health_check"; + private const string HEALTH_CHECK_HIDDEN = "health_check"; private const string UPLOAD_OPTION_HIDDEN = "upload_option"; + private const string LICENSE_OPERATIONS_HIDDEN = "license_operations"; } public enum SSLCertificateTypes { None, Changed, All } diff --git a/XenAdmin/Dialogs/LicenseManager/ILicenseManagerView.cs b/XenAdmin/Dialogs/LicenseManager/ILicenseManagerView.cs index f94f85819..d69db20ba 100644 --- a/XenAdmin/Dialogs/LicenseManager/ILicenseManagerView.cs +++ b/XenAdmin/Dialogs/LicenseManager/ILicenseManagerView.cs @@ -60,5 +60,6 @@ namespace XenAdmin.Dialogs Control Parent { get; } void DrawSummaryInformation(string info, bool show); void SetRowDisabledRowInfo(int rowIndex, string info, bool disabled); + void DrawViewAsReadOnly(bool isReadOnly); } } diff --git a/XenAdmin/Dialogs/LicenseManager/LicenseManager.cs b/XenAdmin/Dialogs/LicenseManager/LicenseManager.cs index c51fd5247..ae7fd0db9 100644 --- a/XenAdmin/Dialogs/LicenseManager/LicenseManager.cs +++ b/XenAdmin/Dialogs/LicenseManager/LicenseManager.cs @@ -37,6 +37,7 @@ using System.Windows.Forms; using XenAdmin.Controls; using XenAdmin.Controls.CheckableDataGridView; using XenAdmin.Controls.SummaryPanel; +using XenAdmin.Core; using XenAdmin.Properties; using XenAPI; @@ -57,6 +58,7 @@ namespace XenAdmin.Dialogs checkableDataGridView.LoadView(); Controller = lmcontroller; Controller.View = this; + downloadLicenseServerLink.Visible = checkBoxColumn.Visible = !Controller.ReadOnlyView; } private void LoadView(List itemsToShow, List selectedItems) @@ -167,7 +169,7 @@ namespace XenAdmin.Dialogs Program.Invoke(this, Controller.Repopulate); } - #region ISummaryPanelView Members + #region ILicenseManagerView Members [EditorBrowsable(EditorBrowsableState.Never)] public LicenseManagerController Controller { set; private get; } @@ -206,7 +208,7 @@ namespace XenAdmin.Dialogs summaryPanel.Title = lRow.XenObject.Name; summaryPanel.HelperUrl = Messages.LICENSE_MANAGER_BUY_LICENSE_LINK_TEXT; - summaryPanel.HelperUrlVisible = lRow.HelperUrlRequired; + summaryPanel.HelperUrlVisible = lRow.HelperUrlRequired && !Controller.ReadOnlyView; summaryPanel.WarningVisible = lRow.WarningRequired; summaryPanel.WarningText = lRow.WarningText; summaryPanel.SummaryText = summaryComponent; @@ -295,6 +297,23 @@ namespace XenAdmin.Dialogs checkableDataGridView.SetRowInformation(rowIndex, info, disabled); } + [EditorBrowsable(EditorBrowsableState.Never)] + public void DrawViewAsReadOnly(bool isReadOnly) + { + if (isReadOnly) + { + activateFreeXenServerButton.Hide(); + assignLicenceButton.Hide(); + releaseLicenseButton.Hide(); + } + else + { + activateFreeXenServerButton.Show(); + assignLicenceButton.Show(); + releaseLicenseButton.Show(); + } + } + #endregion } } diff --git a/XenAdmin/Dialogs/LicenseManager/LicenseManagerController.cs b/XenAdmin/Dialogs/LicenseManager/LicenseManagerController.cs index a6769e6c4..728d9da8c 100644 --- a/XenAdmin/Dialogs/LicenseManager/LicenseManagerController.cs +++ b/XenAdmin/Dialogs/LicenseManager/LicenseManagerController.cs @@ -53,6 +53,7 @@ namespace XenAdmin.Dialogs { ActivationRequest = new LicenseActivationRequest(); VerifierFactory = new LicenseSelectionVerifierFactory(); + ReadOnlyView = Registry.LicenseOperationsHidden; } public LicenseManagerController(ILicenseManagerView view) @@ -64,6 +65,8 @@ namespace XenAdmin.Dialogs public SelectionVerifierFactory VerifierFactory { private get; set; } + public bool ReadOnlyView { get; private set; } + private void AddToGrid(List dataToDraw) { View.DrawRowsInGrid(ConvertXenObjects(dataToDraw)); @@ -107,7 +110,7 @@ namespace XenAdmin.Dialogs private void CheckPreSelectedRows(List dataToCheck) { - if(dataToCheck.Count < 1) + if (dataToCheck.Count < 1 || ReadOnlyView) { DisableAllButtons(); return; @@ -297,13 +300,15 @@ namespace XenAdmin.Dialogs public void UpdateButtonEnablement(List lRows) { //All buttons disabled? - if(lRows.Count < 1) + if(lRows.Count < 1 || ReadOnlyView) { DisableAllButtons(); - + View.DrawViewAsReadOnly(ReadOnlyView); return; } + View.DrawViewAsReadOnly(ReadOnlyView); + LicenseSelectionVerifier verifier; verifier = VerifierFactory.Verifier(SelectionVerifierFactory.Option.NotLive, lRows); if (verifier.Status == LicenseSelectionVerifier.VerificationStatus.Error) @@ -351,7 +356,7 @@ namespace XenAdmin.Dialogs View.DrawAssignButtonAsDisabled(true); View.DrawReleaseButtonAsDisabled(true); View.DrawActivateButtonAsDisabled(true); - View.DrawActivateButtonAsHidden(false); + View.DrawActivateButtonAsHidden(ReadOnlyView); } private void ResetButtonEnablement()