From 8e40e0bfebfc9f464bc1636a3218d821cca7517d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rui=20Tom=C3=A9?= <108268980+r-tome@users.noreply.github.com> Date: Fri, 9 Jun 2023 14:15:56 +0100 Subject: [PATCH] [AC-1345] Moved trials logic to a new function on _OrganizationFormScripts (#2917) --- src/Admin/Views/Organizations/Edit.cshtml | 48 +-------------- .../Views/Providers/CreateOrganization.cshtml | 6 ++ .../Shared/_OrganizationFormScripts.cshtml | 59 +++++++++++++++++++ 3 files changed, 67 insertions(+), 46 deletions(-) diff --git a/src/Admin/Views/Organizations/Edit.cshtml b/src/Admin/Views/Organizations/Edit.cshtml index 2d5aa1aed5..e4c329007c 100644 --- a/src/Admin/Views/Organizations/Edit.cshtml +++ b/src/Admin/Views/Organizations/Edit.cshtml @@ -20,60 +20,16 @@ alert('Organization is not on a free plan.'); return; } - // Plan - document.getElementById('@(nameof(Model.PlanType))').value = '@((byte)Bit.Core.Enums.PlanType.TeamsAnnually)'; + togglePlanSettings('@((byte)Bit.Core.Enums.PlanType.TeamsAnnually)'); document.getElementById('@(nameof(Model.Plan))').value = 'Teams (Trial)'; - document.getElementById('@(nameof(Model.Seats))').value = '10'; - document.getElementById('@(nameof(Model.MaxCollections))').value = ''; - document.getElementById('@(nameof(Model.MaxStorageGb))').value = '1'; - // Features - document.getElementById('@(nameof(Model.UsePolicies))').checked = false; - document.getElementById('@(nameof(Model.UseSso))').checked = false; - document.getElementById('@(nameof(Model.UseGroups))').checked = true; - document.getElementById('@(nameof(Model.UseDirectory))').checked = true; - document.getElementById('@(nameof(Model.UseEvents))').checked = true; - document.getElementById('@(nameof(Model.UsersGetPremium))').checked = true; - document.getElementById('@(nameof(Model.UseCustomPermissions))').checked = false; - document.getElementById('@(nameof(Model.UseTotp))').checked = true; - document.getElementById('@(nameof(Model.Use2fa))').checked = true; - document.getElementById('@(nameof(Model.UseApi))').checked = true; - document.getElementById('@(nameof(Model.SelfHost))').checked = false; - document.getElementById('@(nameof(Model.UseResetPassword))').checked = false; - document.getElementById('@(nameof(Model.UseScim))').checked = false; - // Licensing - document.getElementById('@(nameof(Model.LicenseKey))').value = '@Model.RandomLicenseKey'; - document.getElementById('@(nameof(Model.ExpirationDate))').value = '@Model.FourteenDayExpirationDate'; - document.getElementById('@(nameof(Model.SalesAssistedTrialStarted))').value = true; }); document.getElementById('enterprise-trial').addEventListener('click', () => { if (document.getElementById('@(nameof(Model.PlanType))').value !== '@((byte)Bit.Core.Enums.PlanType.Free)') { alert('Organization is not on a free plan.'); return; } - // Plan - document.getElementById('@(nameof(Model.PlanType))').value = '@((byte)Bit.Core.Enums.PlanType.EnterpriseAnnually)'; + togglePlanSettings('@((byte)Bit.Core.Enums.PlanType.EnterpriseAnnually)'); document.getElementById('@(nameof(Model.Plan))').value = 'Enterprise (Trial)'; - document.getElementById('@(nameof(Model.Seats))').value = '10'; - document.getElementById('@(nameof(Model.MaxCollections))').value = ''; - document.getElementById('@(nameof(Model.MaxStorageGb))').value = '1'; - // Features - document.getElementById('@(nameof(Model.UsePolicies))').checked = true; - document.getElementById('@(nameof(Model.UseSso))').checked = true; - document.getElementById('@(nameof(Model.UseGroups))').checked = true; - document.getElementById('@(nameof(Model.UseDirectory))').checked = true; - document.getElementById('@(nameof(Model.UseEvents))').checked = true; - document.getElementById('@(nameof(Model.UsersGetPremium))').checked = true; - document.getElementById('@(nameof(Model.UseCustomPermissions))').checked = true; - document.getElementById('@(nameof(Model.UseTotp))').checked = true; - document.getElementById('@(nameof(Model.Use2fa))').checked = true; - document.getElementById('@(nameof(Model.UseApi))').checked = true; - document.getElementById('@(nameof(Model.SelfHost))').checked = true; - document.getElementById('@(nameof(Model.UseResetPassword))').checked = true; - document.getElementById('@(nameof(Model.UseScim))').checked = true; - // Licensing - document.getElementById('@(nameof(Model.LicenseKey))').value = '@Model.RandomLicenseKey'; - document.getElementById('@(nameof(Model.ExpirationDate))').value = '@Model.FourteenDayExpirationDate'; - document.getElementById('@(nameof(Model.SalesAssistedTrialStarted))').value = true; }); })(); diff --git a/src/Admin/Views/Providers/CreateOrganization.cshtml b/src/Admin/Views/Providers/CreateOrganization.cshtml index 219b6854b9..2257f6e334 100644 --- a/src/Admin/Views/Providers/CreateOrganization.cshtml +++ b/src/Admin/Views/Providers/CreateOrganization.cshtml @@ -5,6 +5,12 @@ @section Scripts { @await Html.PartialAsync("_OrganizationFormScripts") + + }