Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/lib/components/permissions/actions.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import { DropList, DropListItem } from '..';
import Label from './label.svelte';
import Custom from './custom.svelte';
import Team from './team.svelte';
import User from './user.svelte';
Expand All @@ -10,6 +11,7 @@
export let showDropdown: boolean;
export let showUser: boolean;
export let showTeam: boolean;
export let showLabel: boolean;
export let showCustom: boolean;
export let groups: Writable<Map<string, Permission>>;

Expand Down Expand Up @@ -38,6 +40,7 @@
</DropListItem>
<DropListItem on:click={() => (showUser = true)}>Select users</DropListItem>
<DropListItem on:click={() => (showTeam = true)}>Select teams</DropListItem>
<DropListItem on:click={() => (showLabel = true)}>Label</DropListItem>
<DropListItem on:click={() => (showCustom = true)}>Custom permission</DropListItem>
</svelte:fragment>
</DropList>
Expand All @@ -51,4 +54,5 @@
showCustom = true;
}}
{groups} />
<Label bind:show={showLabel} on:create {groups} />
<Custom bind:show={showCustom} on:create {groups} />
46 changes: 46 additions & 0 deletions src/lib/components/permissions/label.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<script lang="ts">
import { Button, FormList, Helper, InputText } from '$lib/elements/forms';
import { createEventDispatcher } from 'svelte';
import { Modal } from '..';
import type { Writable } from 'svelte/store';
import type { Permission } from './permissions.svelte';

export let show: boolean;
export let groups: Writable<Map<string, Permission>>;

const dispatch = createEventDispatcher();

const pattern = String.raw`^[a-zA-Z0-9]+$`;
let value = '';
let isError = false;

function reset() {
value = '';
show = false;
}

function create() {
if (!value || !value.match(pattern)) {
isError = true;
return;
}

dispatch('create', [`label:${value}`]);
reset();
}

$: disabled = !value || $groups.has(value);
</script>

<Modal title="Label" bind:show on:close={reset} onSubmit={create}>
<p class="text">Labels allow you to grant access to users with the specfied label.</p>
<FormList>
<InputText showLabel={false} id="label" label="Label" placeholder="admin" bind:value />
<Helper type={isError ? 'warning' : 'neutral'}
>Only alphanumeric characters are allowed.</Helper>
</FormList>

<svelte:fragment slot="footer">
<Button submit {disabled}>Add</Button>
</svelte:fragment>
</Modal>
3 changes: 3 additions & 0 deletions src/lib/components/permissions/permissions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

let showUser = false;
let showTeam = false;
let showLabel = false;
let showCustom = false;
let showDropdown = false;

Expand Down Expand Up @@ -207,6 +208,7 @@
</div>

<Actions
bind:showLabel
bind:showCustom
bind:showDropdown
bind:showTeam
Expand All @@ -223,6 +225,7 @@
<div class="u-flex u-cross-center u-flex-vertical u-main-center u-flex">
<div class="common-section">
<Actions
bind:showLabel
bind:showCustom
bind:showDropdown
bind:showTeam
Expand Down
3 changes: 3 additions & 0 deletions src/lib/components/permissions/roles.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

let showUser = false;
let showTeam = false;
let showLabel = false;
let showCustom = false;
let showDropdown = false;

Expand Down Expand Up @@ -112,6 +113,7 @@
</TableBody>
</Table>
<Actions
bind:showLabel
bind:showCustom
bind:showDropdown
bind:showTeam
Expand All @@ -128,6 +130,7 @@
<div class="u-flex u-cross-center u-flex-vertical u-main-center u-flex">
<div class="common-section">
<Actions
bind:showLabel
bind:showCustom
bind:showDropdown
bind:showTeam
Expand Down