From 20bf34d53c0301c5cbb5732ec44b0afced3372d9 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 10 Feb 2021 22:23:27 +0000 Subject: [PATCH] RBAC popover complete --- .../builder/src/builderStore/store/backend.js | 9 ++ .../backend/DataTable/DataTable.svelte | 2 +- .../backend/DataTable/ViewDataTable.svelte | 2 +- .../buttons/ManageAccessButton.svelte | 20 ++- .../DataTable/modals/CreateEditColumn.svelte | 2 +- .../popovers/ManageAccessPopover.svelte | 114 ++++++++++++------ .../builder/src/constants/backend/index.js | 8 ++ 7 files changed, 116 insertions(+), 41 deletions(-) diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index d2a19f8726..912e458995 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -30,6 +30,7 @@ export const getBackendUiStore = () => { const queries = await queriesResponse.json() const integrationsResponse = await api.get("/api/integrations") const integrations = await integrationsResponse.json() + const permissionLevels = await store.actions.permissions.fetchLevels() store.update(state => { state.selectedDatabase = db @@ -37,6 +38,7 @@ export const getBackendUiStore = () => { state.datasources = datasources state.queries = queries state.integrations = integrations + state.permissionLevels = permissionLevels return state }) }, @@ -351,6 +353,13 @@ export const getBackendUiStore = () => { const json = await response.json() return json }, + delete: async ({ role, resource, level }) => { + const response = await api.delete( + `/api/permission/${role}/${resource}/${level}` + ) + const json = await response.json() + return json + }, }, } diff --git a/packages/builder/src/components/backend/DataTable/DataTable.svelte b/packages/builder/src/components/backend/DataTable/DataTable.svelte index 937cb7931a..577fda62a8 100644 --- a/packages/builder/src/components/backend/DataTable/DataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/DataTable.svelte @@ -48,8 +48,8 @@ title={isUsersTable ? 'Create New User' : 'Create New Row'} modalContentComponent={isUsersTable ? CreateEditUser : CreateEditRow} /> - + {/if} {#if isUsersTable} diff --git a/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte b/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte index 6597dcd481..f875fa8849 100644 --- a/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte @@ -54,6 +54,6 @@ {#if view.calculation} {/if} - + diff --git a/packages/builder/src/components/backend/DataTable/buttons/ManageAccessButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/ManageAccessButton.svelte index c6c6bddecf..2540267d72 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/ManageAccessButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/ManageAccessButton.svelte @@ -1,5 +1,7 @@
- + Manage Access
- + diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index 80eaf613f8..afb474499b 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -92,3 +92,11 @@ export const HostingTypes = { CLOUD: "cloud", SELF: "self", } + +export const Roles = { + ADMIN: "ADMIN", + POWER: "POWER", + BASIC: "BASIC", + PUBLIC: "PUBLIC", + BUILDER: "BUILDER", +}