Add new detail popover and update manage access button to use it

This commit is contained in:
Andrew Kingston 2024-08-21 07:46:15 +01:00
parent d8fd021e37
commit f54d1985b4
No known key found for this signature in database
5 changed files with 103 additions and 67 deletions

View File

@ -143,6 +143,9 @@
border-color: var(--spectrum-global-color-gray-300);
overflow: auto;
transition: opacity 260ms ease-out;
filter: none;
-webkit-filter: none;
box-shadow: 0 1px 4px var(--drop-shadow);
}
.blockPointerEvents {
pointer-events: none;

View File

@ -2,22 +2,25 @@
import { ActionButton, Modal } from "@budibase/bbui"
import { permissions } from "stores/builder"
import ManageAccessModal from "../modals/ManageAccessModal.svelte"
import DetailPopover from "components/common/DetailPopover.svelte"
export let resourceId
export let disabled = false
let modal
let resourcePermissions
async function openModal() {
resourcePermissions = await permissions.forResourceDetailed(resourceId)
modal.show()
$: fetchPermissions(resourceId)
const fetchPermissions = async id => {
console.log("getting perms for", id)
resourcePermissions = await permissions.forResourceDetailed(id)
}
</script>
<ActionButton icon="LockClosed" quiet on:click={openModal} {disabled}>
Access
</ActionButton>
<Modal bind:this={modal}>
<DetailPopover title="Manage access">
<svelte:fragment slot="anchor" let:open>
<ActionButton icon="LockClosed" selected={open} quiet>Access</ActionButton>
</svelte:fragment>
{#if resourcePermissions}
<ManageAccessModal {resourceId} permissions={resourcePermissions} />
</Modal>
{/if}
</DetailPopover>

View File

@ -1,19 +1,8 @@
<script>
import { PermissionSource } from "@budibase/types"
import { roles, permissions as permissionsStore } from "stores/builder"
import {
Label,
Input,
Select,
notifications,
Body,
ModalContent,
Tags,
Tag,
Icon,
} from "@budibase/bbui"
import { Label, Input, Select, notifications, Body } from "@budibase/bbui"
import { capitalise } from "helpers"
import { getFormattedPlanName } from "helpers/planTitle"
import { get } from "svelte/store"
export let resourceId
@ -69,8 +58,6 @@
{}
)
$: requiresPlanToModify = permissions.requiresPlanToModify
let dependantsInfoMessage
async function loadDependantInfo() {
const dependantsInfo = await permissionsStore.getDependantsInfo(resourceId)
@ -94,27 +81,13 @@
loadDependantInfo()
</script>
<ModalContent showCancelButton={false} confirmText="Done">
<span slot="header">
Manage Access
{#if requiresPlanToModify}
<span class="lock-tag">
<Tags>
<Tag icon="LockClosed"
>{getFormattedPlanName(requiresPlanToModify)}</Tag
>
</Tags>
</span>
{/if}
</span>
<Body size="S">Specify the minimum access level role for this data.</Body>
<div class="row">
<Body size="S">Specify the minimum access level role for this data.</Body>
<div class="row">
<Label extraSmall grey>Level</Label>
<Label extraSmall grey>Role</Label>
{#each Object.keys(computedPermissions) as level}
<Input value={capitalise(level)} disabled />
<Select
disabled={requiresPlanToModify}
placeholder={false}
value={computedPermissions[level].selectedValue}
on:change={e => changePermission(level, e.detail)}
@ -123,9 +96,9 @@
getOptionValue={x => x._id}
/>
{/each}
</div>
</div>
{#if dependantsInfoMessage}
{#if dependantsInfoMessage}
<div class="inheriting-resources">
<Icon name="Alert" />
<Body size="S">
@ -134,8 +107,7 @@
</i>
</Body>
</div>
{/if}
</ModalContent>
{/if}
<style>
.row {

View File

@ -0,0 +1,59 @@
<script>
import { Popover, Icon } from "@budibase/bbui"
export let title
export let align = "left"
let popover
let anchor
let open
export const show = () => popover?.show()
export const hide = () => popover?.hide()
</script>
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div class="anchor" bind:this={anchor} on:click={show}>
<slot name="anchor" {open} />
</div>
<Popover bind:this={popover} bind:open {anchor} {align} minWidth={300}>
<div class="detail-popover">
<div class="detail-popover__header">
<div class="detail-popover__title">
{title}
</div>
<Icon name="Close" />
</div>
<div class="detail-popover__body">
<slot />
</div>
</div>
</Popover>
<style>
.detail-popover {
--padding: 12px;
background-color: var(--spectrum-alias-background-color-primary);
}
.detail-popover__header {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid var(--spectrum-global-color-gray-300);
padding: var(--padding);
}
.detail-popover__title {
font-size: 16px;
font-weight: 600;
}
.detail-popover__body {
padding: var(--padding);
display: flex;
flex-direction: column;
align-items: stretch;
gap: var(--padding);
}
</style>

View File

@ -152,7 +152,6 @@ export const createActions = context => {
return
}
schemaMutations.update($schemaMutations => {
console.log($schemaMutations)
return {
...$schemaMutations,
[field]: {