From c7646afde008dc16569b6b0cc57721fb888b7aae Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 30 Oct 2024 14:23:58 +0000 Subject: [PATCH 1/6] Adding a change to nodemon configuration, this stops the services restarting twice when a build is triggered. --- packages/server/nodemon.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/nodemon.json b/packages/server/nodemon.json index 3b3d9aa46d..b0e792d945 100644 --- a/packages/server/nodemon.json +++ b/packages/server/nodemon.json @@ -8,6 +8,6 @@ "../string-templates" ], "ext": "js,ts,json,svelte", - "ignore": ["**/*.spec.ts", "**/*.spec.js", "../*/dist/**/*"], + "ignore": ["**/*.spec.ts", "**/*.spec.js", "../*/dist/**/*", "client/**/*", "builder/**/*"], "exec": "yarn build && node --no-node-snapshot ./dist/index.js" } From e235de54adfbe80ac136ef4af75d4417878dbe78 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 30 Oct 2024 17:32:39 +0000 Subject: [PATCH 2/6] Fixing an issue with serving the builder, increased error rate due to requests that hit the / endpoint, these were 500ing due to a lack of app ID. --- .../server/src/api/controllers/static/index.ts | 11 +++++++++++ .../server/src/api/routes/tests/static.spec.ts | 18 ++++++++++++++++++ .../src/sdk/app/applications/applications.ts | 8 +++++--- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/packages/server/src/api/controllers/static/index.ts b/packages/server/src/api/controllers/static/index.ts index 1d04811019..b90d24c9b1 100644 --- a/packages/server/src/api/controllers/static/index.ts +++ b/packages/server/src/api/controllers/static/index.ts @@ -6,6 +6,7 @@ import { ObjectStoreBuckets } from "../../../constants" import { processString } from "@budibase/string-templates" import { loadHandlebarsFile, + streamFile, NODE_MODULES_PATH, shouldServeLocally, TOP_LEVEL_PATH, @@ -145,6 +146,16 @@ const requiresMigration = async (ctx: Ctx) => { } export const serveApp = async function (ctx: UserCtx) { + if (ctx.url.includes("apple-touch-icon")) { + ctx.redirect("/builder/bblogo.png") + return + } + // no app ID found, cannot serve - return message instead + if (!context.getAppId()) { + ctx.body = "No content found - requires app ID" + return + } + const needMigrations = await requiresMigration(ctx) const bbHeaderEmbed = diff --git a/packages/server/src/api/routes/tests/static.spec.ts b/packages/server/src/api/routes/tests/static.spec.ts index 62b72b2b8f..c2808603e9 100644 --- a/packages/server/src/api/routes/tests/static.spec.ts +++ b/packages/server/src/api/routes/tests/static.spec.ts @@ -152,4 +152,22 @@ describe("/static", () => { expect(res.body.builderPreview).toBe(true) }) }) + + describe("/", () => { + it("should move permanently from base call (public call)", async () => { + const res = await request.get(`/`) + expect(res.status).toEqual(301) + expect(res.text).toEqual( + `Redirecting to /builder.` + ) + }) + + it("should not error when trying to get 'apple-touch-icon.png' (public call)", async () => { + const res = await request.get(`/apple-touch-icon.png`) + expect(res.status).toEqual(302) + expect(res.text).toEqual( + `Redirecting to /builder/bblogo.png.` + ) + }) + }) }) diff --git a/packages/server/src/sdk/app/applications/applications.ts b/packages/server/src/sdk/app/applications/applications.ts index 07e303ccdd..1a705a211e 100644 --- a/packages/server/src/sdk/app/applications/applications.ts +++ b/packages/server/src/sdk/app/applications/applications.ts @@ -25,10 +25,12 @@ export async function fetch(status: AppStatus, user: ContextUser) { const all = status === AppStatus.ALL let apps = (await dbCore.getAllApps({ dev, all })) as App[] - const enrichedUser = await groups.enrichUserRolesFromGroups({ + // need to type this correctly - add roles back in to convert from ContextUser to User + const completeUser: User = { ...user, - roles: user.roles || {}, - }) + roles: user?.roles || {}, + } + const enrichedUser = await groups.enrichUserRolesFromGroups(completeUser) apps = filterAppList(enrichedUser, apps) const appIds = apps From dc1389b8fbc1a7e281dc85db4a45b64d613cf8db Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 30 Oct 2024 17:39:48 +0000 Subject: [PATCH 3/6] PR comment and linting. --- packages/server/src/api/controllers/static/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/server/src/api/controllers/static/index.ts b/packages/server/src/api/controllers/static/index.ts index b90d24c9b1..daf7b9b25c 100644 --- a/packages/server/src/api/controllers/static/index.ts +++ b/packages/server/src/api/controllers/static/index.ts @@ -6,7 +6,6 @@ import { ObjectStoreBuckets } from "../../../constants" import { processString } from "@budibase/string-templates" import { loadHandlebarsFile, - streamFile, NODE_MODULES_PATH, shouldServeLocally, TOP_LEVEL_PATH, @@ -146,7 +145,7 @@ const requiresMigration = async (ctx: Ctx) => { } export const serveApp = async function (ctx: UserCtx) { - if (ctx.url.includes("apple-touch-icon")) { + if (ctx.url.includes("apple-touch-icon.png")) { ctx.redirect("/builder/bblogo.png") return } From 41807e87b305019eb6380690160c08ee25d3b940 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Thu, 31 Oct 2024 08:44:36 +0000 Subject: [PATCH 4/6] Don't throw if no account-holder is found --- .../src/api/controllers/global/users.ts | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/worker/src/api/controllers/global/users.ts b/packages/worker/src/api/controllers/global/users.ts index 52f8821fab..fa19948bf5 100644 --- a/packages/worker/src/api/controllers/global/users.ts +++ b/packages/worker/src/api/controllers/global/users.ts @@ -312,16 +312,21 @@ export const tenantUserLookup = async (ctx: any) => { * So the account holder may not be found until further pagination has occurred */ export const accountHolderLookup = async (ctx: Ctx) => { - const users = await userSdk.core.getAllUsers() - const response = await userSdk.core.getExistingAccounts( - users.map(u => u.email) - ) - const holder = response[0] - if (!holder) { - return + try { + const users = await userSdk.core.getAllUsers() + const response = await userSdk.core.getExistingAccounts( + users.map(u => u.email) + ) + const holder = response[0] + if (!holder) { + ctx.body = null + return + } + holder._id = users.find(u => u.email === holder.email)?._id + ctx.body = holder + } catch (e) { + ctx.body = null } - holder._id = users.find(u => u.email === holder.email)?._id - ctx.body = holder } /* From eba7f015782ef8f02f26cdc082d37232f66320a0 Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Thu, 31 Oct 2024 08:51:46 +0000 Subject: [PATCH 5/6] Improve users sort (#14894) --- .../builder/src/pages/builder/portal/users/users/index.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/pages/builder/portal/users/users/index.svelte b/packages/builder/src/pages/builder/portal/users/users/index.svelte index 9ecb42b6d3..9c4e8f70c7 100644 --- a/packages/builder/src/pages/builder/portal/users/users/index.svelte +++ b/packages/builder/src/pages/builder/portal/users/users/index.svelte @@ -406,7 +406,7 @@ allowSelectRows={!readonly} {customRenderers} loading={!$fetch.loaded || !groupsLoaded} - defaultSortColumn={"__selectable"} + defaultSortColumn={"access"} />