From 92f9501d26cb3dcde5a747b6889a231e36c2aaad Mon Sep 17 00:00:00 2001 From: Conor Webb <126772285+ConorWebb96@users.noreply.github.com> Date: Mon, 17 Jun 2024 08:21:26 +0100 Subject: [PATCH 1/3] Add function to close side panel based on the browser's history. (#13944) * Add function to close side panel based on the browser's history. * Switched to hashchange, removed from SidePanel, added to ClientApp.svelte * Removed unused onMount, fixed lint issue * Removed unnecessary if statement. --- packages/client/src/components/ClientApp.svelte | 11 +++++++++++ packages/client/src/components/app/SidePanel.svelte | 4 ---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/client/src/components/ClientApp.svelte b/packages/client/src/components/ClientApp.svelte index b790ecd0d4..c1bdc92ac4 100644 --- a/packages/client/src/components/ClientApp.svelte +++ b/packages/client/src/components/ClientApp.svelte @@ -19,6 +19,7 @@ devToolsStore, devToolsEnabled, environmentStore, + sidePanelStore, } from "stores" import NotificationDisplay from "components/overlay/NotificationDisplay.svelte" import ConfirmationDisplay from "components/overlay/ConfirmationDisplay.svelte" @@ -102,6 +103,16 @@ embedded: !!$appStore.embedded, }) } + const handleHashChange = () => { + const { open } = $sidePanelStore + if (open) { + sidePanelStore.actions.close() + } + } + window.addEventListener("hashchange", handleHashChange) + return () => { + window.removeEventListener("hashchange", handleHashChange) + } }) $: { diff --git a/packages/client/src/components/app/SidePanel.svelte b/packages/client/src/components/app/SidePanel.svelte index bff5a78837..d49ab33c40 100644 --- a/packages/client/src/components/app/SidePanel.svelte +++ b/packages/client/src/components/app/SidePanel.svelte @@ -29,10 +29,6 @@ } } - // $: { - - // } - // Derive visibility $: open = $sidePanelStore.contentId === $component.id From 7601cd0ce29d7022fd9aad06b2bf949b39a99262 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 17 Jun 2024 09:11:47 +0000 Subject: [PATCH 2/3] Bump version to 2.28.7 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 70d6a683e0..abce1679c8 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.28.6", + "version": "2.28.7", "npmClient": "yarn", "packages": [ "packages/*", From 9ecf82e0f6e034df559c35331027367111952bb6 Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:22:44 +0100 Subject: [PATCH 3/3] Add endpoint to GET tenant info from tenant global DB. (#13923) * Add GET tenant info endpoint * Add GET global tenant to endpoint list. * Use correct not found code * Fix unit test * Code review comments * Ignore account portal check types * remove account-portal-ui from type check ignore * Remove ignore account-portal-ui from type check --- .github/workflows/budibase_ci.yml | 4 ++-- package.json | 2 +- packages/backend-core/src/tenancy/db.ts | 7 ++++++- packages/types/src/documents/global/tenantInfo.ts | 2 ++ .../worker/src/api/controllers/global/tenant.ts | 4 ++++ packages/worker/src/api/index.ts | 4 ++++ packages/worker/src/api/routes/global/tenant.ts | 15 +++++++++------ .../src/api/routes/global/tests/tenant.spec.ts | 3 ++- 8 files changed, 30 insertions(+), 11 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index eb11627758..b7dbcae771 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -73,9 +73,9 @@ jobs: - name: Check types run: | if ${{ env.USE_NX_AFFECTED }}; then - yarn check:types --since=${{ env.NX_BASE_BRANCH }} + yarn check:types --since=${{ env.NX_BASE_BRANCH }} --ignore @budibase/account-portal-server else - yarn check:types + yarn check:types --ignore @budibase/account-portal-server fi helm-lint: diff --git a/package.json b/package.json index 5377dfc5a1..e05eb795bc 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "build:oss": "NODE_OPTIONS=--max-old-space-size=1500 lerna run build --stream --ignore @budibase/account-portal-server --ignore @budibase/account-portal-ui", "build:account-portal": "NODE_OPTIONS=--max-old-space-size=1500 lerna run build --stream --scope @budibase/account-portal-server --scope @budibase/account-portal-ui", "build:dev": "lerna run --stream prebuild && yarn nx run-many --target=build --output-style=dynamic --watch --preserveWatchOutput", - "check:types": "lerna run --concurrency 2 check:types", + "check:types": "lerna run --concurrency 2 check:types --ignore @budibase/account-portal-server", "build:sdk": "lerna run --stream build:sdk", "deps:circular": "madge packages/server/dist/index.js packages/worker/src/index.ts packages/backend-core/dist/src/index.js packages/cli/src/index.js --circular", "release": "lerna publish from-package --yes --force-publish --no-git-tag-version --no-push --no-git-reset", diff --git a/packages/backend-core/src/tenancy/db.ts b/packages/backend-core/src/tenancy/db.ts index f2e4705fa8..d430296a5c 100644 --- a/packages/backend-core/src/tenancy/db.ts +++ b/packages/backend-core/src/tenancy/db.ts @@ -9,8 +9,13 @@ export function getTenantDB(tenantId: string) { export async function saveTenantInfo(tenantInfo: TenantInfo) { const db = getTenantDB(tenantInfo.tenantId) // save the tenant info to db - return await db.put({ + return db.put({ _id: "tenant_info", ...tenantInfo, }) } + +export async function getTenantInfo(tenantId: string): Promise { + const db = getTenantDB(tenantId) + return db.get("tenant_info") +} diff --git a/packages/types/src/documents/global/tenantInfo.ts b/packages/types/src/documents/global/tenantInfo.ts index 2fa8f4ad96..4c8837cf2a 100644 --- a/packages/types/src/documents/global/tenantInfo.ts +++ b/packages/types/src/documents/global/tenantInfo.ts @@ -1,3 +1,4 @@ +import { Hosting } from "../../sdk" import { Document } from "../document" export interface TenantInfo extends Document { @@ -10,4 +11,5 @@ export interface TenantInfo extends Document { budibaseUserId?: string } tenantId: string + hosting: Hosting } diff --git a/packages/worker/src/api/controllers/global/tenant.ts b/packages/worker/src/api/controllers/global/tenant.ts index 1e86fb8246..8b5ae6d528 100644 --- a/packages/worker/src/api/controllers/global/tenant.ts +++ b/packages/worker/src/api/controllers/global/tenant.ts @@ -8,3 +8,7 @@ export const save = async (ctx: Ctx) => { _rev: response.rev, } } + +export const get = async (ctx: Ctx) => { + ctx.body = await tenancy.getTenantInfo(ctx.params.id) +} diff --git a/packages/worker/src/api/index.ts b/packages/worker/src/api/index.ts index feec8b4de1..08c65b98d4 100644 --- a/packages/worker/src/api/index.ts +++ b/packages/worker/src/api/index.ts @@ -129,6 +129,10 @@ const NO_TENANCY_ENDPOINTS = [ route: "/api/global/tenant", method: "POST", }, + { + route: "/api/global/tenant/:id", + method: "GET", + }, ] // most public endpoints are gets, but some are posts diff --git a/packages/worker/src/api/routes/global/tenant.ts b/packages/worker/src/api/routes/global/tenant.ts index 7179532cde..18b7058c34 100644 --- a/packages/worker/src/api/routes/global/tenant.ts +++ b/packages/worker/src/api/routes/global/tenant.ts @@ -18,16 +18,19 @@ function buildTenantInfoValidation() { familyName: OPTIONAL_STRING, budibaseUserId: OPTIONAL_STRING, }).required(), + hosting: Joi.string().required(), tenantId: Joi.string().required(), }).required() ) } -router.post( - "/api/global/tenant", - cloudRestricted, - buildTenantInfoValidation(), - controller.save -) +router + .post( + "/api/global/tenant", + cloudRestricted, + buildTenantInfoValidation(), + controller.save + ) + .get("/api/global/tenant/:id", controller.get) export default router diff --git a/packages/worker/src/api/routes/global/tests/tenant.spec.ts b/packages/worker/src/api/routes/global/tests/tenant.spec.ts index 36036eceee..e039b4139b 100644 --- a/packages/worker/src/api/routes/global/tests/tenant.spec.ts +++ b/packages/worker/src/api/routes/global/tests/tenant.spec.ts @@ -1,4 +1,4 @@ -import { TenantInfo } from "@budibase/types" +import { Hosting, TenantInfo } from "@budibase/types" import { TestConfiguration } from "../../../../tests" import { tenancy as _tenancy } from "@budibase/backend-core" @@ -36,6 +36,7 @@ describe("/api/global/tenant", () => { budibaseUserId: "USER_ID", }, tenantId: "tenant123", + hosting: Hosting.CLOUD, } const response = await config.api.tenants.saveTenantInfo(tenantInfo)