From 333145209e6274bd0f135cc11b753c2653bdf5a3 Mon Sep 17 00:00:00 2001 From: cturnbull-bitwarden <133619638+cturnbull-bitwarden@users.noreply.github.com> Date: Tue, 27 Jun 2023 05:23:23 -0400 Subject: [PATCH] [AC-1429] Add new secrets manager fields to organization edit page in admin portal (#3009) * Added new secrets fields to organization edit page * Reordered fields based on feedback from Priya --- .../Controllers/OrganizationsController.cs | 6 ++ src/Admin/Models/OrganizationEditModel.cs | 16 +++ .../Views/Shared/_OrganizationForm.cshtml | 97 +++++++++++++------ .../Shared/_OrganizationFormScripts.cshtml | 20 ++++ 4 files changed, 111 insertions(+), 28 deletions(-) diff --git a/src/Admin/Controllers/OrganizationsController.cs b/src/Admin/Controllers/OrganizationsController.cs index 01e55f86a9..9a367d7997 100644 --- a/src/Admin/Controllers/OrganizationsController.cs +++ b/src/Admin/Controllers/OrganizationsController.cs @@ -287,6 +287,12 @@ public class OrganizationsController : Controller organization.UseTotp = model.UseTotp; organization.UsersGetPremium = model.UsersGetPremium; organization.UseSecretsManager = model.UseSecretsManager; + + //secrets + organization.SmSeats = model.SmSeats; + organization.MaxAutoscaleSmSeats = model.MaxAutoscaleSmSeats; + organization.SmServiceAccounts = model.SmServiceAccounts; + organization.MaxAutoscaleSmServiceAccounts = model.MaxAutoscaleSmServiceAccounts; } if (_accessControlService.UserHasPermission(Permission.Org_Licensing_Edit)) diff --git a/src/Admin/Models/OrganizationEditModel.cs b/src/Admin/Models/OrganizationEditModel.cs index f67ad18abc..19a82bb31c 100644 --- a/src/Admin/Models/OrganizationEditModel.cs +++ b/src/Admin/Models/OrganizationEditModel.cs @@ -63,6 +63,10 @@ public class OrganizationEditModel : OrganizationViewModel Enabled = org.Enabled; LicenseKey = org.LicenseKey; ExpirationDate = org.ExpirationDate; + SmSeats = org.SmSeats; + MaxAutoscaleSmSeats = org.MaxAutoscaleSmSeats; + SmServiceAccounts = org.SmServiceAccounts; + MaxAutoscaleSmServiceAccounts = org.MaxAutoscaleSmServiceAccounts; } public BillingInfo BillingInfo { get; set; } @@ -134,6 +138,14 @@ public class OrganizationEditModel : OrganizationViewModel [Display(Name = "Expiration Date")] public DateTime? ExpirationDate { get; set; } public bool SalesAssistedTrialStarted { get; set; } + [Display(Name = "Seats")] + public int? SmSeats { get; set; } + [Display(Name = "Max Autoscale Seats")] + public int? MaxAutoscaleSmSeats { get; set; } + [Display(Name = "Max Service Accounts")] + public int? SmServiceAccounts { get; set; } + [Display(Name = "Max Autoscale Service Accounts")] + public int? MaxAutoscaleSmServiceAccounts { get; set; } public Organization CreateOrganization(Provider provider) { @@ -174,6 +186,10 @@ public class OrganizationEditModel : OrganizationViewModel existingOrganization.LicenseKey = LicenseKey; existingOrganization.ExpirationDate = ExpirationDate; existingOrganization.MaxAutoscaleSeats = MaxAutoscaleSeats; + existingOrganization.SmSeats = SmSeats; + existingOrganization.MaxAutoscaleSmSeats = MaxAutoscaleSmSeats; + existingOrganization.SmServiceAccounts = SmServiceAccounts; + existingOrganization.MaxAutoscaleSmServiceAccounts = MaxAutoscaleSmServiceAccounts; return existingOrganization; } } diff --git a/src/Admin/Views/Shared/_OrganizationForm.cshtml b/src/Admin/Views/Shared/_OrganizationForm.cshtml index f20b80f280..ae5970603c 100644 --- a/src/Admin/Views/Shared/_OrganizationForm.cshtml +++ b/src/Admin/Views/Shared/_OrganizationForm.cshtml @@ -99,34 +99,6 @@ -
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
-
- - -
-
-

Features

@@ -200,6 +172,75 @@
} + + @if (canViewPlan) + { +

Password Manager Configuration

+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+ } + + @if (canViewPlan) + { + + } + @if(canViewLicensing) {

Licensing

diff --git a/src/Admin/Views/Shared/_OrganizationFormScripts.cshtml b/src/Admin/Views/Shared/_OrganizationFormScripts.cshtml index 70a5ae60d7..8fd7ef10e0 100644 --- a/src/Admin/Views/Shared/_OrganizationFormScripts.cshtml +++ b/src/Admin/Views/Shared/_OrganizationFormScripts.cshtml @@ -32,6 +32,18 @@ 'subscriptions/' + subId.value, '_blank'); } }); + document.getElementById('@(nameof(Model.UseSecretsManager))').addEventListener('change', (event) => { + document.getElementById('organization-secrets-configuration').hidden = !event.target.checked; + + if (event.target.checked) { + return; + } + + document.getElementById('@(nameof(Model.SmSeats))').value = ''; + document.getElementById('@(nameof(Model.MaxAutoscaleSmSeats))').value = ''; + document.getElementById('@(nameof(Model.SmServiceAccounts))').value = ''; + document.getElementById('@(nameof(Model.MaxAutoscaleSmServiceAccounts))').value = ''; + }); })(); function togglePlanSettings(planType) { @@ -43,6 +55,10 @@ document.getElementById('@(nameof(Model.Seats))').value = '10'; document.getElementById('@(nameof(Model.MaxCollections))').value = ''; document.getElementById('@(nameof(Model.MaxStorageGb))').value = '1'; + // Secrets + if (document.getElementById('@(nameof(Model.UseSecretsManager))').checked) { + document.getElementById('@(nameof(Model.SmServiceAccounts))').value = '50'; + } // Features document.getElementById('@(nameof(Model.UsePolicies))').checked = false; document.getElementById('@(nameof(Model.UseSso))').checked = false; @@ -69,6 +85,10 @@ document.getElementById('@(nameof(Model.Seats))').value = '10'; document.getElementById('@(nameof(Model.MaxCollections))').value = ''; document.getElementById('@(nameof(Model.MaxStorageGb))').value = '1'; + // Secrets + if (document.getElementById('@(nameof(Model.UseSecretsManager))').checked) { + document.getElementById('@(nameof(Model.SmServiceAccounts))').value = '200'; + } // Features document.getElementById('@(nameof(Model.UsePolicies))').checked = true; document.getElementById('@(nameof(Model.UseSso))').checked = true;