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 userLimitReachedModal
let searchEmail = undefined let searchEmail = undefined
let selectedRows = [] let selectedRows = []
let selectedInvites = []
let bulkSaveResponse let bulkSaveResponse
let customRenderers = [ let customRenderers = [
{ column: "email", component: EmailTableRenderer }, { column: "email", component: EmailTableRenderer },
@ -123,7 +124,7 @@
return {} return {}
} }
let pendingSchema = JSON.parse(JSON.stringify(tblSchema)) let pendingSchema = JSON.parse(JSON.stringify(tblSchema))
pendingSchema.email.displayName = "Pending Invites" pendingSchema.email.displayName = "Pending Users"
return pendingSchema return pendingSchema
} }
@ -132,6 +133,7 @@
const { admin, builder, userGroups, apps } = invite.info const { admin, builder, userGroups, apps } = invite.info
return { return {
_id: invite.code,
email: invite.email, email: invite.email,
builder, builder,
admin, admin,
@ -260,9 +262,26 @@
return return
} }
await users.bulkDelete(ids) if (ids.length > 0) {
notifications.success(`Successfully deleted ${selectedRows.length} rows`) 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 = [] selectedRows = []
selectedInvites = []
await fetch.refresh() await fetch.refresh()
} catch (error) { } catch (error) {
notifications.error("Error deleting users") notifications.error("Error deleting users")
@ -328,15 +347,15 @@
</div> </div>
{/if} {/if}
<div class="controls-right"> <div class="controls-right">
<Search bind:value={searchEmail} placeholder="Search" /> {#if selectedRows.length > 0 || selectedInvites.length > 0}
{#if selectedRows.length > 0}
<DeleteRowsButton <DeleteRowsButton
item="user" item="user"
on:updaterows on:updaterows
{selectedRows} selectedRows={[...selectedRows, ...selectedInvites]}
deleteRows={deleteUsers} deleteRows={deleteUsers}
/> />
{/if} {/if}
<Search bind:value={searchEmail} placeholder="Search" />
</div> </div>
</div> </div>
<Table <Table
@ -362,10 +381,12 @@
</div> </div>
<Table <Table
bind:selectedRows={selectedInvites}
schema={pendingSchema} schema={pendingSchema}
data={parsedInvites} data={parsedInvites}
allowEditColumns={false} allowEditColumns={false}
allowEditRows={false} allowEditRows={false}
allowSelectRows={!readonly}
{customRenderers} {customRenderers}
loading={!invitesLoaded} loading={!invitesLoaded}
allowClickRows={false} allowClickRows={false}

View File

@ -38,6 +38,10 @@ export function createUsersStore() {
return API.inviteUsers(payload) return API.inviteUsers(payload)
} }
async function removeInvites(payload) {
return API.removeUserInvites(payload)
}
async function acceptInvite(inviteCode, password, firstName, lastName) { async function acceptInvite(inviteCode, password, firstName, lastName) {
return API.acceptInvite({ return API.acceptInvite({
inviteCode, inviteCode,
@ -154,6 +158,7 @@ export function createUsersStore() {
onboard, onboard,
fetchInvite, fetchInvite,
getInvites, getInvites,
removeInvites,
updateInvite, updateInvite,
getUserCountByApp, getUserCountByApp,
addAppBuilder, 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. * Accepts an invite to join the platform and creates a user.
* @param inviteCode the invite code sent in the email * @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) await logs.waitUntilReady(container, boundPorts, startTime)
const command = Wait.forSuccessfulCommand( const command = Wait.forSuccessfulCommand(
`mysqladmin ping -h localhost -P 3306 -u root -ppassword` `/usr/local/bin/healthcheck.sh --innodb_initialized`
) )
await command.waitUntilReady(container) await command.waitUntilReady(container)
} }

View File

@ -45,7 +45,12 @@ export interface InviteUserRequest {
userInfo: any userInfo: any
} }
export interface DeleteInviteUserRequest {
code: string
}
export type InviteUsersRequest = InviteUserRequest[] export type InviteUsersRequest = InviteUserRequest[]
export type DeleteInviteUsersRequest = DeleteInviteUserRequest[]
export interface InviteUsersResponse { export interface InviteUsersResponse {
successful: { email: string }[] successful: { email: string }[]

View File

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

View File

@ -108,6 +108,11 @@ router
buildInviteMultipleValidation(), buildInviteMultipleValidation(),
controller.inviteMultiple controller.inviteMultiple
) )
.post(
"/api/global/users/multi/invite/delete",
auth.builderOrAdmin,
controller.removeMultipleInvites
)
// non-global endpoints // non-global endpoints
.get("/api/global/users/invite/:code", controller.checkInvite) .get("/api/global/users/invite/:code", controller.checkInvite)