Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user access roles from displaying business #14368

Merged
merged 10 commits into from
Sep 12, 2024
40 changes: 30 additions & 10 deletions packages/builder/src/components/common/RoleSelect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

const dispatch = createEventDispatcher()
const RemoveID = "remove"
const subType = $licensing.license.plan.type
ConorWebb96 marked this conversation as resolved.
Show resolved Hide resolved

$: enrichLabel = label => (labelPrefix ? `${labelPrefix} ${label}` : label)
$: options = getOptions(
Expand Down Expand Up @@ -68,13 +69,19 @@
}))

// Add creator if required
if (allowCreator) {
if (
allowCreator ||
subType === Constants.PlanType.ENTERPRISE ||
subType === Constants.PlanType.ENTERPRISE_BASIC
ConorWebb96 marked this conversation as resolved.
Show resolved Hide resolved
) {
options.unshift({
_id: Constants.Roles.CREATOR,
name: "Can edit",
tag:
!$licensing.perAppBuildersEnabled &&
capitalise(Constants.PlanType.BUSINESS),
subType === Constants.PlanType.ENTERPRISE ||
subType === Constants.PlanType.ENTERPRISE_BASIC
? null
ConorWebb96 marked this conversation as resolved.
Show resolved Hide resolved
: capitalise(Constants.PlanType.ENTERPRISE),
})
}

Expand Down Expand Up @@ -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 &&
ConorWebb96 marked this conversation as resolved.
Show resolved Hide resolved
$licensing.perAppBuildersEnabled)
)
}
return true
}}
{placeholder}
{error}
/>
Expand All @@ -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 ||
ConorWebb96 marked this conversation as resolved.
Show resolved Hide resolved
(subType === Constants.PlanType.ENTERPRISE_BASIC_TRIAL &&
$licensing.perAppBuildersEnabled)
)
}
return option.enabled !== false
}}
{placeholder}
{error}
/>
Expand Down
1 change: 1 addition & 0 deletions packages/frontend-core/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const PlanType = {
TEAM: "team",
PRO: "pro",
BUSINESS: "business",
PREMIUM: "premium",
ENTERPRISE: "enterprise",
ENTERPRISE_BASIC_TRIAL: "enterprise_basic_trial",
}
Expand Down
Loading