add api for per app builder and help function

This commit is contained in:
Peter Clement 2023-08-24 11:38:12 +01:00
parent 3dea081fdf
commit 8d5f6cf7af
3 changed files with 31 additions and 0 deletions

View File

@ -250,4 +250,26 @@ export const buildUserEndpoints = API => ({
url: `/api/global/users/count/${appId}`, url: `/api/global/users/count/${appId}`,
}) })
}, },
/**
* Adds a per app builder to the selected app
* @param appId the applications id
* @param userId The id of the user to add as a builder
*/
addAppBuilder: async ({ userId, appId }) => {
return await API.post({
url: `/api/global/users/${userId}/app/${appId}/builder`,
})
},
/**
* Removes a per app builder to the selected app
* @param appId the applications id
* @param userId The id of the user to remove as a builder
*/
removeAppBuilder: async ({ userId, appId }) => {
return await API.delete({
url: `/api/global/users/${userId}/app/${appId}/builder`,
})
},
}) })

View File

@ -71,6 +71,7 @@ export const Features = {
BRANDING: "branding", BRANDING: "branding",
SCIM: "scim", SCIM: "scim",
SYNC_AUTOMATIONS: "syncAutomations", SYNC_AUTOMATIONS: "syncAutomations",
APP_BUILDERS: "appBuilders",
} }
// Role IDs // Role IDs
@ -80,6 +81,7 @@ export const Roles = {
BASIC: "BASIC", BASIC: "BASIC",
PUBLIC: "PUBLIC", PUBLIC: "PUBLIC",
BUILDER: "BUILDER", BUILDER: "BUILDER",
CREATOR: "CREATOR",
} }
export const Themes = [ export const Themes = [

View File

@ -35,6 +35,13 @@ export function isAdminOrBuilder(
return isBuilder(user, appId) || isAdmin(user) return isBuilder(user, appId) || isAdmin(user)
} }
export function isAdminOrGlobalBuilder(
user: User | ContextUser,
appId?: string
): boolean {
return isGlobalBuilder(user) || isAdmin(user)
}
// check if they are a builder within an app (not necessarily a global builder) // check if they are a builder within an app (not necessarily a global builder)
export function hasAppBuilderPermissions(user?: User | ContextUser): boolean { export function hasAppBuilderPermissions(user?: User | ContextUser): boolean {
if (!user) { if (!user) {