switching to global builder role for plugin API, dis-allowing per app builders to delete apps and updating UI to reflect these updates.

This commit is contained in:
mike12345567 2023-07-27 18:09:30 +01:00
parent d8f50f139e
commit d62b2bdbe0
4 changed files with 34 additions and 29 deletions

View File

@ -4,6 +4,8 @@
import { url, isActive } from "@roxi/routify" import { url, isActive } from "@roxi/routify"
import DeleteModal from "components/deploy/DeleteModal.svelte" import DeleteModal from "components/deploy/DeleteModal.svelte"
import { isOnlyUser } from "builderStore" import { isOnlyUser } from "builderStore"
import { auth } from "stores/portal"
import { sdk } from "@budibase/shared-core"
let deleteModal let deleteModal
</script> </script>
@ -44,22 +46,24 @@
url={$url("./version")} url={$url("./version")}
active={$isActive("./version")} active={$isActive("./version")}
/> />
<div class="delete-action"> {#if sdk.users.isGlobalBuilder($auth.user)}
<AbsTooltip <div class="delete-action">
position={TooltipPosition.Bottom} <AbsTooltip
text={$isOnlyUser position={TooltipPosition.Bottom}
? null text={$isOnlyUser
: "Unavailable - another user is editing this app"} ? null
> : "Unavailable - another user is editing this app"}
<SideNavItem >
text="Delete app" <SideNavItem
disabled={!$isOnlyUser} text="Delete app"
on:click={() => { disabled={!$isOnlyUser}
deleteModal.show() on:click={() => {
}} deleteModal.show()
/> }}
</AbsTooltip> />
</div> </AbsTooltip>
</div>
{/if}
</SideNav> </SideNav>
<slot /> <slot />
</Content> </Content>

View File

@ -29,20 +29,17 @@ export const menu = derived([admin, auth], ([$admin, $auth]) => {
href: "/builder/portal/apps", href: "/builder/portal/apps",
}, },
] ]
if ( if (sdk.users.isGlobalBuilder(user)) {
sdk.users.hasBuilderPermissions(user) &&
!sdk.users.hasAppBuilderPermissions(user)
) {
menu.push({ menu.push({
title: "Users", title: "Users",
href: "/builder/portal/users", href: "/builder/portal/users",
subPages: userSubPages, subPages: userSubPages,
}) })
menu.push({
title: "Plugins",
href: "/builder/portal/plugins",
})
} }
menu.push({
title: "Plugins",
href: "/builder/portal/plugins",
})
// Add settings page for admins // Add settings page for admins
if (isAdmin) { if (isAdmin) {

View File

@ -55,7 +55,7 @@ router
) )
.delete( .delete(
"/api/applications/:appId", "/api/applications/:appId",
authorized(permissions.BUILDER), authorized(permissions.GLOBAL_BUILDER),
controller.destroy controller.destroy
) )

View File

@ -8,14 +8,18 @@ const router: Router = new Router()
router router
.post( .post(
"/api/plugin/upload", "/api/plugin/upload",
authorized(permissions.BUILDER), authorized(permissions.GLOBAL_BUILDER),
controller.upload controller.upload
) )
.post("/api/plugin", authorized(permissions.BUILDER), controller.create) .post(
.get("/api/plugin", authorized(permissions.BUILDER), controller.fetch) "/api/plugin",
authorized(permissions.GLOBAL_BUILDER),
controller.create
)
.get("/api/plugin", authorized(permissions.GLOBAL_BUILDER), controller.fetch)
.delete( .delete(
"/api/plugin/:pluginId", "/api/plugin/:pluginId",
authorized(permissions.BUILDER), authorized(permissions.GLOBAL_BUILDER),
controller.destroy controller.destroy
) )