Merge pull request #10127 from Budibase/feature/whitelabelling-pro
Move branding read behind pro
This commit is contained in:
commit
118f250edb
|
@ -23,11 +23,6 @@
|
||||||
chalk "^2.0.0"
|
chalk "^2.0.0"
|
||||||
js-tokens "^4.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":
|
"@jridgewell/gen-mapping@^0.3.0":
|
||||||
version "0.3.2"
|
version "0.3.2"
|
||||||
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9"
|
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9"
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { context, objectStore, utils, configs } from "@budibase/backend-core"
|
||||||
import AWS from "aws-sdk"
|
import AWS from "aws-sdk"
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import sdk from "../../../sdk"
|
import sdk from "../../../sdk"
|
||||||
|
import * as pro from "@budibase/pro"
|
||||||
|
|
||||||
const send = require("koa-send")
|
const send = require("koa-send")
|
||||||
|
|
||||||
|
@ -101,6 +102,8 @@ export const deleteObjects = async function (ctx: any) {
|
||||||
export const serveApp = async function (ctx: any) {
|
export const serveApp = async function (ctx: any) {
|
||||||
//Public Settings
|
//Public Settings
|
||||||
const { config } = await configs.getSettingsConfigDoc()
|
const { config } = await configs.getSettingsConfigDoc()
|
||||||
|
const branding = await pro.branding.getBrandingConfig(config)
|
||||||
|
|
||||||
let db
|
let db
|
||||||
try {
|
try {
|
||||||
db = context.getAppDB({ skip_setup: true })
|
db = context.getAppDB({ skip_setup: true })
|
||||||
|
@ -112,17 +115,18 @@ export const serveApp = async function (ctx: any) {
|
||||||
const plugins = objectStore.enrichPluginURLs(appInfo.usedPlugins)
|
const plugins = objectStore.enrichPluginURLs(appInfo.usedPlugins)
|
||||||
const { head, html, css } = App.render({
|
const { head, html, css } = App.render({
|
||||||
metaImage:
|
metaImage:
|
||||||
config?.metaImageUrl ||
|
branding?.metaImageUrl ||
|
||||||
"https://res.cloudinary.com/daog6scxm/image/upload/v1666109324/meta-images/budibase-meta-image_uukc1m.png",
|
"https://res.cloudinary.com/daog6scxm/image/upload/v1666109324/meta-images/budibase-meta-image_uukc1m.png",
|
||||||
metaDescription: config?.metaDescription || "",
|
metaDescription: branding?.metaDescription || "",
|
||||||
metaTitle: config?.metaTitle || `${appInfo.name} - built with Budibase`,
|
metaTitle:
|
||||||
|
branding?.metaTitle || `${appInfo.name} - built with Budibase`,
|
||||||
title: appInfo.name,
|
title: appInfo.name,
|
||||||
production: env.isProd(),
|
production: env.isProd(),
|
||||||
appId,
|
appId,
|
||||||
clientLibPath: objectStore.clientLibraryUrl(appId!, appInfo.version),
|
clientLibPath: objectStore.clientLibraryUrl(appId!, appInfo.version),
|
||||||
usedPlugins: plugins,
|
usedPlugins: plugins,
|
||||||
favicon:
|
favicon:
|
||||||
config.faviconUrl !== ""
|
branding.faviconUrl !== ""
|
||||||
? objectStore.getGlobalFileUrl("settings", "faviconUrl")
|
? objectStore.getGlobalFileUrl("settings", "faviconUrl")
|
||||||
: "",
|
: "",
|
||||||
logo:
|
logo:
|
||||||
|
@ -145,14 +149,14 @@ export const serveApp = async function (ctx: any) {
|
||||||
if (!env.isJest()) {
|
if (!env.isJest()) {
|
||||||
const App = require("./templates/BudibaseApp.svelte").default
|
const App = require("./templates/BudibaseApp.svelte").default
|
||||||
const { head, html, css } = App.render({
|
const { head, html, css } = App.render({
|
||||||
title: config?.metaTitle,
|
title: branding?.metaTitle,
|
||||||
metaTitle: config?.metaTitle,
|
metaTitle: branding?.metaTitle,
|
||||||
metaImage:
|
metaImage:
|
||||||
config?.metaImageUrl ||
|
branding?.metaImageUrl ||
|
||||||
"https://res.cloudinary.com/daog6scxm/image/upload/v1666109324/meta-images/budibase-meta-image_uukc1m.png",
|
"https://res.cloudinary.com/daog6scxm/image/upload/v1666109324/meta-images/budibase-meta-image_uukc1m.png",
|
||||||
metaDescription: config?.metaDescription || "",
|
metaDescription: branding?.metaDescription || "",
|
||||||
favicon:
|
favicon:
|
||||||
config.faviconUrl !== ""
|
branding.faviconUrl !== ""
|
||||||
? objectStore.getGlobalFileUrl("settings", "faviconUrl")
|
? objectStore.getGlobalFileUrl("settings", "faviconUrl")
|
||||||
: "",
|
: "",
|
||||||
})
|
})
|
||||||
|
|
|
@ -22,12 +22,10 @@ export interface SMTPConfig extends Config {
|
||||||
config: SMTPInnerConfig
|
config: SMTPInnerConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SettingsInnerConfig {
|
/**
|
||||||
platformUrl?: string
|
* Accessible only via pro.
|
||||||
company?: string
|
*/
|
||||||
logoUrl?: string // Populated on read
|
export interface SettingsBrandingConfig {
|
||||||
logoUrlEtag?: string
|
|
||||||
|
|
||||||
faviconUrl?: string
|
faviconUrl?: string
|
||||||
faviconUrlEtag?: string
|
faviconUrlEtag?: string
|
||||||
|
|
||||||
|
@ -40,7 +38,13 @@ export interface SettingsInnerConfig {
|
||||||
metaDescription?: string
|
metaDescription?: string
|
||||||
metaImageUrl?: string
|
metaImageUrl?: string
|
||||||
metaTitle?: string
|
metaTitle?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SettingsInnerConfig {
|
||||||
|
platformUrl?: string
|
||||||
|
company?: string
|
||||||
|
logoUrl?: string // Populated on read
|
||||||
|
logoUrlEtag?: string
|
||||||
uniqueTenantId?: string
|
uniqueTenantId?: string
|
||||||
analyticsEnabled?: boolean
|
analyticsEnabled?: boolean
|
||||||
isSSOEnforced?: boolean
|
isSSOEnforced?: boolean
|
||||||
|
|
|
@ -310,7 +310,7 @@ export async function publicSettings(
|
||||||
const configDoc = await configs.getSettingsConfigDoc()
|
const configDoc = await configs.getSettingsConfigDoc()
|
||||||
const config = configDoc.config
|
const config = configDoc.config
|
||||||
|
|
||||||
const licensedConfig: object = await getLicensedConfig()
|
const branding = await pro.branding.getBrandingConfig(config)
|
||||||
|
|
||||||
// enrich the logo url - empty url means deleted
|
// enrich the logo url - empty url means deleted
|
||||||
if (config.logoUrl && config.logoUrl !== "") {
|
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(
|
config.faviconUrl = objectStore.getGlobalFileUrl(
|
||||||
"settings",
|
"settings",
|
||||||
"faviconUrl",
|
"faviconUrl",
|
||||||
config.faviconUrl
|
branding.faviconUrl
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +350,7 @@ export async function publicSettings(
|
||||||
_rev: configDoc._rev,
|
_rev: configDoc._rev,
|
||||||
config: {
|
config: {
|
||||||
...config,
|
...config,
|
||||||
...licensedConfig,
|
...branding,
|
||||||
google,
|
google,
|
||||||
oidc,
|
oidc,
|
||||||
isSSOEnforced,
|
isSSOEnforced,
|
||||||
|
|
|
@ -9,12 +9,14 @@ import { checkSlashesInUrl } from "./index"
|
||||||
import { getLicensedConfig } from "./configs"
|
import { getLicensedConfig } from "./configs"
|
||||||
|
|
||||||
const BASE_COMPANY = "Budibase"
|
const BASE_COMPANY = "Budibase"
|
||||||
|
import * as pro from "@budibase/pro"
|
||||||
|
|
||||||
export async function getSettingsTemplateContext(
|
export async function getSettingsTemplateContext(
|
||||||
purpose: EmailTemplatePurpose,
|
purpose: EmailTemplatePurpose,
|
||||||
code?: string | null
|
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 URL = settings.platformUrl
|
||||||
const context: any = {
|
const context: any = {
|
||||||
[InternalTemplateBinding.LOGO_URL]:
|
[InternalTemplateBinding.LOGO_URL]:
|
||||||
|
@ -29,12 +31,7 @@ export async function getSettingsTemplateContext(
|
||||||
[InternalTemplateBinding.CURRENT_YEAR]: new Date().getFullYear(),
|
[InternalTemplateBinding.CURRENT_YEAR]: new Date().getFullYear(),
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
context["enableEmailBranding"] = branding.emailBrandingEnabled === true
|
||||||
const config: SettingsInnerConfig = await getLicensedConfig()
|
|
||||||
context["enableEmailBranding"] = config?.emailBrandingEnabled || true
|
|
||||||
} catch (e) {
|
|
||||||
context["enableEmailBranding"] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// attach purpose specific context
|
// attach purpose specific context
|
||||||
switch (purpose) {
|
switch (purpose) {
|
||||||
|
|
Loading…
Reference in New Issue