From 2546346f3645d1d103dfb40d2262ea41bbba72cd Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 14 Dec 2020 15:56:33 +0000 Subject: [PATCH] Adding the ability to change default logo URL for new apps in self hosting. --- hosting/docker-compose.yml | 3 ++- hosting/hosting.properties | 2 +- packages/server/src/constants/layouts.js | 5 +++-- packages/server/src/constants/screens.js | 4 ++-- packages/server/src/environment.js | 1 + packages/server/src/utilities/index.js | 13 +++++++++++++ 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/hosting/docker-compose.yml b/hosting/docker-compose.yml index 1b1f608f91..13102a28d1 100644 --- a/hosting/docker-compose.yml +++ b/hosting/docker-compose.yml @@ -10,9 +10,10 @@ services: environment: MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY} MINIO_SECRET_KEY: ${MINIO_SECRET_KEY} - SELF_HOSTED: ${SELF_HOSTED} + SELF_HOSTED: 1 COUCH_DB_URL: http://${COUCH_DB_USER}:${COUCH_DB_PASSWORD}@couchdb-service:5984 BUDIBASE_ENVIRONMENT: ${BUDIBASE_ENVIRONMENT} + LOGO_URL: ${LOGO_URL} depends_on: - nginx-service - minio-service diff --git a/hosting/hosting.properties b/hosting/hosting.properties index cf818d0eb3..8ffe9f1473 100644 --- a/hosting/hosting.properties +++ b/hosting/hosting.properties @@ -1,6 +1,6 @@ -SELF_HOSTED=1 MINIO_ACCESS_KEY=budibase MINIO_SECRET_KEY=budibase COUCH_DB_PASSWORD=budibase COUCH_DB_USER=budibase BUDIBASE_ENVIRONMENT=PRODUCTION +LOGO_URL=https://logoipsum.com/logo/logo-15.svg diff --git a/packages/server/src/constants/layouts.js b/packages/server/src/constants/layouts.js index f2ad5b2675..2472e3289e 100644 --- a/packages/server/src/constants/layouts.js +++ b/packages/server/src/constants/layouts.js @@ -1,3 +1,5 @@ +const { getLogoUrl } = require("../utilities") + const BASE_LAYOUT_PROP_IDS = { PRIVATE: "layout_private_master", PUBLIC: "layout_public_master", @@ -88,8 +90,7 @@ const BASE_LAYOUTS = [ active: {}, selected: {}, }, - logoUrl: - "https://d33wubrfki0l68.cloudfront.net/aac32159d7207b5085e74a7ef67afbb7027786c5/2b1fd/img/logo/bb-emblem.svg", + logoUrl: getLogoUrl(), title: "", backgroundColor: "", color: "", diff --git a/packages/server/src/constants/screens.js b/packages/server/src/constants/screens.js index e08eaa8195..a1a96c994f 100644 --- a/packages/server/src/constants/screens.js +++ b/packages/server/src/constants/screens.js @@ -1,5 +1,6 @@ const { BUILTIN_ROLE_IDS } = require("../utilities/security/roles") const { BASE_LAYOUT_PROP_IDS } = require("./layouts") +const { getLogoUrl } = require("../utilities") exports.createHomeScreen = () => ({ description: "", @@ -138,8 +139,7 @@ exports.createLoginScreen = app => ({ active: {}, selected: {}, }, - logo: - "https://d33wubrfki0l68.cloudfront.net/aac32159d7207b5085e74a7ef67afbb7027786c5/2b1fd/img/logo/bb-emblem.svg", + logo: getLogoUrl(), title: `Log in to ${app.name}`, buttonText: "Log In", _children: [], diff --git a/packages/server/src/environment.js b/packages/server/src/environment.js index 0c67f8c747..cca3c4fbac 100644 --- a/packages/server/src/environment.js +++ b/packages/server/src/environment.js @@ -39,6 +39,7 @@ module.exports = { // self hosting features MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY, MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY, + LOGO_URL: process.env.LOGO_URL, _set(key, value) { process.env[key] = value module.exports[key] = value diff --git a/packages/server/src/utilities/index.js b/packages/server/src/utilities/index.js index 8a43e9d27a..c8e2e57bff 100644 --- a/packages/server/src/utilities/index.js +++ b/packages/server/src/utilities/index.js @@ -168,3 +168,16 @@ exports.coerceRowValues = (row, table) => { } return clonedRow } + +/** + * Gets the correct link to the logo URL depending on if running in Cloud or if running in self hosting. + * @returns {string} A URL which links to the correct default logo for new apps. + */ +exports.getLogoUrl = () => { + const BB_LOGO_URL = + "https://d33wubrfki0l68.cloudfront.net/aac32159d7207b5085e74a7ef67afbb7027786c5/2b1fd/img/logo/bb-emblem.svg" + if (env.SELF_HOSTED) { + return env.LOGO_URL || BB_LOGO_URL + } + return BB_LOGO_URL +}