Merge pull request #10127 from Budibase/feature/whitelabelling-pro

Move branding read behind pro
This commit is contained in:
deanhannigan 2023-03-28 09:45:45 +01:00 committed by GitHub
commit 118f250edb
5 changed files with 32 additions and 31 deletions

View File

@ -23,11 +23,6 @@
chalk "^2.0.0"
js-tokens "^4.0.0"
"@budibase/types@2.4.8-alpha.4":
version "2.4.8-alpha.4"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.4.8-alpha.4.tgz#4e6dec50eef381994432ef4d08587a9a7156dd84"
integrity sha512-aiHHOvsDLHQ2OFmLgaSUttQwSuaPBqF1lbyyCkEJIbbl/qo9EPNZGl+AkB7wo12U5HdqWhr9OpFL12EqkcD4GA==
"@jridgewell/gen-mapping@^0.3.0":
version "0.3.2"
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9"

View File

@ -15,6 +15,7 @@ import { context, objectStore, utils, configs } from "@budibase/backend-core"
import AWS from "aws-sdk"
import fs from "fs"
import sdk from "../../../sdk"
import * as pro from "@budibase/pro"
const send = require("koa-send")
@ -101,6 +102,8 @@ export const deleteObjects = async function (ctx: any) {
export const serveApp = async function (ctx: any) {
//Public Settings
const { config } = await configs.getSettingsConfigDoc()
const branding = await pro.branding.getBrandingConfig(config)
let db
try {
db = context.getAppDB({ skip_setup: true })
@ -112,17 +115,18 @@ export const serveApp = async function (ctx: any) {
const plugins = objectStore.enrichPluginURLs(appInfo.usedPlugins)
const { head, html, css } = App.render({
metaImage:
config?.metaImageUrl ||
branding?.metaImageUrl ||
"https://res.cloudinary.com/daog6scxm/image/upload/v1666109324/meta-images/budibase-meta-image_uukc1m.png",
metaDescription: config?.metaDescription || "",
metaTitle: config?.metaTitle || `${appInfo.name} - built with Budibase`,
metaDescription: branding?.metaDescription || "",
metaTitle:
branding?.metaTitle || `${appInfo.name} - built with Budibase`,
title: appInfo.name,
production: env.isProd(),
appId,
clientLibPath: objectStore.clientLibraryUrl(appId!, appInfo.version),
usedPlugins: plugins,
favicon:
config.faviconUrl !== ""
branding.faviconUrl !== ""
? objectStore.getGlobalFileUrl("settings", "faviconUrl")
: "",
logo:
@ -145,14 +149,14 @@ export const serveApp = async function (ctx: any) {
if (!env.isJest()) {
const App = require("./templates/BudibaseApp.svelte").default
const { head, html, css } = App.render({
title: config?.metaTitle,
metaTitle: config?.metaTitle,
title: branding?.metaTitle,
metaTitle: branding?.metaTitle,
metaImage:
config?.metaImageUrl ||
branding?.metaImageUrl ||
"https://res.cloudinary.com/daog6scxm/image/upload/v1666109324/meta-images/budibase-meta-image_uukc1m.png",
metaDescription: config?.metaDescription || "",
metaDescription: branding?.metaDescription || "",
favicon:
config.faviconUrl !== ""
branding.faviconUrl !== ""
? objectStore.getGlobalFileUrl("settings", "faviconUrl")
: "",
})

View File

@ -22,12 +22,10 @@ export interface SMTPConfig extends Config {
config: SMTPInnerConfig
}
export interface SettingsInnerConfig {
platformUrl?: string
company?: string
logoUrl?: string // Populated on read
logoUrlEtag?: string
/**
* Accessible only via pro.
*/
export interface SettingsBrandingConfig {
faviconUrl?: string
faviconUrlEtag?: string
@ -40,7 +38,13 @@ export interface SettingsInnerConfig {
metaDescription?: string
metaImageUrl?: string
metaTitle?: string
}
export interface SettingsInnerConfig {
platformUrl?: string
company?: string
logoUrl?: string // Populated on read
logoUrlEtag?: string
uniqueTenantId?: string
analyticsEnabled?: boolean
isSSOEnforced?: boolean

View File

@ -310,7 +310,7 @@ export async function publicSettings(
const configDoc = await configs.getSettingsConfigDoc()
const config = configDoc.config
const licensedConfig: object = await getLicensedConfig()
const branding = await pro.branding.getBrandingConfig(config)
// enrich the logo url - empty url means deleted
if (config.logoUrl && config.logoUrl !== "") {
@ -321,11 +321,12 @@ export async function publicSettings(
)
}
if (config.faviconUrl && config.faviconUrl !== "") {
if (branding.faviconUrl && branding.faviconUrl !== "") {
// @ts-ignore
config.faviconUrl = objectStore.getGlobalFileUrl(
"settings",
"faviconUrl",
config.faviconUrl
branding.faviconUrl
)
}
@ -349,7 +350,7 @@ export async function publicSettings(
_rev: configDoc._rev,
config: {
...config,
...licensedConfig,
...branding,
google,
oidc,
isSSOEnforced,

View File

@ -9,12 +9,14 @@ import { checkSlashesInUrl } from "./index"
import { getLicensedConfig } from "./configs"
const BASE_COMPANY = "Budibase"
import * as pro from "@budibase/pro"
export async function getSettingsTemplateContext(
purpose: EmailTemplatePurpose,
code?: string | null
) {
let settings = await configs.getSettingsConfig()
const settings = await configs.getSettingsConfig()
const branding = await pro.branding.getBrandingConfig(settings)
const URL = settings.platformUrl
const context: any = {
[InternalTemplateBinding.LOGO_URL]:
@ -29,12 +31,7 @@ export async function getSettingsTemplateContext(
[InternalTemplateBinding.CURRENT_YEAR]: new Date().getFullYear(),
}
try {
const config: SettingsInnerConfig = await getLicensedConfig()
context["enableEmailBranding"] = config?.emailBrandingEnabled || true
} catch (e) {
context["enableEmailBranding"] = true
}
context["enableEmailBranding"] = branding.emailBrandingEnabled === true
// attach purpose specific context
switch (purpose) {