From a8747a0b6d2658070fb21fdaf770f480656c19e6 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Thu, 15 Sep 2022 14:23:25 +0100 Subject: [PATCH] Ignore empty name validation on app update and change free logo text --- ...{MadeInBudibase.svelte => FreeLogo.svelte} | 2 +- .../client/src/components/app/Layout.svelte | 4 +-- packages/server/src/api/routes/application.ts | 2 +- .../server/src/api/routes/utils/validators.js | 30 +++++++++++++++---- 4 files changed, 29 insertions(+), 9 deletions(-) rename packages/client/src/components/{MadeInBudibase.svelte => FreeLogo.svelte} (96%) diff --git a/packages/client/src/components/MadeInBudibase.svelte b/packages/client/src/components/FreeLogo.svelte similarity index 96% rename from packages/client/src/components/MadeInBudibase.svelte rename to packages/client/src/components/FreeLogo.svelte index ef31a9cfb5..2a5a936cdb 100644 --- a/packages/client/src/components/MadeInBudibase.svelte +++ b/packages/client/src/components/FreeLogo.svelte @@ -8,7 +8,7 @@ >
Budibase -

Made In Budibase

+

Made with Budibase

diff --git a/packages/client/src/components/app/Layout.svelte b/packages/client/src/components/app/Layout.svelte index 7897782b3e..a317da1f0f 100644 --- a/packages/client/src/components/app/Layout.svelte +++ b/packages/client/src/components/app/Layout.svelte @@ -5,7 +5,7 @@ import { FieldTypes } from "constants" import active from "svelte-spa-router/active" import { RoleUtils } from "@budibase/frontend-core" - import MadeInBudibase from "../MadeInBudibase.svelte" + import FreeLogo from "../FreeLogo.svelte" import licensing from "../../licensing" const sdk = getContext("sdk") @@ -236,7 +236,7 @@ {/if} {#if !$builderStore.inBuilder && licensing.logoEnabled() && $environmentStore.cloud} - + {/if}
diff --git a/packages/server/src/api/routes/application.ts b/packages/server/src/api/routes/application.ts index 0ebdf548e3..8627dd024c 100644 --- a/packages/server/src/api/routes/application.ts +++ b/packages/server/src/api/routes/application.ts @@ -20,7 +20,7 @@ router .put( "/api/applications/:appId", authorized(BUILDER), - applicationValidator(), + applicationValidator({ isCreate: false }), controller.update ) .post( diff --git a/packages/server/src/api/routes/utils/validators.js b/packages/server/src/api/routes/utils/validators.js index 000c9655bc..ab9f2afaf0 100644 --- a/packages/server/src/api/routes/utils/validators.js +++ b/packages/server/src/api/routes/utils/validators.js @@ -210,15 +210,35 @@ exports.automationValidator = (existing = false) => { }).unknown(true)) } -exports.applicationValidator = () => { +exports.applicationValidator = (opts = { isCreate: true }) => { // prettier-ignore - return joiValidator.body(Joi.object({ + const base = { _id: OPTIONAL_STRING, _rev: OPTIONAL_STRING, - name: Joi.string().pattern(new RegExp(APP_NAME_REGEX)).required().error(new Error('App name must be letters, numbers and spaces only')), url: OPTIONAL_STRING, template: Joi.object({ templateString: OPTIONAL_STRING, - }).unknown(true), - }).unknown(true)) + }) + } + + const appNameValidator = Joi.string() + .pattern(new RegExp(APP_NAME_REGEX)) + .error(new Error("App name must be letters, numbers and spaces only")) + if (opts.isCreate) { + base.name = appNameValidator.required() + } else { + base.name = appNameValidator.optional() + } + + return joiValidator.body( + Joi.object({ + _id: OPTIONAL_STRING, + _rev: OPTIONAL_STRING, + name: appNameValidator, + url: OPTIONAL_STRING, + template: Joi.object({ + templateString: OPTIONAL_STRING, + }).unknown(true), + }).unknown(true) + ) }