Merge branch 'master' of github.com:Budibase/budibase into fix/rest-download-issue

This commit is contained in:
mike12345567 2024-06-03 10:13:49 +01:00
commit 7b8195f41d
7 changed files with 69 additions and 7 deletions

View File

@ -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
}
if (ids.length > 0) {
await users.bulkDelete(ids)
notifications.success(`Successfully deleted ${selectedRows.length} rows`)
}
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 @@
</div>
{/if}
<div class="controls-right">
<Search bind:value={searchEmail} placeholder="Search" />
{#if selectedRows.length > 0}
{#if selectedRows.length > 0 || selectedInvites.length > 0}
<DeleteRowsButton
item="user"
on:updaterows
{selectedRows}
selectedRows={[...selectedRows, ...selectedInvites]}
deleteRows={deleteUsers}
/>
{/if}
<Search bind:value={searchEmail} placeholder="Search" />
</div>
</div>
<Table
@ -362,10 +381,12 @@
</div>
<Table
bind:selectedRows={selectedInvites}
schema={pendingSchema}
data={parsedInvites}
allowEditColumns={false}
allowEditRows={false}
allowSelectRows={!readonly}
{customRenderers}
loading={!invitesLoaded}
allowClickRows={false}

View File

@ -38,6 +38,10 @@ export function createUsersStore() {
return API.inviteUsers(payload)
}
async function removeInvites(payload) {
return API.removeUserInvites(payload)
}
async function acceptInvite(inviteCode, password, firstName, lastName) {
return API.acceptInvite({
inviteCode,
@ -154,6 +158,7 @@ export function createUsersStore() {
onboard,
fetchInvite,
getInvites,
removeInvites,
updateInvite,
getUserCountByApp,
addAppBuilder,

View File

@ -234,6 +234,16 @@ export const buildUserEndpoints = API => ({
})
},
/**
* 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

View File

@ -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)
}

View File

@ -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 }[]

View File

@ -10,6 +10,8 @@ import {
CreateAdminUserRequest,
CreateAdminUserResponse,
Ctx,
DeleteInviteUserRequest,
DeleteInviteUsersRequest,
InviteUserRequest,
InviteUsersRequest,
InviteUsersResponse,
@ -335,6 +337,20 @@ export const inviteMultiple = async (ctx: Ctx<InviteUsersRequest>) => {
ctx.body = await userSdk.invite(ctx.request.body)
}
export const removeMultipleInvites = async (
ctx: Ctx<DeleteInviteUsersRequest>
) => {
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

View File

@ -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)