Branding feature flag changes, config trimming and some fixes

This commit is contained in:
Dean 2023-03-27 15:17:14 +01:00
parent 1b6a2bebf9
commit 8131d9dc6f
5 changed files with 44 additions and 21 deletions

View File

@ -8,7 +8,7 @@
$: platformTitleText = $organisation.platformTitle $: platformTitleText = $organisation.platformTitle
$: platformTitleText, $: platformTitleText,
(platformTitle = (platformTitle =
!$admin.isCloud && !$auth.user ? platformTitleText : "Budibase") !$auth.user && platformTitleText ? platformTitleText : "Budibase")
$: faviconUrl = $organisation.faviconUrl || "https://i.imgur.com/Xhdt1YP.png" $: faviconUrl = $organisation.faviconUrl || "https://i.imgur.com/Xhdt1YP.png"

View File

@ -47,12 +47,8 @@
$: onConfigUpdate(config, mounted) $: onConfigUpdate(config, mounted)
$: init = Object.keys(config).length > 0 $: init = Object.keys(config).length > 0
$: cloudPremium = !$licensing.isFreePlan
$: selfhostPremium = $licensing.isEnterprisePlan || $licensing.isBusinessPlan
$: isCloud = $admin.cloud $: isCloud = $admin.cloud
$: brandingEnabled = $licensing.brandingEnabled
$: isLicenseLocked =
(isCloud && !cloudPremium) || (!isCloud && !selfhostPremium)
const onConfigUpdate = () => { const onConfigUpdate = () => {
if (!mounted || updated || !init) { if (!mounted || updated || !init) {
@ -152,6 +148,27 @@
faviconPreview = null faviconPreview = null
} }
} }
// Trim
const userStrings = [
"metaTitle",
"platformTitle",
"loginButton",
"loginHeading",
"metaDescription",
"metaImageUrl",
]
const trimmed = userStrings.reduce((acc, fieldName) => {
acc[fieldName] = config[fieldName] ? config[fieldName].trim() : undefined
return acc
}, {})
config = {
...config,
...trimmed,
}
try { try {
// Update settings // Update settings
await organisation.save(config) await organisation.save(config)
@ -190,12 +207,12 @@
<Layout gap="XS" noPadding> <Layout gap="XS" noPadding>
<div class="title"> <div class="title">
<Heading size="M">Branding</Heading> <Heading size="M">Branding</Heading>
{#if !isCloud && !selfhostPremium} {#if !isCloud && !brandingEnabled}
<Tags> <Tags>
<Tag icon="LockClosed">Business</Tag> <Tag icon="LockClosed">Business</Tag>
</Tags> </Tags>
{/if} {/if}
{#if isCloud && !cloudPremium} {#if isCloud && !brandingEnabled}
<Tags> <Tags>
<Tag icon="LockClosed">Pro</Tag> <Tag icon="LockClosed">Pro</Tag>
</Tags> </Tags>
@ -226,7 +243,7 @@
config = clone config = clone
}} }}
value={logoFile || logo} value={logoFile || logo}
disabled={isLicenseLocked || saving} disabled={!brandingEnabled || saving}
allowClear={true} allowClear={true}
/> />
</div> </div>
@ -251,7 +268,7 @@
config = clone config = clone
}} }}
value={faviconFile || favicon} value={faviconFile || favicon}
disabled={isLicenseLocked || saving} disabled={!brandingEnabled || saving}
allowClear={true} allowClear={true}
/> />
</div> </div>
@ -265,7 +282,7 @@
config = clone config = clone
}} }}
value={config.platformTitle || ""} value={config.platformTitle || ""}
disabled={!selfhostPremium || saving} disabled={!brandingEnabled || saving}
/> />
</div> </div>
{/if} {/if}
@ -278,7 +295,7 @@
config = clone config = clone
}} }}
value={!config.emailBrandingEnabled} value={!config.emailBrandingEnabled}
disabled={isLicenseLocked || saving} disabled={!brandingEnabled || saving}
/> />
</div> </div>
</div> </div>
@ -300,7 +317,7 @@
config = clone config = clone
}} }}
value={config.loginHeading || ""} value={config.loginHeading || ""}
disabled={!selfhostPremium || saving} disabled={!brandingEnabled || saving}
/> />
</div> </div>
@ -313,7 +330,7 @@
config = clone config = clone
}} }}
value={config.loginButton || ""} value={config.loginButton || ""}
disabled={!selfhostPremium || saving} disabled={!brandingEnabled || saving}
/> />
</div> </div>
<div> <div>
@ -325,7 +342,7 @@
config = clone config = clone
}} }}
value={!config.testimonialsEnabled} value={!config.testimonialsEnabled}
disabled={!selfhostPremium || saving} disabled={!brandingEnabled || saving}
/> />
<Toggle <Toggle
text={"Remove license agreement"} text={"Remove license agreement"}
@ -335,7 +352,7 @@
config = clone config = clone
}} }}
value={!config.licenseAgreementEnabled} value={!config.licenseAgreementEnabled}
disabled={!selfhostPremium || saving} disabled={!brandingEnabled || saving}
/> />
</div> </div>
</div> </div>
@ -357,7 +374,7 @@
config = clone config = clone
}} }}
value={config.metaImageUrl} value={config.metaImageUrl}
disabled={isLicenseLocked || saving} disabled={!brandingEnabled || saving}
/> />
</div> </div>
<div class="field"> <div class="field">
@ -369,7 +386,7 @@
config = clone config = clone
}} }}
value={config.metaTitle} value={config.metaTitle}
disabled={isLicenseLocked || saving} disabled={!brandingEnabled || saving}
/> />
</div> </div>
<div class="field"> <div class="field">
@ -381,13 +398,13 @@
config = clone config = clone
}} }}
value={config.metaDescription} value={config.metaDescription}
disabled={isLicenseLocked || saving} disabled={!brandingEnabled || saving}
/> />
</div> </div>
</div> </div>
</div> </div>
<div class="buttons"> <div class="buttons">
{#if isLicenseLocked} {#if !brandingEnabled}
<Button <Button
on:click={() => { on:click={() => {
if (isCloud && $auth?.user?.accountPortalAccess) { if (isCloud && $auth?.user?.accountPortalAccess) {

View File

@ -17,6 +17,7 @@ export const createLicensingStore = () => {
// features // features
groupsEnabled: false, groupsEnabled: false,
backupsEnabled: false, backupsEnabled: false,
brandingEnabled: false,
// the currently used quotas from the db // the currently used quotas from the db
quotaUsage: undefined, quotaUsage: undefined,
// derived quota metrics for percentages used // derived quota metrics for percentages used
@ -71,7 +72,9 @@ export const createLicensingStore = () => {
const enforceableSSO = license.features.includes( const enforceableSSO = license.features.includes(
Constants.Features.ENFORCEABLE_SSO Constants.Features.ENFORCEABLE_SSO
) )
const brandingEnabled = license.features.includes(
Constants.Features.BRANDING
)
const auditLogsEnabled = license.features.includes( const auditLogsEnabled = license.features.includes(
Constants.Features.AUDIT_LOGS Constants.Features.AUDIT_LOGS
) )
@ -84,6 +87,7 @@ export const createLicensingStore = () => {
isBusinessPlan, isBusinessPlan,
groupsEnabled, groupsEnabled,
backupsEnabled, backupsEnabled,
brandingEnabled,
environmentVariablesEnabled, environmentVariablesEnabled,
auditLogsEnabled, auditLogsEnabled,
enforceableSSO, enforceableSSO,

View File

@ -68,6 +68,7 @@ export const Features = {
ENVIRONMENT_VARIABLES: "environmentVariables", ENVIRONMENT_VARIABLES: "environmentVariables",
AUDIT_LOGS: "auditLogs", AUDIT_LOGS: "auditLogs",
ENFORCEABLE_SSO: "enforceableSSO", ENFORCEABLE_SSO: "enforceableSSO",
BRANDING: "branding",
} }
// Role IDs // Role IDs

View File

@ -4,4 +4,5 @@ export enum Feature {
ENVIRONMENT_VARIABLES = "environmentVariables", ENVIRONMENT_VARIABLES = "environmentVariables",
AUDIT_LOGS = "auditLogs", AUDIT_LOGS = "auditLogs",
ENFORCEABLE_SSO = "enforceableSSO", ENFORCEABLE_SSO = "enforceableSSO",
BRANDING = "branding",
} }