1
0
Fork 0
mirror of synced 2024-09-25 13:51:40 +12:00

Refactor based on feedback

This commit is contained in:
Conor Webb 2024-08-13 16:36:42 +01:00
parent 9a6a1abb84
commit 7456596c7a

View file

@ -24,7 +24,7 @@
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
const RemoveID = "remove" const RemoveID = "remove"
const subType = $licensing.license.plan.type const subType = $licensing.license.plan.type ?? null
$: enrichLabel = label => (labelPrefix ? `${labelPrefix} ${label}` : label) $: enrichLabel = label => (labelPrefix ? `${labelPrefix} ${label}` : label)
$: options = getOptions( $: options = getOptions(
@ -69,19 +69,13 @@
})) }))
// Add creator if required // Add creator if required
if ( if (allowCreator || isEnterprisePlan(subType)) {
allowCreator ||
subType === Constants.PlanType.ENTERPRISE ||
subType === Constants.PlanType.ENTERPRISE_BASIC
) {
options.unshift({ options.unshift({
_id: Constants.Roles.CREATOR, _id: Constants.Roles.CREATOR,
name: "Can edit", name: "Can edit",
tag: tag: isEnterprisePlan(subType)
subType === Constants.PlanType.ENTERPRISE || ? null
subType === Constants.PlanType.ENTERPRISE_BASIC : capitalise(Constants.PlanType.ENTERPRISE),
? null
: capitalise(Constants.PlanType.ENTERPRISE),
}) })
} }
@ -124,6 +118,14 @@
dispatch("change", e.detail) dispatch("change", e.detail)
} }
} }
function isEnterprisePlan(subType) {
return (
subType === Constants.PlanType.ENTERPRISE ||
subType === Constants.PlanType.ENTERPRISE_BASIC ||
subType === Constants.PlanType.ENTERPRISE_BASIC_trial
)
}
</script> </script>
{#if fancySelect} {#if fancySelect}
@ -143,11 +145,7 @@
getOptionIcon={getIcon} getOptionIcon={getIcon}
isOptionEnabled={option => { isOptionEnabled={option => {
if (option._id === Constants.Roles.CREATOR) { if (option._id === Constants.Roles.CREATOR) {
return ( return isEnterprisePlan(subType)
subType === Constants.PlanType.ENTERPRISE ||
(subType === Constants.PlanType.ENTERPRISE_BASIC_TRIAL &&
$licensing.perAppBuildersEnabled)
)
} }
return true return true
}} }}
@ -170,11 +168,7 @@
getOptionIcon={getIcon} getOptionIcon={getIcon}
isOptionEnabled={option => { isOptionEnabled={option => {
if (option._id === Constants.Roles.CREATOR) { if (option._id === Constants.Roles.CREATOR) {
return ( return isEnterprisePlan(subType)
subType === Constants.PlanType.ENTERPRISE ||
(subType === Constants.PlanType.ENTERPRISE_BASIC_TRIAL &&
$licensing.perAppBuildersEnabled)
)
} }
return option.enabled !== false return option.enabled !== false
}} }}