From 4971d05e40fc8703b558246a3af84d80032b3f5c Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Fri, 12 Feb 2021 10:12:17 +0000 Subject: [PATCH] simplify UI --- .../builder/src/builderStore/store/backend.js | 7 -- .../popovers/ManageAccessPopover.svelte | 77 +++++-------------- 2 files changed, 18 insertions(+), 66 deletions(-) diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index d6d712083a..6731aea51c 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -348,13 +348,6 @@ 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/popovers/ManageAccessPopover.svelte b/packages/builder/src/components/backend/DataTable/popovers/ManageAccessPopover.svelte index 8a1859a2d6..d8266b8f3b 100644 --- a/packages/builder/src/components/backend/DataTable/popovers/ManageAccessPopover.svelte +++ b/packages/builder/src/components/backend/DataTable/popovers/ManageAccessPopover.svelte @@ -4,42 +4,26 @@ import { Roles } from "constants/backend" import api from "builderStore/api" import { notifier } from "builderStore/store/notifications" - import { Button, Label, Select, Spacer } from "@budibase/bbui" + import { Button, Label, Input, Select, Spacer } from "@budibase/bbui" export let resourceId export let permissions - export let levels export let onClosed - // Draft level and role for editing - let level = levels[0] - let role = Roles.BASIC - - $: permissionKeys = Object.keys(permissions) - - async function addPermission() { + async function changePermission(level, role) { await backendUiStore.actions.permissions.save({ level, role, resource: resourceId, }) - // Show updated permissions in UI + // Show updated permissions in UI: REMOVE permissions = await backendUiStore.actions.permissions.forResource( resourceId ) - notifier.success("Access rule saved.") - - // Reset the draft permissions - level = levels[0] - role = Roles.BASIC - } - - async function deletePermission(level, role) { - await backendUiStore.actions.permissions.delete({ level, role, resourceId }) - delete permissions[role] - notifier.danger("Removed access rule.") - permissions = permissions + notifier.success("Updated permissions.") + // TODO: update permissions + // permissions[] } @@ -49,39 +33,24 @@
-
- {#if permissionKeys.length === 0} - - {/if} - {#each permissionKeys as role} - - - deletePermission(permissions[role], role)} /> + {#each Object.keys(permissions) as level} + + {/each}
-
- - -
- - -
@@ -107,19 +76,9 @@ margin-top: var(--spacing-l); } - .draft-permission { + .row { display: grid; grid-template-columns: 1fr 1fr; grid-gap: var(--spacing-m); } - - .row { - display: grid; - grid-template-columns: 1fr 1fr 20px; - grid-gap: var(--spacing-s); - } - - .delete { - cursor: pointer; - }