From f9e5a9f8ca127fe1d1cff799b1b86843709b1723 Mon Sep 17 00:00:00 2001 From: Conor Webb Date: Tue, 13 Aug 2024 11:27:59 +0100 Subject: [PATCH 1/6] Added frontend type for premium --- packages/frontend-core/src/constants.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/frontend-core/src/constants.js b/packages/frontend-core/src/constants.js index 22e5e8583a..c2706c69b1 100644 --- a/packages/frontend-core/src/constants.js +++ b/packages/frontend-core/src/constants.js @@ -72,6 +72,7 @@ export const PlanType = { TEAM: "team", PRO: "pro", BUSINESS: "business", + PREMIUM: "premium", ENTERPRISE: "enterprise", ENTERPRISE_BASIC_TRIAL: "enterprise_basic_trial", } From 7b3e02506dc7fc84312fedbb4ae05326c7b0f749 Mon Sep 17 00:00:00 2001 From: Conor Webb Date: Tue, 13 Aug 2024 11:28:12 +0100 Subject: [PATCH 2/6] Changed from Business to premium --- packages/builder/src/components/common/RoleSelect.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/components/common/RoleSelect.svelte b/packages/builder/src/components/common/RoleSelect.svelte index 4605b0c182..6ed77f383c 100644 --- a/packages/builder/src/components/common/RoleSelect.svelte +++ b/packages/builder/src/components/common/RoleSelect.svelte @@ -74,7 +74,7 @@ name: "Can edit", tag: !$licensing.perAppBuildersEnabled && - capitalise(Constants.PlanType.BUSINESS), + capitalise(Constants.PlanType.PREMIUM), }) } From bd5789f59cbeada57ea9112ad5f1c338f4de3faa Mon Sep 17 00:00:00 2001 From: Conor Webb Date: Tue, 13 Aug 2024 11:36:15 +0100 Subject: [PATCH 3/6] Changed label to enterprise. --- packages/builder/src/components/common/RoleSelect.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/components/common/RoleSelect.svelte b/packages/builder/src/components/common/RoleSelect.svelte index 6ed77f383c..49b349a00c 100644 --- a/packages/builder/src/components/common/RoleSelect.svelte +++ b/packages/builder/src/components/common/RoleSelect.svelte @@ -74,7 +74,7 @@ name: "Can edit", tag: !$licensing.perAppBuildersEnabled && - capitalise(Constants.PlanType.PREMIUM), + capitalise(Constants.PlanType.ENTERPRISE), }) } From 9a6a1abb84e999437137156e18f9fa89eb608d8b Mon Sep 17 00:00:00 2001 From: Conor Webb Date: Tue, 13 Aug 2024 12:39:56 +0100 Subject: [PATCH 4/6] Fix logic, enterprise is the only tier that can use this --- .../src/components/common/RoleSelect.svelte | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/packages/builder/src/components/common/RoleSelect.svelte b/packages/builder/src/components/common/RoleSelect.svelte index 49b349a00c..6eb7b705be 100644 --- a/packages/builder/src/components/common/RoleSelect.svelte +++ b/packages/builder/src/components/common/RoleSelect.svelte @@ -24,6 +24,7 @@ const dispatch = createEventDispatcher() const RemoveID = "remove" + const subType = $licensing.license.plan.type $: enrichLabel = label => (labelPrefix ? `${labelPrefix} ${label}` : label) $: options = getOptions( @@ -68,13 +69,19 @@ })) // Add creator if required - if (allowCreator) { + if ( + allowCreator || + subType === Constants.PlanType.ENTERPRISE || + subType === Constants.PlanType.ENTERPRISE_BASIC + ) { options.unshift({ _id: Constants.Roles.CREATOR, name: "Can edit", tag: - !$licensing.perAppBuildersEnabled && - capitalise(Constants.PlanType.ENTERPRISE), + subType === Constants.PlanType.ENTERPRISE || + subType === Constants.PlanType.ENTERPRISE_BASIC + ? null + : capitalise(Constants.PlanType.ENTERPRISE), }) } @@ -134,9 +141,16 @@ getOptionValue={role => role._id} getOptionColour={getColor} getOptionIcon={getIcon} - isOptionEnabled={option => - option._id !== Constants.Roles.CREATOR || - $licensing.perAppBuildersEnabled} + isOptionEnabled={option => { + if (option._id === Constants.Roles.CREATOR) { + return ( + subType === Constants.PlanType.ENTERPRISE || + (subType === Constants.PlanType.ENTERPRISE_BASIC_TRIAL && + $licensing.perAppBuildersEnabled) + ) + } + return true + }} {placeholder} {error} /> @@ -154,10 +168,16 @@ getOptionValue={role => role._id} getOptionColour={getColor} getOptionIcon={getIcon} - isOptionEnabled={option => - (option._id !== Constants.Roles.CREATOR || - $licensing.perAppBuildersEnabled) && - option.enabled !== false} + isOptionEnabled={option => { + if (option._id === Constants.Roles.CREATOR) { + return ( + subType === Constants.PlanType.ENTERPRISE || + (subType === Constants.PlanType.ENTERPRISE_BASIC_TRIAL && + $licensing.perAppBuildersEnabled) + ) + } + return option.enabled !== false + }} {placeholder} {error} /> From 7456596c7ac338405b54d5b533d7018c58321cb9 Mon Sep 17 00:00:00 2001 From: Conor Webb Date: Tue, 13 Aug 2024 16:36:42 +0100 Subject: [PATCH 5/6] Refactor based on feedback --- .../src/components/common/RoleSelect.svelte | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/packages/builder/src/components/common/RoleSelect.svelte b/packages/builder/src/components/common/RoleSelect.svelte index 6eb7b705be..3a37e61138 100644 --- a/packages/builder/src/components/common/RoleSelect.svelte +++ b/packages/builder/src/components/common/RoleSelect.svelte @@ -24,7 +24,7 @@ const dispatch = createEventDispatcher() const RemoveID = "remove" - const subType = $licensing.license.plan.type + const subType = $licensing.license.plan.type ?? null $: enrichLabel = label => (labelPrefix ? `${labelPrefix} ${label}` : label) $: options = getOptions( @@ -69,19 +69,13 @@ })) // Add creator if required - if ( - allowCreator || - subType === Constants.PlanType.ENTERPRISE || - subType === Constants.PlanType.ENTERPRISE_BASIC - ) { + if (allowCreator || isEnterprisePlan(subType)) { options.unshift({ _id: Constants.Roles.CREATOR, name: "Can edit", - tag: - subType === Constants.PlanType.ENTERPRISE || - subType === Constants.PlanType.ENTERPRISE_BASIC - ? null - : capitalise(Constants.PlanType.ENTERPRISE), + tag: isEnterprisePlan(subType) + ? null + : capitalise(Constants.PlanType.ENTERPRISE), }) } @@ -124,6 +118,14 @@ dispatch("change", e.detail) } } + + function isEnterprisePlan(subType) { + return ( + subType === Constants.PlanType.ENTERPRISE || + subType === Constants.PlanType.ENTERPRISE_BASIC || + subType === Constants.PlanType.ENTERPRISE_BASIC_trial + ) + } {#if fancySelect} @@ -143,11 +145,7 @@ getOptionIcon={getIcon} isOptionEnabled={option => { if (option._id === Constants.Roles.CREATOR) { - return ( - subType === Constants.PlanType.ENTERPRISE || - (subType === Constants.PlanType.ENTERPRISE_BASIC_TRIAL && - $licensing.perAppBuildersEnabled) - ) + return isEnterprisePlan(subType) } return true }} @@ -170,11 +168,7 @@ getOptionIcon={getIcon} isOptionEnabled={option => { if (option._id === Constants.Roles.CREATOR) { - return ( - subType === Constants.PlanType.ENTERPRISE || - (subType === Constants.PlanType.ENTERPRISE_BASIC_TRIAL && - $licensing.perAppBuildersEnabled) - ) + return isEnterprisePlan(subType) } return option.enabled !== false }} From 8a5d0560eb6bff84067d181478f6d42fa653faec Mon Sep 17 00:00:00 2001 From: Conor Webb Date: Wed, 11 Sep 2024 10:01:20 +0100 Subject: [PATCH 6/6] Fixed PlanType typo --- packages/builder/src/components/common/RoleSelect.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/components/common/RoleSelect.svelte b/packages/builder/src/components/common/RoleSelect.svelte index 3a37e61138..6006b8ab8d 100644 --- a/packages/builder/src/components/common/RoleSelect.svelte +++ b/packages/builder/src/components/common/RoleSelect.svelte @@ -123,7 +123,7 @@ return ( subType === Constants.PlanType.ENTERPRISE || subType === Constants.PlanType.ENTERPRISE_BASIC || - subType === Constants.PlanType.ENTERPRISE_BASIC_trial + subType === Constants.PlanType.ENTERPRISE_BASIC_TRIAL ) }