diff --git a/packages/account-portal b/packages/account-portal
index 39acfff42a..a03225549e 160000
--- a/packages/account-portal
+++ b/packages/account-portal
@@ -1 +1 @@
-Subproject commit 39acfff42a063e5a8a7d58d36721ec3103e16348
+Subproject commit a03225549e3ce61f43d0da878da162e08941b939
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 c2fbce5747..58da310104 100644
--- a/packages/builder/src/pages/builder/portal/users/users/index.svelte
+++ b/packages/builder/src/pages/builder/portal/users/users/index.svelte
@@ -60,6 +60,7 @@
userLimitReachedModal
let searchEmail = undefined
let selectedRows = []
+ let selectedInvites = []
let bulkSaveResponse
let customRenderers = [
{ column: "email", component: EmailTableRenderer },
@@ -123,7 +124,7 @@
return {}
}
let pendingSchema = JSON.parse(JSON.stringify(tblSchema))
- pendingSchema.email.displayName = "Pending Invites"
+ pendingSchema.email.displayName = "Pending Users"
return pendingSchema
}
@@ -132,6 +133,7 @@
const { admin, builder, userGroups, apps } = invite.info
return {
+ _id: invite.code,
email: invite.email,
builder,
admin,
@@ -260,9 +262,26 @@
return
}
- await users.bulkDelete(ids)
- notifications.success(`Successfully deleted ${selectedRows.length} rows`)
+ if (ids.length > 0) {
+ await users.bulkDelete(ids)
+ }
+
+ if (selectedInvites.length > 0) {
+ await users.removeInvites(
+ selectedInvites.map(invite => ({
+ code: invite._id,
+ }))
+ )
+ pendingInvites = await users.getInvites()
+ }
+
+ notifications.success(
+ `Successfully deleted ${
+ selectedRows.length + selectedInvites.length
+ } users`
+ )
selectedRows = []
+ selectedInvites = []
await fetch.refresh()
} catch (error) {
notifications.error("Error deleting users")
@@ -328,15 +347,15 @@
{/if}
-
- {#if selectedRows.length > 0}
+ {#if selectedRows.length > 0 || selectedInvites.length > 0}
{/if}
+
({
})
},
+ /**
+ * Removes multiple user invites from Redis cache
+ */
+ removeUserInvites: async inviteCodes => {
+ return await API.post({
+ url: "/api/global/users/multi/invite/delete",
+ body: inviteCodes,
+ })
+ },
+
/**
* Accepts an invite to join the platform and creates a user.
* @param inviteCode the invite code sent in the email
diff --git a/packages/server/package.json b/packages/server/package.json
index e816ad3f18..bd5a82cb29 100644
--- a/packages/server/package.json
+++ b/packages/server/package.json
@@ -97,7 +97,7 @@
"memorystream": "0.3.1",
"mongodb": "^6.3.0",
"mssql": "10.0.1",
- "mysql2": "3.9.7",
+ "mysql2": "3.9.8",
"node-fetch": "2.6.7",
"object-sizeof": "2.6.1",
"openai": "^3.2.1",
diff --git a/packages/server/src/api/routes/tests/data/agency-client-portal.tar.gz b/packages/server/src/api/routes/tests/data/agency-client-portal.tar.gz
new file mode 100644
index 0000000000..e839dc73ee
Binary files /dev/null and b/packages/server/src/api/routes/tests/data/agency-client-portal.tar.gz differ
diff --git a/packages/server/src/api/routes/tests/templates.spec.js b/packages/server/src/api/routes/tests/templates.spec.js
deleted file mode 100644
index 1406a75c59..0000000000
--- a/packages/server/src/api/routes/tests/templates.spec.js
+++ /dev/null
@@ -1,24 +0,0 @@
-const setup = require("./utilities")
-
-describe("/templates", () => {
- let request = setup.getRequest()
- let config = setup.getConfig()
-
- afterAll(setup.afterAll)
-
- beforeAll(async () => {
- await config.init()
- })
-
- describe("fetch", () => {
- it("should be able to fetch templates", async () => {
- const res = await request
- .get(`/api/templates`)
- .set(config.defaultHeaders())
- .expect("Content-Type", /json/)
- .expect(200)
- // this test is quite light right now, templates aren't heavily utilised yet
- expect(Array.isArray(res.body)).toEqual(true)
- })
- })
-})
diff --git a/packages/server/src/api/routes/tests/templates.spec.ts b/packages/server/src/api/routes/tests/templates.spec.ts
new file mode 100644
index 0000000000..680ddb39d7
--- /dev/null
+++ b/packages/server/src/api/routes/tests/templates.spec.ts
@@ -0,0 +1,125 @@
+import * as setup from "./utilities"
+import path from "path"
+import nock from "nock"
+import { generator } from "@budibase/backend-core/tests"
+
+interface App {
+ background: string
+ icon: string
+ category: string
+ description: string
+ name: string
+ url: string
+ type: string
+ key: string
+ image: string
+}
+
+interface Manifest {
+ templates: {
+ app: { [key: string]: App }
+ }
+}
+
+function setManifest(manifest: Manifest) {
+ nock("https://prod-budi-templates.s3-eu-west-1.amazonaws.com")
+ .get("/manifest.json")
+ .reply(200, manifest)
+}
+
+function mockApp(key: string, tarPath: string) {
+ nock("https://prod-budi-templates.s3-eu-west-1.amazonaws.com")
+ .get(`/templates/app/${key}.tar.gz`)
+ .replyWithFile(200, tarPath)
+}
+
+function mockAgencyClientPortal() {
+ setManifest({
+ templates: {
+ app: {
+ "Agency Client Portal": {
+ background: "#20a3a8",
+ icon: "Project",
+ category: "Portals",
+ description:
+ "Manage clients, streamline communications, and securely share files.",
+ name: "Agency Client Portal",
+ url: "https://budibase.com/portals/templates/agency-client-portal-template/",
+ type: "app",
+ key: "app/agency-client-portal",
+ image:
+ "https://prod-budi-templates.s3.eu-west-1.amazonaws.com/images/agency-client-portal.png",
+ },
+ },
+ },
+ })
+
+ mockApp(
+ "agency-client-portal",
+ path.resolve(__dirname, "data", "agency-client-portal.tar.gz")
+ )
+}
+
+describe("/templates", () => {
+ let config = setup.getConfig()
+
+ afterAll(setup.afterAll)
+ beforeAll(async () => {
+ await config.init()
+ })
+ beforeEach(() => {
+ nock.cleanAll()
+ mockAgencyClientPortal()
+ })
+
+ describe("fetch", () => {
+ it("should be able to fetch templates", async () => {
+ const templates = await config.api.templates.fetch()
+ expect(templates).toHaveLength(1)
+ expect(templates[0].name).toBe("Agency Client Portal")
+ })
+ })
+
+ describe("create app from template", () => {
+ it.each(["sqs", "lucene"])(
+ `should be able to create an app from a template (%s)`,
+ async source => {
+ const env = {
+ SQS_SEARCH_ENABLE: source === "sqs" ? "true" : "false",
+ }
+
+ await config.withEnv(env, async () => {
+ const name = generator.guid().replaceAll("-", "")
+ const url = `/${name}`
+
+ const app = await config.api.application.create({
+ name,
+ url,
+ useTemplate: "true",
+ templateName: "Agency Client Portal",
+ templateKey: "app/agency-client-portal",
+ })
+ expect(app.name).toBe(name)
+ expect(app.url).toBe(url)
+
+ await config.withApp(app, async () => {
+ const tables = await config.api.table.fetch()
+ expect(tables).toHaveLength(2)
+
+ tables.sort((a, b) => a.name.localeCompare(b.name))
+ const [agencyProjects, users] = tables
+ expect(agencyProjects.name).toBe("Agency Projects")
+ expect(users.name).toBe("Users")
+
+ const { rows } = await config.api.row.search(agencyProjects._id!, {
+ tableId: agencyProjects._id!,
+ query: {},
+ })
+
+ expect(rows).toHaveLength(3)
+ })
+ })
+ }
+ )
+ })
+})
diff --git a/packages/server/src/integrations/tests/utils/mariadb.ts b/packages/server/src/integrations/tests/utils/mariadb.ts
index fcd79b8e56..c4dd4cf43b 100644
--- a/packages/server/src/integrations/tests/utils/mariadb.ts
+++ b/packages/server/src/integrations/tests/utils/mariadb.ts
@@ -18,7 +18,7 @@ class MariaDBWaitStrategy extends AbstractWaitStrategy {
await logs.waitUntilReady(container, boundPorts, startTime)
const command = Wait.forSuccessfulCommand(
- `mysqladmin ping -h localhost -P 3306 -u root -ppassword`
+ `/usr/local/bin/healthcheck.sh --innodb_initialized`
)
await command.waitUntilReady(container)
}
diff --git a/packages/server/src/tests/utilities/TestConfiguration.ts b/packages/server/src/tests/utilities/TestConfiguration.ts
index 58dbecd197..325d911f07 100644
--- a/packages/server/src/tests/utilities/TestConfiguration.ts
+++ b/packages/server/src/tests/utilities/TestConfiguration.ts
@@ -314,6 +314,16 @@ export default class TestConfiguration {
}
}
+ async withApp(app: App | string, f: () => Promise) {
+ const oldAppId = this.appId
+ this.appId = typeof app === "string" ? app : app.appId
+ try {
+ return await f()
+ } finally {
+ this.appId = oldAppId
+ }
+ }
+
// UTILS
_req | void, Res>(
diff --git a/packages/server/src/tests/utilities/api/index.ts b/packages/server/src/tests/utilities/api/index.ts
index d66acd86fd..554fa36588 100644
--- a/packages/server/src/tests/utilities/api/index.ts
+++ b/packages/server/src/tests/utilities/api/index.ts
@@ -12,6 +12,7 @@ import { AttachmentAPI } from "./attachment"
import { UserAPI } from "./user"
import { QueryAPI } from "./query"
import { RoleAPI } from "./role"
+import { TemplateAPI } from "./template"
export default class API {
table: TableAPI
@@ -27,6 +28,7 @@ export default class API {
user: UserAPI
query: QueryAPI
roles: RoleAPI
+ templates: TemplateAPI
constructor(config: TestConfiguration) {
this.table = new TableAPI(config)
@@ -42,5 +44,6 @@ export default class API {
this.user = new UserAPI(config)
this.query = new QueryAPI(config)
this.roles = new RoleAPI(config)
+ this.templates = new TemplateAPI(config)
}
}
diff --git a/packages/server/src/tests/utilities/api/template.ts b/packages/server/src/tests/utilities/api/template.ts
new file mode 100644
index 0000000000..6dc2a7a4da
--- /dev/null
+++ b/packages/server/src/tests/utilities/api/template.ts
@@ -0,0 +1,8 @@
+import { Template } from "@budibase/types"
+import { Expectations, TestAPI } from "./base"
+
+export class TemplateAPI extends TestAPI {
+ fetch = async (expectations?: Expectations): Promise => {
+ return await this._get("/api/templates", { expectations })
+ }
+}
diff --git a/packages/types/src/api/web/user.ts b/packages/types/src/api/web/user.ts
index f59bda133b..471ca86616 100644
--- a/packages/types/src/api/web/user.ts
+++ b/packages/types/src/api/web/user.ts
@@ -45,7 +45,12 @@ export interface InviteUserRequest {
userInfo: any
}
+export interface DeleteInviteUserRequest {
+ code: string
+}
+
export type InviteUsersRequest = InviteUserRequest[]
+export type DeleteInviteUsersRequest = DeleteInviteUserRequest[]
export interface InviteUsersResponse {
successful: { email: string }[]
diff --git a/packages/worker/src/api/controllers/global/users.ts b/packages/worker/src/api/controllers/global/users.ts
index 46bf13284e..cd69281f56 100644
--- a/packages/worker/src/api/controllers/global/users.ts
+++ b/packages/worker/src/api/controllers/global/users.ts
@@ -10,6 +10,8 @@ import {
CreateAdminUserRequest,
CreateAdminUserResponse,
Ctx,
+ DeleteInviteUserRequest,
+ DeleteInviteUsersRequest,
InviteUserRequest,
InviteUsersRequest,
InviteUsersResponse,
@@ -335,6 +337,20 @@ export const inviteMultiple = async (ctx: Ctx) => {
ctx.body = await userSdk.invite(ctx.request.body)
}
+export const removeMultipleInvites = async (
+ ctx: Ctx
+) => {
+ const inviteCodesToRemove = ctx.request.body.map(
+ (invite: DeleteInviteUserRequest) => invite.code
+ )
+ for (const code of inviteCodesToRemove) {
+ await cache.invite.deleteCode(code)
+ }
+ ctx.body = {
+ message: "User invites successfully removed.",
+ }
+}
+
export const checkInvite = async (ctx: any) => {
const { code } = ctx.params
let invite
diff --git a/packages/worker/src/api/routes/global/users.ts b/packages/worker/src/api/routes/global/users.ts
index b40c491830..0372c187f8 100644
--- a/packages/worker/src/api/routes/global/users.ts
+++ b/packages/worker/src/api/routes/global/users.ts
@@ -108,6 +108,11 @@ router
buildInviteMultipleValidation(),
controller.inviteMultiple
)
+ .post(
+ "/api/global/users/multi/invite/delete",
+ auth.builderOrAdmin,
+ controller.removeMultipleInvites
+ )
// non-global endpoints
.get("/api/global/users/invite/:code", controller.checkInvite)
diff --git a/yarn.lock b/yarn.lock
index 677b7cb441..9daf499918 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -11904,6 +11904,17 @@ glob@^10.0.0, glob@^10.2.2:
minipass "^7.0.4"
path-scurry "^1.10.2"
+glob@^10.3.7:
+ version "10.4.1"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.1.tgz#0cfb01ab6a6b438177bfe6a58e2576f6efe909c2"
+ integrity sha512-2jelhlq3E4ho74ZyVLN03oKdAZVUa6UDZzFLVH1H7dnoax+y9qyaq8zBkfDIggjniU19z0wU18y16jMB2eyVIw==
+ dependencies:
+ foreground-child "^3.1.0"
+ jackspeak "^3.1.2"
+ minimatch "^9.0.4"
+ minipass "^7.1.2"
+ path-scurry "^1.11.1"
+
glob@^5.0.15:
version "5.0.15"
resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1"
@@ -13472,6 +13483,15 @@ jackspeak@^2.3.6:
optionalDependencies:
"@pkgjs/parseargs" "^0.11.0"
+jackspeak@^3.1.2:
+ version "3.1.2"
+ resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-3.1.2.tgz#eada67ea949c6b71de50f1b09c92a961897b90ab"
+ integrity sha512-kWmLKn2tRtfYMF/BakihVVRzBKOxz4gJMiL2Rj91WnAB5TPZumSH99R/Yf1qE1u4uRimvCSJfm6hnxohXeEXjQ==
+ dependencies:
+ "@isaacs/cliui" "^8.0.2"
+ optionalDependencies:
+ "@pkgjs/parseargs" "^0.11.0"
+
jake@^10.8.5:
version "10.8.5"
resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.5.tgz#f2183d2c59382cb274226034543b9c03b8164c46"
@@ -15751,6 +15771,13 @@ minimatch@^8.0.2:
dependencies:
brace-expansion "^2.0.1"
+minimatch@^9.0.4:
+ version "9.0.4"
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.4.tgz#8e49c731d1749cbec05050ee5145147b32496a51"
+ integrity sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==
+ dependencies:
+ brace-expansion "^2.0.1"
+
minimist-options@4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-4.1.0.tgz#c0655713c53a8a2ebd77ffa247d342c40f010619"
@@ -15845,6 +15872,11 @@ minipass@^5.0.0:
resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.0.4.tgz#dbce03740f50a4786ba994c1fb908844d27b038c"
integrity sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==
+minipass@^7.1.2:
+ version "7.1.2"
+ resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.1.2.tgz#93a9626ce5e5e66bd4db86849e7515e92340a707"
+ integrity sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==
+
minizlib@^2.1.1, minizlib@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-2.1.2.tgz#e90d3466ba209b932451508a11ce3d3632145931"
@@ -17378,6 +17410,14 @@ path-scurry@^1.10.2, path-scurry@^1.6.1:
lru-cache "^10.2.0"
minipass "^5.0.0 || ^6.0.2 || ^7.0.0"
+path-scurry@^1.11.1:
+ version "1.11.1"
+ resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.11.1.tgz#7960a668888594a0720b12a911d1a742ab9f11d2"
+ integrity sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==
+ dependencies:
+ lru-cache "^10.2.0"
+ minipass "^5.0.0 || ^6.0.2 || ^7.0.0"
+
path-to-regexp@1.x:
version "1.8.0"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a"
@@ -19318,6 +19358,13 @@ rimraf@^4.4.1:
dependencies:
glob "^9.2.0"
+rimraf@^5.0.7:
+ version "5.0.7"
+ resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-5.0.7.tgz#27bddf202e7d89cb2e0381656380d1734a854a74"
+ integrity sha512-nV6YcJo5wbLW77m+8KjH8aB/7/rxQy9SZ0HY5shnwULfS+9nmTtVXAJET5NdZmCzA4fPI/Hm1wo/Po/4mopOdg==
+ dependencies:
+ glob "^10.3.7"
+
ripemd160@^2.0.0, ripemd160@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c"