CP-15409: Add read-only mode to License manager

Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
Mihaela Stoica 2016-01-26 14:49:02 +00:00
parent 249489220b
commit f12b4765b6
5 changed files with 49 additions and 8 deletions

View File

@ -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;
}

View File

@ -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 }

View File

@ -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);
}
}

View File

@ -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<IXenObject> itemsToShow, List<IXenObject> 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
}
}

View File

@ -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<IXenObject> dataToDraw)
{
View.DrawRowsInGrid(ConvertXenObjects(dataToDraw));
@ -107,7 +110,7 @@ namespace XenAdmin.Dialogs
private void CheckPreSelectedRows(List<IXenObject> dataToCheck)
{
if(dataToCheck.Count < 1)
if (dataToCheck.Count < 1 || ReadOnlyView)
{
DisableAllButtons();
return;
@ -297,13 +300,15 @@ namespace XenAdmin.Dialogs
public void UpdateButtonEnablement(List<LicenseDataGridViewRow> 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()