fix db screens

This commit is contained in:
Torsten Dittmann committed 2025-02-27 23:43:00 +04:00
1 parent f0a06e8c0a
commit 648f640374
41 files changed
+1160 -1313

No files matched your search

+1 -1
View File
@@ -23,7 +23,7 @@
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@dd94b87a ",
"@appwrite.io/pink-legacy": "^1.0.2",
"@appwrite.io/pink-svelte": "https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@3944439",
"@appwrite.io/pink-svelte": "https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@463e78e9",
"@popperjs/core": "^2.11.8",
"@sentry/sveltekit": "^8.38.0",
"@stripe/stripe-js": "^3.5.0",
+13 -13
View File
@@ -21,8 +21,8 @@ importers:
specifier: ^1.0.2
version: 1.0.2
'@appwrite.io/pink-svelte':
specifier: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@3944439
version: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@3944439(react-dom@18.3.1(react@18.3.1))(svelte@4.2.19)
specifier: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@463e78e9
version: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@463e78e9(react-dom@18.3.1(react@18.3.1))(svelte@4.2.19)
'@popperjs/core':
specifier: ^2.11.8
version: 2.11.8
@@ -215,8 +215,8 @@ packages:
resolution: {tarball: https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@ac51fcb}
version: 1.2.1
'@appwrite.io/pink-icons-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@3944439501e60e559b63958c09c83dbfa4ea7600':
resolution: {tarball: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@3944439501e60e559b63958c09c83dbfa4ea7600}
'@appwrite.io/pink-icons-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@463e78e978aa761b551b86a6e3f64c0703159326':
resolution: {tarball: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@463e78e978aa761b551b86a6e3f64c0703159326}
version: 1.0.0-next.7
peerDependencies:
svelte: ^4.0.0
@@ -236,8 +236,8 @@ packages:
'@appwrite.io/pink-legacy@1.0.2':
resolution: {integrity: sha512-1AYNcfbV+x0Tyj56CoieSq5g7+u+7F5/LDVN/z+Hx1kp9gj7xc1eT39Dy832xxfihImF6ksjp0FXEMVSBR8cew==}
'@appwrite.io/pink-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@3944439':
resolution: {tarball: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@3944439}
'@appwrite.io/pink-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@463e78e9':
resolution: {tarball: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@463e78e9}
version: 1.0.0-next.85
peerDependencies:
react-dom: ^18.0.0
@@ -2826,8 +2826,8 @@ packages:
micromark-util-symbol@2.0.1:
resolution: {integrity: sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==}
micromark-util-types@2.0.1:
resolution: {integrity: sha512-534m2WhVTddrcKVepwmVEVnUAmtrx9bfIjNoQHRqfnvdaHQiFytEhJoTgpWJvDEXCO5gLTQh3wYC1PgOJA4NSQ==}
micromark-util-types@2.0.2:
resolution: {integrity: sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==}
micromatch@4.0.8:
resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==}
@@ -4099,7 +4099,7 @@ snapshots:
'@appwrite.io/console@https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@ac51fcb': {}
'@appwrite.io/pink-icons-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@3944439501e60e559b63958c09c83dbfa4ea7600(svelte@4.2.19)':
'@appwrite.io/pink-icons-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@463e78e978aa761b551b86a6e3f64c0703159326(svelte@4.2.19)':
dependencies:
svelte: 4.2.19
@@ -4116,9 +4116,9 @@ snapshots:
'@appwrite.io/pink-icons': 1.0.0
the-new-css-reset: 1.11.3
'@appwrite.io/pink-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@3944439(react-dom@18.3.1(react@18.3.1))(svelte@4.2.19)':
'@appwrite.io/pink-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@463e78e9(react-dom@18.3.1(react@18.3.1))(svelte@4.2.19)':
dependencies:
'@appwrite.io/pink-icons-svelte': https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@3944439501e60e559b63958c09c83dbfa4ea7600(svelte@4.2.19)
'@appwrite.io/pink-icons-svelte': https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@463e78e978aa761b551b86a6e3f64c0703159326(svelte@4.2.19)
'@floating-ui/dom': 1.6.13
'@melt-ui/pp': 0.3.2(@melt-ui/svelte@0.86.3(svelte@4.2.19))(svelte@4.2.19)
'@melt-ui/svelte': 0.86.3(svelte@4.2.19)
@@ -7242,7 +7242,7 @@ snapshots:
micromark-util-character@2.1.1:
dependencies:
micromark-util-symbol: 2.0.1
micromark-util-types: 2.0.1
micromark-util-types: 2.0.2
micromark-util-encode@2.0.1: {}
@@ -7254,7 +7254,7 @@ snapshots:
micromark-util-symbol@2.0.1: {}
micromark-util-types@2.0.1: {}
micromark-util-types@2.0.2: {}
micromatch@4.0.8:
dependencies:
+18 -18
View File
@@ -1,4 +1,6 @@
<script lang="ts">
import { IconChevronLeft, IconChevronRight } from '@appwrite.io/pink-icons-svelte';
import { Button, Icon, Layout } from '@appwrite.io/pink-svelte';
import { createEventDispatcher } from 'svelte';
export let sum: number;
@@ -51,16 +53,15 @@
</script>
{#if totalPages > 1}
<nav class="pagination">
<button
type="button"
<Layout.Stack direction="row">
<Button.Button
size="s"
variant="compact"
on:click={() => handleButtonPage('prev')}
class:is-disabled={currentPage <= 1}
class="button is-text"
aria-label="prev page">
<span class="icon-cheveron-left" aria-hidden="true" />
<span class="text">Prev</span>
</button>
disabled={currentPage <= 1}>
<Icon icon={IconChevronLeft} slot="start" />
Prev
</Button.Button>
{#if !hidePages}
<ol class="pagination-list is-only-desktop">
{#each pages as page}
@@ -84,16 +85,15 @@
{/each}
</ol>
{/if}
<button
<Button.Button
size="s"
variant="compact"
on:click={() => handleButtonPage('next')}
class:is-disabled={currentPage === totalPages}
class="button is-text"
type="button"
aria-label="next page">
<span class="text">Next</span>
<span class="icon-cheveron-right" aria-hidden="true" />
</button>
</nav>
disabled={currentPage === totalPages}>
<Icon icon={IconChevronRight} slot="end" />
Next
</Button.Button>
</Layout.Stack>
{:else}
<nav class="pagination">
<button type="button" class="button is-text is-disabled" aria-label="prev page">
+6 -3
View File
@@ -17,9 +17,12 @@
{#if !hideFooter}
<Layout.Stack direction="row" justifyContent="space-between" alignItems="center">
<Typography.Text variant="m-400" color="--color-fgcolor-neutral-secondary"
>Total results: {total}</Typography.Text>
<PaginationInline {limit} bind:offset sum={total} hidePages />
<Typography.Text variant="m-400" color="--color-fgcolor-neutral-secondary">
Total results: {total}
</Typography.Text>
<div>
<PaginationInline {limit} bind:offset sum={total} hidePages />
</div>
</Layout.Stack>
{/if}
</Layout.Stack>
+20 -17
View File
@@ -17,15 +17,10 @@
const dispatch = createEventDispatcher();
</script>
<Popover let:toggle>
<Popover let:toggle padding="none" placement="bottom-start">
<slot {toggle} />
<svelte:fragment slot="tooltip">
<ActionMenu.Root>
<ActionMenu.Item.Button
disabled={$groups.has('any')}
on:click={() => dispatch('create', ['any'])}>
Any
</ActionMenu.Item.Button>
<ActionMenu.Item.Button
disabled={$groups.has('any')}
on:click={() => dispatch('create', ['any'])}>
@@ -53,14 +48,22 @@
</svelte:fragment>
</Popover>
<User bind:show={showUser} on:create {groups} />
<Team
bind:show={showTeam}
on:create
on:custom={() => {
showTeam = false;
showCustom = true;
}}
{groups} />
<Label bind:show={showLabel} on:create {groups} />
<Custom bind:show={showCustom} on:create {groups} />
{#if showUser}
<User bind:show={showUser} on:create {groups} />
{/if}
{#if showTeam}
<Team
bind:show={showTeam}
on:create
on:custom={() => {
showTeam = false;
showCustom = true;
}}
{groups} />
{/if}
{#if showLabel}
<Label bind:show={showLabel} on:create {groups} />
{/if}
{#if showCustom}
<Custom bind:show={showCustom} on:create {groups} />
{/if}
+7 -10
View File
@@ -30,16 +30,13 @@
Custom permissions allow you to grant access to specific users or teams using their ID and
role.
</span>
<FormList>
<InputText
id="custom-permission"
label="Role"
placeholder="user:[USER_ID] or team:[TEAM_ID]/[ROLE]"
bind:value />
<Helper type="neutral">
A permission should be formatted as: user:[USER_ID] or team:[TEAM_ID]/[ROLE]¸
</Helper>
</FormList>
<InputText
required
id="custom-permission"
label="Role"
placeholder="user:[USER_ID] or team:[TEAM_ID]/[ROLE]"
helper="A permission should be formatted as: user:[USER_ID] or team:[TEAM_ID]/[ROLE]¸"
bind:value />
<svelte:fragment slot="footer">
<Button submit {disabled}>Add</Button>
+10 -10
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { Button, FormList, Helper, InputText } from '$lib/elements/forms';
import { Button, InputText } from '$lib/elements/forms';
import { createEventDispatcher } from 'svelte';
import { Modal } from '..';
import type { Writable } from 'svelte/store';
@@ -12,7 +12,6 @@
const pattern = String.raw`^[a-zA-Z0-9]+$`;
let value = '';
let isError = false;
function reset() {
value = '';
@@ -21,7 +20,6 @@
function create() {
if (!value || !value.match(pattern)) {
isError = true;
return;
}
@@ -33,14 +31,16 @@
</script>
<Modal title="Label" bind:show on:close={reset} onSubmit={create}>
<span slot="description">
<svelte:fragment slot="description">
Labels allow you to grant access to users with the specified label.
</span>
<FormList>
<InputText id="label" label="Label" placeholder="Enter label" bind:value />
<Helper type={isError ? 'warning' : 'neutral'}
>Only alphanumeric characters are allowed.</Helper>
</FormList>
</svelte:fragment>
<InputText
required
id="label"
label="Label"
placeholder="Enter label"
bind:value
helper="Only alphanumeric characters are allowed." />
<svelte:fragment slot="footer">
<Button submit {disabled}>Add</Button>
@@ -11,21 +11,13 @@
<script lang="ts">
import { Button } from '$lib/elements/forms';
import {
TableBody,
TableCell,
TableCellHead,
TableHeader,
TableRow
} from '$lib/elements/table';
import { symmetricDifference } from '$lib/helpers/array';
import { onMount } from 'svelte';
import { writable } from 'svelte/store';
import Actions from './actions.svelte';
import Row from './row.svelte';
import Table from '$lib/elements/table/table.svelte';
import { Icon } from '@appwrite.io/pink-svelte';
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
import { Icon, Selector, Table } from '@appwrite.io/pink-svelte';
import { IconPlus, IconX } from '@appwrite.io/pink-icons-svelte';
export let withCreate = false;
export let permissions: string[] = [];
@@ -136,89 +128,74 @@
{#if [...$groups]?.length}
<div class="table-wrapper">
<Table noMargin noStyles>
<TableHeader>
<TableCellHead width={140}>Role</TableCellHead>
<Table.Root>
<svelte:fragment slot="header">
<Table.Header.Cell>Role</Table.Header.Cell>
{#if withCreate}
<TableCellHead width={60}>Create</TableCellHead>
<Table.Header.Cell width="90px">Create</Table.Header.Cell>
{/if}
<TableCellHead width={50}>Read</TableCellHead>
<TableCellHead width={60}>Update</TableCellHead>
<TableCellHead width={60}>Delete</TableCellHead>
<TableCellHead width={32} />
</TableHeader>
<TableBody>
{#each [...$groups].sort(sortRoles) as [role, permission] (role)}
<TableRow>
<TableCell title="Role">
<Row {role} />
</TableCell>
<Table.Header.Cell width="90px">Read</Table.Header.Cell>
<Table.Header.Cell width="90px">Update</Table.Header.Cell>
<Table.Header.Cell width="90px">Delete</Table.Header.Cell>
<Table.Header.Cell width="40px" />
</svelte:fragment>
{#each [...$groups].sort(sortRoles) as [role, permission] (role)}
<Table.Row>
<Table.Cell>
<Row {role} />
</Table.Cell>
{#if withCreate}
<TableCell title="Create">
<input
type="checkbox"
class="icon-check"
aria-label="Create"
checked={permission.create}
on:change={() => togglePermission(role, 'create')} />
</TableCell>
{/if}
<TableCell title="Read">
<input
type="checkbox"
class="icon-check"
aria-label="Read"
checked={permission.read}
on:change={() => togglePermission(role, 'read')} />
</TableCell>
<TableCell title="Update">
<input
type="checkbox"
class="icon-check"
aria-label="Update"
checked={permission.update}
on:change={() => togglePermission(role, 'update')} />
</TableCell>
<TableCell title="Delete">
<input
type="checkbox"
class="icon-check"
aria-label="Delete"
checked={permission.delete}
on:change={() => togglePermission(role, 'delete')} />
</TableCell>
{#if withCreate}
<Table.Cell>
<Selector.Checkbox
checked={permission.create}
on:change={() => togglePermission(role, 'create')} />
</Table.Cell>
{/if}
<Table.Cell>
<Selector.Checkbox
size="s"
checked={permission.read}
on:change={() => togglePermission(role, 'read')} />
</Table.Cell>
<Table.Cell>
<Selector.Checkbox
size="s"
checked={permission.update}
on:change={() => togglePermission(role, 'update')} />
</Table.Cell>
<Table.Cell>
<Selector.Checkbox
size="s"
checked={permission.delete}
on:change={() => togglePermission(role, 'delete')} />
</Table.Cell>
<TableCell title="Remove" width={40}>
<div class="u-flex">
<button
class="button is-text is-only-icon"
type="button"
aria-label="delete"
on:click={() => deleteRole(role)}>
<span class="icon-x" aria-hidden="true" />
</button>
</div>
</TableCell>
</TableRow>
{/each}
</TableBody>
</Table>
<Table.Cell>
<Button compact icon ariaLabel="delete" on:click={() => deleteRole(role)}>
<Icon icon={IconX} size="s" />
</Button>
</Table.Cell>
</Table.Row>
{/each}
</Table.Root>
</div>
<Actions
bind:showLabel
bind:showCustom
bind:showTeam
bind:showUser
{groups}
on:create={create}
let:toggle>
<Button text on:click={toggle}>
<Icon icon={IconPlus} slot="start" size="s" />
Add role
</Button>
</Actions>
<div>
<Actions
bind:showLabel
bind:showCustom
bind:showTeam
bind:showUser
{groups}
on:create={create}
let:toggle>
<Button secondary on:click={toggle}>
<Icon icon={IconPlus} slot="start" size="s" />
Add role
</Button>
</Actions>
</div>
{:else}
<article class="card u-grid u-cross-center u-width-full-line dashed">
<div class="u-flex u-cross-center u-flex-vertical u-main-center u-flex">
+76 -80
View File
@@ -6,8 +6,15 @@
import { AvatarInitials, EmptySearch, Modal, PaginationInline } from '..';
import type { Writable } from 'svelte/store';
import type { Permission } from './permissions.svelte';
import Table from '$lib/elements/table/table.svelte';
import { TableBody, TableCell, TableRow } from '$lib/elements/table';
import {
Card,
Empty,
Layout,
Link,
Selector,
Table,
Typography
} from '@appwrite.io/pink-svelte';
export let show: boolean;
export let groups: Writable<Map<string, Permission>>;
@@ -39,14 +46,14 @@
);
}
function onSelection(event: Event, role: string) {
const { checked } = event.currentTarget as HTMLInputElement;
function onSelection(role: string) {
const checked = selected.has(role);
if (checked) {
selected.add(role);
} else {
selected.delete(role);
} else {
selected.add(role);
}
selected = selected;
hasSelection = selected.size > 0;
}
@@ -64,87 +71,76 @@
</script>
<Modal title="Select teams" bind:show onSubmit={create} on:close={reset} size="big">
<p class="text">
Grant access to any member of a specific team. To grant access to team members with specific
roles, you will need to set a <button
type="button"
class="link"
on:click={() => dispatch('custom')}>custom permission</button
>.
</p>
<InputSearch
autofocus
disabled={!results?.teams?.length && !search}
placeholder="Search by name or ID"
bind:value={search} />
<Typography.Text
>Grant access to any member of a specific team. To grant access to team members with
specific roles, you will need to set a <Link.Button on:click={() => dispatch('custom')}
>custom permission</Link.Button
>.</Typography.Text>
<InputSearch autofocus placeholder="Search by name or ID" bind:value={search} />
{#if results?.teams?.length}
<div class="table-wrapper">
<Table noStyles isAutoLayout tag="table">
<TableBody>
{#each results.teams as team (team.$id)}
{@const role = `team:${team.$id}`}
{@const exists = $groups.has(role)}
<TableRow>
<TableCell title="Enabled" width={40}>
<input
id={team.$id}
type="checkbox"
class="icon-check"
aria-label="Create"
checked={exists || selected.has(role)}
disabled={exists}
on:change={(event) => onSelection(event, role)} />
</TableCell>
<TableCell title="Team">
<label class="u-flex u-cross-center u-gap-8" for={team.$id}>
<AvatarInitials size="s" name={team.name} />
<div class="u-line-height-1-5">
<div class="body-text-2 u-bold">{team.name}</div>
<div class="u-x-small">{team.$id}</div>
</div>
</label>
</TableCell>
</TableRow>
{/each}
</TableBody>
</Table>
</div>
<Table.Root>
{#each results.teams as team (team.$id)}
{@const role = `team:${team.$id}`}
{@const exists = $groups.has(role)}
<Table.Button on:click={() => onSelection(role)} disabled={exists}>
<Table.Cell width="40px">
<Selector.Checkbox
id={team.$id}
checked={exists || selected.has(role)}
disabled={exists} />
</Table.Cell>
<Table.Cell>
<Layout.Stack direction="row" alignItems="center" gap="s">
<AvatarInitials size="xs" name={team.name} />
<Layout.Stack gap="none">
<Typography.Caption variant="400">Text</Typography.Caption>
<Typography.Caption
variant="400"
color="--color-fgcolor-neutral-tertiary">
Secondary Text
</Typography.Caption>
</Layout.Stack>
</Layout.Stack>
<Layout.Stack direction="row" alignItems="center" gap="s">
<AvatarInitials size="xs" name={team.name} />
<span>
{team.name}
</span>
<span>
{team.$id}
</span>
</Layout.Stack>
</Table.Cell>
</Table.Button>
{/each}
</Table.Root>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {results?.total}</p>
<PaginationInline limit={5} bind:offset sum={results?.total} hidePages />
</div>
{:else if search}
<EmptySearch hidePages>
<div class="common-section">
<div class="u-text-center common-section">
<b class="body-text-2 u-bold">Sorry we couldn't find "{search}"</b>
<p>There are no teams that match your search.</p>
</div>
<div class="u-flex u-gap-16 common-section u-main-center">
<Button external href="https://appwrite.io/docs/products/auth/teams" text
>Documentation</Button>
<Button secondary on:click={() => (search = '')}>Clear search</Button>
</div>
</div>
<EmptySearch bind:search target="teams" hidePages>
<Button
external
href="https://appwrite.io/docs/products/auth/teams"
text
event="empty_documentation"
size="s">Documentation</Button>
<Button secondary on:click={() => (search = '')}>Clear search</Button>
</EmptySearch>
{:else}
<EmptySearch hidePages>
<div class="common-section">
<div class="u-text-center common-section">
<p class="text u-line-height-1-5">
You have no teams. Create a team to see them here.
</p>
<p class="text u-line-height-1-5">
Need a hand? Learn more in our <a
href="https://appwrite.io/docs/products/auth/teams"
target="_blank"
rel="noopener noreferrer">
documentation</a
>.
</p>
</div>
</div>
</EmptySearch>
<Card.Base padding="none">
<Empty title="You have no teams. Create a team to see them here." type="secondary">
<Typography.Text slot="description">
Need a hand? Learn more in our <Link.Anchor
href="https://appwrite.io/docs/products/auth/teams"
target="_blank"
rel="noopener noreferrer">
documentation</Link.Anchor
>.
</Typography.Text>
</Empty>
</Card.Base>
{/if}
<svelte:fragment slot="footer">
+110 -100
View File
@@ -6,6 +6,24 @@
import { Query, type Models } from '@appwrite.io/console';
import type { Writable } from 'svelte/store';
import type { Permission } from './permissions.svelte';
import {
Avatar,
Card,
Empty,
Icon,
Layout,
Link,
Selector,
Table,
Typography
} from '@appwrite.io/pink-svelte';
import {
IconAnonymous,
IconChartSquareBar,
IconCheck,
IconMinus,
IconMinusSm
} from '@appwrite.io/pink-icons-svelte';
export let show: boolean;
export let groups: Writable<Map<string, Permission>>;
@@ -37,14 +55,14 @@
);
}
function onSelection(event: Event, role: string) {
const { checked } = event.currentTarget as HTMLInputElement;
function onSelection(role: string) {
const checked = selected.has(role);
if (checked) {
selected.add(role);
} else {
selected.delete(role);
} else {
selected.add(role);
}
selected = selected;
hasSelection = selected.size > 0;
}
@@ -61,107 +79,99 @@
}
</script>
<Modal title="Select users" bind:show onSubmit={create} on:close={reset} size="big">
<p class="text">Grant access to any authenticated or anonymous user.</p>
<InputSearch
autofocus
disabled={!results?.users?.length && !search}
placeholder="Search by name, email, phone or ID"
bind:value={search} />
<Modal title="Select users" bind:show onSubmit={create} on:close={reset}>
<Typography.Text>Grant access to any authenticated or anonymous user.</Typography.Text>
<InputSearch autofocus placeholder="Search by name, email, phone or ID" bind:value={search} />
{#if results?.users?.length}
<div class="table-wrapper">
<table class="table is-table-layout-auto is-remove-outer-styles">
<tbody class="table-tbody">
{#each results.users as user (user.$id)}
{@const role = `user:${user.$id}`}
{@const exists = $groups.has(role)}
<tr class="table-row">
<td class="table-col" data-title="Enabled" style="--p-col-width:40">
<input
id={user.$id}
type="checkbox"
class="icon-check"
aria-label="Create"
checked={exists || selected.has(role)}
disabled={exists}
on:change={(event) => onSelection(event, role)} />
</td>
<td class="table-col" data-title="User">
<label class="u-flex u-cross-center u-gap-8" for={user.$id}>
{#if user.email || user.phone}
{#if user.name}
<AvatarInitials size="s" name={user.name} />
<div class="u-line-height-1-5">
<div class="body-text-2 u-bold">
{user.name}
</div>
<div class="u-x-small">{user.$id}</div>
</div>
{:else}
<div class="avatar is-size-small">
<span class="icon-minus-sm" aria-hidden="true" />
</div>
<div class="u-line-height-1-5">
<div class="body-text-2 u-bold">
{user.email ? user.email : user.phone}
</div>
<div class="u-x-small">{user.$id}</div>
</div>
{/if}
{:else}
<div class="avatar is-size-small">
<span class="icon-anonymous" aria-hidden="true" />
</div>
<div class="u-line-height-1-5">
<div class="body-text-2 u-bold">
{user.name ? user.name : '-'}
</div>
<div class="u-x-small">{user.$id}</div>
</div>
{/if}
</label>
</td>
</tr>
{/each}
</tbody>
</table>
</div>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<Table.Root>
{#each results.users as user (user.$id)}
{@const role = `user:${user.$id}`}
{@const exists = $groups.has(role)}
<Table.Button on:click={() => onSelection(role)} disabled={exists}>
<Table.Cell width="40px">
<Selector.Checkbox
size="s"
id={user.$id}
checked={exists || selected.has(role)}
disabled={exists} />
</Table.Cell>
<Table.Cell>
<Layout.Stack direction="row" alignItems="center" gap="s">
{#if user.email || user.phone}
{#if user.name}
<AvatarInitials size="xs" name={user.name} />
<Layout.Stack gap="none">
<Typography.Caption variant="400"
>{user.name}</Typography.Caption>
<Typography.Caption
variant="400"
color="--color-fgcolor-neutral-tertiary">
{user.$id}
</Typography.Caption>
</Layout.Stack>
{:else}
<Avatar size="xs">
<Icon icon={IconMinusSm} size="s" />
</Avatar>
<Layout.Stack gap="none">
<Typography.Caption variant="400"
>{user.email
? user.email
: user.phone}</Typography.Caption>
<Typography.Caption
variant="400"
color="--color-fgcolor-neutral-tertiary">
{user.$id}
</Typography.Caption>
</Layout.Stack>
{/if}
{:else}
<Avatar size="xs">
<Icon icon={IconAnonymous} size="s" />
</Avatar>
<Layout.Stack gap="none">
<Typography.Caption variant="400"
>{user.name ? user.name : '-'}</Typography.Caption>
<Typography.Caption
variant="400"
color="--color-fgcolor-neutral-tertiary">
{user.$id}
</Typography.Caption>
</Layout.Stack>
{/if}
</Layout.Stack>
</Table.Cell>
</Table.Button>
{/each}
</Table.Root>
<Layout.Stack direction="row" justifyContent="space-between" alignItems="center">
<p class="text">Total results: {results?.total}</p>
<PaginationInline limit={5} bind:offset sum={results?.total} hidePages />
</div>
</Layout.Stack>
{:else if search}
<EmptySearch hidePages>
<div class="common-section">
<div class="u-text-center common-section">
<b class="body-text-2 u-bold">Sorry we couldn't find "{search}"</b>
<p>There are no Users that match your search.</p>
</div>
<div class="u-flex u-gap-16 common-section u-main-center">
<Button external href="https://appwrite.io/docs/products/auth/accounts" text
>Documentation</Button>
<Button secondary on:click={() => (search = '')}>Clear search</Button>
</div>
</div>
<EmptySearch bind:search target="users" hidePages>
<Button
external
href="https://appwrite.io/docs/products/auth/users"
text
event="empty_documentation"
size="s">Documentation</Button>
<Button secondary on:click={() => (search = '')}>Clear search</Button>
</EmptySearch>
{:else}
<EmptySearch hidePages>
<div class="common-section">
<div class="u-text-center common-section">
<p class="text u-line-height-1-5">
You have no users. Create a user to see them here.
</p>
<p class="text u-line-height-1-5">
Need a hand? Learn more in our <a
href="https://appwrite.io/docs/products/auth/quick-start"
target="_blank"
rel="noopener noreferrer">
documentation</a
>.
</p>
</div>
</div>
</EmptySearch>
<Card.Base padding="none">
<Empty title="You have no users. Create a user to see them here." type="secondary">
<Typography.Text slot="description">
Need a hand? Learn more in our <Link.Anchor
href="https://appwrite.io/docs/products/auth/quick-start"
target="_blank"
rel="noopener noreferrer">
documentation</Link.Anchor
>.
</Typography.Text>
</Empty>
</Card.Base>
{/if}
<svelte:fragment slot="footer">
+1 -1
View File
@@ -18,7 +18,7 @@
export let external = false;
export let href: string = null;
export let download: string = undefined;
export let badge: string = null;
export let badge: string = undefined;
export let fullWidth = false;
export let fullWidthMobile = false;
export let ariaLabel: string = null;
+28 -64
View File
@@ -1,13 +1,13 @@
<script lang="ts">
import { onMount } from 'svelte';
import { Helper, Label } from '.';
import NullCheckbox from './nullCheckbox.svelte';
import { Input } from '@appwrite.io/pink-svelte';
export let label: string;
export let showLabel = true;
export let optionalText: string | undefined = undefined;
export let label: string = undefined;
export let id: string;
export let value: string;
export let name: string = id;
export let helper: string = undefined;
export let value = '';
export let placeholder = '';
export let required = false;
export let nullable = false;
export let disabled = false;
@@ -16,78 +16,42 @@
export let autocomplete = false;
export let step: number | 'any' = 0.001;
let element: HTMLInputElement;
let error: string;
onMount(() => {
if (element && autofocus) {
element.focus();
}
});
function handleInvalid(event: Event) {
event.preventDefault();
if (element.validity.valueMissing) {
if (event.currentTarget.validity.valueMissing) {
error = 'This field is required';
return;
}
error = element.validationMessage;
}
function handleInput(event: Event) {
const { value: currentValue } = event.currentTarget as HTMLInputElement;
value = currentValue || null;
}
let prevValue = '';
function handleNullChange(e: CustomEvent<boolean>) {
const isNull = e.detail;
if (isNull) {
prevValue = value;
value = null;
} else {
value = prevValue;
}
error = event.currentTarget.validationMessage;
}
$: if (value) {
error = null;
}
$: isNullable = nullable && !required;
</script>
<Label {required} {optionalText} hide={!showLabel} for={id}>
<Input.DateTime
{id}
{name}
{placeholder}
{disabled}
{required}
{label}
</Label>
<div class="input-text-wrapper">
<input
{id}
{disabled}
{readonly}
{required}
{value}
{step}
autocomplete={autocomplete ? 'on' : 'off'}
type="datetime-local"
class="input-text"
bind:this={element}
on:input={handleInput}
on:invalid={handleInvalid}
style:--amount-of-buttons={isNullable ? 2.75 : 1}
style:--button-size={isNullable ? '2rem' : '1rem'} />
{#if isNullable}
<ul
class="buttons-list u-cross-center u-gap-8 u-position-absolute u-inset-block-start-8 u-inset-block-end-8 u-inset-inline-end-12">
<li class="buttons-list-item">
<NullCheckbox checked={value === null} on:change={handleNullChange} />
</li>
</ul>
{/if}
</div>
{#if error}
<Helper type="warning">{error}</Helper>
{/if}
{step}
{nullable}
{readonly}
autofocus={autofocus || undefined}
autocomplete={autocomplete ? 'on' : 'off'}
helper={error || helper}
state={error ? 'error' : 'default'}
on:invalid={handleInvalid}
on:input
bind:value>
<slot name="start" slot="start" />
<slot name="info" slot="info" />
<slot name="end" slot="end" />
</Input.DateTime>
+11 -103
View File
@@ -1,113 +1,19 @@
<script lang="ts">
import { DropList } from '$lib/components';
import { clickOnEnter } from '$lib/helpers/a11y';
import { createEventDispatcher, onMount } from 'svelte';
import { Helper, Label } from '.';
import { Input } from '@appwrite.io/pink-svelte';
import type ComboBox from '@appwrite.io/pink-svelte/dist/input/ComboBox.svelte';
import type { ComponentProps } from 'svelte';
/* eslint no-undef: "off" */
type Option = $$Generic<{
value: string | boolean | number;
label: string;
data?: unknown[];
}>;
type OptionArray = Option[];
export let options: OptionArray;
export let options: ComponentProps<ComboBox>['options'];
export let id: string;
export let label: string;
export let name = 'elements';
export let optionalText: string | undefined = undefined;
export let tooltip: string | undefined = undefined;
export let showLabel = true;
export let placeholder = '';
export let required = false;
export let hideRequired = false;
export let disabled = false;
export let fullWidth = false;
export let autofocus = false;
export let interactiveOutput = false;
export let interactiveEmpty = false;
export let hideEmpty = false;
// stretch is used inside of a flex container to give the element flex:1
export let stretch = true;
export let search = '';
// The actual selected value
export let value: Option['value'];
$: selectedOption = options.find((option) => option.value === value);
export let value: ComponentProps<ComboBox>['value'];
let element: HTMLInputElement;
let hasFocus = false;
let selected: number = null;
let error: string;
$: if (!hasFocus) {
selected = null;
}
const dispatch = createEventDispatcher();
onMount(() => {
if (element && autofocus) {
element.focus();
}
});
function handleInput() {
if (hideEmpty && !options?.length) hasFocus = false;
else hasFocus = true;
}
function handleKeydown(event: KeyboardEvent) {
event.stopImmediatePropagation();
switch (event.key) {
case 'Escape':
hasFocus = false;
break;
case 'ArrowDown':
if (selected === null) {
selected = 0;
} else {
selected = (selected + 1) % options.length;
}
break;
case 'ArrowUp':
if (selected === null) {
selected = options.length - 1;
} else {
selected = (selected - 1 + options.length) % options.length;
}
break;
case 'Enter':
if (selected !== null) {
event.preventDefault();
selectOption(options[selected]);
}
break;
}
}
function selectOption(option: Option) {
value = option.value;
search = option.label;
// It's not working without this line.
if (!$$slots.output) {
element.value = search;
} else {
search = '';
}
hasFocus = false;
dispatch('select', option);
}
function clearOption() {
search = '';
value = null;
!$$slots.output && (element.value = search);
hasFocus = false;
dispatch('reset');
}
let error: string | null;
function handleInvalid(event: Event) {
event.preventDefault();
@@ -119,10 +25,12 @@
error = element.validationMessage;
}
$: showClearBtn = (hasFocus && search) || value;
$: if (value || search) error = null;
$: if (value) error = null;
</script>
<!-- <Input.ComboBox {label} {id} {placeholder} {disabled} {name} bind:value {required} {options} /> -->
<!--
<div
class="u-position-relative form-item"
class:u-width-full-line={fullWidth}
@@ -235,7 +143,7 @@
{#if error}
<Helper class="u-position-relative" type="warning">{error}</Helper>
{/if}
</div>
</div> -->
<style>
.form-item :global(.drop) {
+2 -1
View File
@@ -3,6 +3,7 @@
export let label: string = undefined;
export let id: string;
export let name: string = id;
export let helper: string = undefined;
export let value = '';
export let placeholder = '';
export let required = false;
@@ -43,7 +44,7 @@
{readonly}
autofocus={autofocus || undefined}
autocomplete={autocomplete ? 'on' : 'off'}
helper={error}
helper={error || helper}
state={error ? 'error' : 'default'}
on:invalid={handleInvalid}
on:input
@@ -1,20 +1,20 @@
<script lang="ts">
import { base } from '$app/paths';
import { page } from '$app/stores';
import { DropList, DropListItem, Empty, Heading } from '$lib/components';
import { Pill } from '$lib/elements';
import { Empty } from '$lib/components';
import { Button } from '$lib/elements/forms';
import {
Table,
TableBody,
TableCell,
TableCellHead,
TableCellText,
TableHeader,
TableRow
} from '$lib/elements/table';
import { Container } from '$lib/layout';
import { canWriteCollections } from '$lib/stores/roles';
import {
ActionMenu,
Badge,
Icon,
Layout,
Link,
Popover,
Table,
Typography
} from '@appwrite.io/pink-svelte';
import Create from '../createAttribute.svelte';
import { isRelationship } from '../document-[document]/attributes/store';
import FailedModal from '../failedModal.svelte';
@@ -24,6 +24,17 @@
import Delete from './deleteAttribute.svelte';
import Edit from './edit.svelte';
import { attributeOptions, type Option } from './store';
import {
IconArrowSmRight,
IconDotsHorizontal,
IconLink,
IconLocationMarker,
IconPencil,
IconPlus,
IconSwitchHorizontal,
IconTrash
} from '@appwrite.io/pink-icons-svelte';
import type { ComponentProps } from 'svelte';
const projectId = $page.params.project;
const databaseId = $page.params.database;
@@ -38,162 +49,146 @@
let showFailed = false;
let error = '';
enum attributeFormatIcon {
ip = 'location-marker',
url = 'link',
email = 'mail',
enum = 'view-list'
const attributeFormatIcon = {
ip: IconLocationMarker,
url: IconLink,
email: IconLink,
enum: IconSwitchHorizontal
};
function getAttributeStatusBadge(status: string): ComponentProps<Badge>['type'] {
switch (status) {
case 'processing':
return 'warning';
case 'deleting':
case 'stuck':
case 'failed':
return 'error';
default:
return undefined;
}
}
</script>
<Container>
<div class="u-flex u-gap-12 common-section u-main-space-between">
<Heading tag="h2" size="5">Attributes</Heading>
<Layout.Stack direction="row" justifyContent="space-between">
<Typography.Title>Attributes</Typography.Title>
{#if $canWriteCollections}
<CreateAttributeDropdown bind:selectedOption bind:showCreate />
{/if}
</div>
</Layout.Stack>
{#if $attributes.length}
<Table>
<TableHeader>
<TableCellHead>Key</TableCellHead>
<TableCellHead onlyDesktop>Type</TableCellHead>
<TableCellHead onlyDesktop>Default Value</TableCellHead>
<TableCellHead width={30} />
</TableHeader>
<TableBody>
{#each $attributes as attribute, index}
{@const option = attributeOptions.find(
(option) => option.type === attribute.type
)}
<TableRow>
<TableCell title="Key">
<div class="u-flex u-main-space-between u-cross-center">
<div class="u-flex u-cross-center u-gap-16">
<div class="avatar is-size-small u-color-text-gray">
{#if isRelationship(attribute)}
<span
class={`icon-${
attribute?.twoWay
? 'switch-horizontal'
: 'arrow-sm-right'
}`}
aria-hidden="true" />
{:else if 'format' in attribute && attribute.format}
{@const icon = attributeFormatIcon[attribute?.format]}
<span class={`icon-${icon}`} aria-hidden="true" />
{:else}
<span
class={`icon-${option.icon}`}
aria-hidden="true" />
{/if}
</div>
<span class="text u-trim-1" data-private>{attribute.key}</span>
</div>
{#if attribute.status !== 'available'}
<div class="u-inline-flex u-gap-12 u-cross-center">
<Pill
warning={attribute.status === 'processing'}
danger={['deleting', 'stuck', 'failed'].includes(
attribute.status
)}>
{attribute.status}
</Pill>
{#if attribute.error}
<Button
link
on:click={(e) => {
e.preventDefault();
error = attribute.error;
showFailed = true;
}}>Details</Button>
{/if}
</div>
{:else if attribute.required}
<Pill>Required</Pill>
{/if}
</div>
</TableCell>
<TableCellText onlyDesktop title="Type">
{#if 'format' in attribute && attribute.format}
<span class="u-capitalize">{attribute.format}</span>
<Table.Root>
<svelte:fragment slot="header">
<Table.Header.Cell>Key</Table.Header.Cell>
<Table.Header.Cell>Type</Table.Header.Cell>
<Table.Header.Cell>Default value</Table.Header.Cell>
<Table.Header.Cell width="40px" />
</svelte:fragment>
{#each $attributes as attribute, index}
{@const option = attributeOptions.find((option) => option.type === attribute.type)}
<Table.Row>
<Table.Cell>
<Layout.Stack direction="row" alignItems="center">
{#if isRelationship(attribute)}
<Icon
size="s"
icon={attribute?.twoWay
? IconSwitchHorizontal
: IconArrowSmRight} />
{:else if 'format' in attribute && attribute.format}
{@const icon = attributeFormatIcon[attribute?.format]}
<Icon {icon} size="s" />
{:else}
<span class="u-capitalize">{attribute.type}</span>
{#if isRelationship(attribute)}
<span>
with <a
href={`${base}/project-${projectId}/databases/database-${databaseId}/collection-${attribute?.relatedCollection}`}
><b data-private>{attribute?.key}</b></a>
</span>
{/if}
<Icon icon={option.icon} size="s" />
{/if}
<span>
{attribute.array ? '[]' : ''}
</span>
</TableCellText>
<TableCellText onlyDesktop title="Default Value">
{attribute?.default !== null && attribute?.default !== undefined
? attribute?.default
: '-'}
</TableCellText>
<TableCell showOverflow>
<DropList
bind:show={showDropdown[index]}
placement="bottom-start"
noArrow>
<button
class="button is-only-icon is-text"
aria-label="More options"
on:click|preventDefault={() => {
showDropdown[index] = !showDropdown[index];
<span class="text u-trim-1" data-private>{attribute.key}</span>
{#if attribute.status !== 'available'}
<Badge
size="s"
variant="secondary"
content={attribute.status}
type={getAttributeStatusBadge(attribute.status)} />
{#if attribute.error}
<Link.Button
variant="muted"
on:click={(e) => {
e.preventDefault();
error = attribute.error;
showFailed = true;
}}>Details</Link.Button>
{/if}
{:else if attribute.required}
<Badge size="s" variant="secondary" content="required" />
{/if}
</Layout.Stack>
</Table.Cell>
<Table.Cell>
{#if 'format' in attribute && attribute.format}
<span class="u-capitalize">{attribute.format}</span>
{:else}
<span class="u-capitalize">{attribute.type}</span>
{#if isRelationship(attribute)}
<span>
with <a
href={`${base}/project-${projectId}/databases/database-${databaseId}/collection-${attribute?.relatedCollection}`}
><b data-private>{attribute?.key}</b></a>
</span>
{/if}
{/if}
<span>
{attribute.array ? '[]' : ''}
</span>
</Table.Cell>
<Table.Cell>
{attribute?.default !== null && attribute?.default !== undefined
? attribute?.default
: '-'}
</Table.Cell>
<Table.Cell>
<Popover let:toggle padding="none" placement="bottom-end">
<Button text icon ariaLabel="more options" on:click={toggle}>
<Icon icon={IconDotsHorizontal} size="s" />
</Button>
<ActionMenu.Root slot="tooltip">
<ActionMenu.Item.Button
leadingIcon={IconPencil}
on:click={() => {
selectedAttribute = attribute;
showEdit = true;
showDropdown[index] = false;
}}>
<span class="icon-dots-horizontal" aria-hidden="true" />
</button>
<svelte:fragment slot="list">
<DropListItem
event="edit_attribute"
icon="pencil"
Update
</ActionMenu.Item.Button>
{#if !isRelationship(attribute)}
<ActionMenu.Item.Button
leadingIcon={IconPlus}
on:click={() => {
selectedAttribute = attribute;
showEdit = true;
showCreateIndex = true;
showDropdown[index] = false;
}}>
Update
</DropListItem>
{#if !isRelationship(attribute)}
<DropListItem
icon="plus"
on:click={() => {
selectedAttribute = attribute;
showCreateIndex = true;
showDropdown[index] = false;
}}>
Create Index
</DropListItem>
{/if}
{#if attribute.status !== 'processing'}
<DropListItem
icon="trash"
on:click={() => {
selectedAttribute = attribute;
showDelete = true;
showDropdown[index] = false;
}}>
Delete
</DropListItem>
{/if}
</svelte:fragment>
</DropList>
</TableCell>
</TableRow>
{/each}
</TableBody>
</Table>
<div class="u-flex common-section u-main-space-between">
<p class="text">Total results: {$attributes.length}</p>
</div>
Create index
</ActionMenu.Item.Button>
{/if}
{#if attribute.status !== 'processing'}
<ActionMenu.Item.Button
leadingIcon={IconTrash}
on:click={() => {
selectedAttribute = attribute;
showDelete = true;
showDropdown[index] = false;
}}>
Delete
</ActionMenu.Item.Button>
{/if}
</ActionMenu.Root>
</Popover>
</Table.Cell>
</Table.Row>
{/each}
</Table.Root>
{:else}
<Empty single target="attribute">
<svelte:fragment slot="actions">
@@ -215,8 +210,18 @@
{/if}
</Container>
<Create bind:showCreate bind:selectedOption />
<Delete bind:showDelete {selectedAttribute} />
<Edit bind:showEdit {selectedAttribute} />
<CreateIndex bind:showCreateIndex externalAttribute={selectedAttribute} />
<FailedModal bind:show={showFailed} title="Create attribute" header="Creation failed" {error} />
{#if showCreate}
<Create bind:showCreate bind:selectedOption />
{/if}
{#if showDelete}
<Delete bind:showDelete {selectedAttribute} />
{/if}
{#if showEdit}
<Edit bind:showEdit {selectedAttribute} />
{/if}
{#if showCreateIndex}
<CreateIndex bind:showCreateIndex externalAttribute={selectedAttribute} />
{/if}
{#if showFailed}
<FailedModal bind:show={showFailed} title="Create attribute" header="Creation failed" {error} />
{/if}
@@ -42,6 +42,7 @@
export let data: Partial<Models.AttributeDatetime>;
import { createConservative } from '$lib/helpers/stores';
import { Selector } from '@appwrite.io/pink-svelte';
let savedDefault = data.default;
@@ -73,10 +74,18 @@
bind:value={data.default}
disabled={data.required || data.array}
nullable={!data.required && !data.array} />
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
Indicate whether this is a required attribute
</InputChoice>
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
Indicate whether this attribute should act as an array, with the default value set as an empty
array.
</InputChoice>
<Selector.Checkbox
size="s"
id="required"
label="Required"
bind:checked={data.required}
disabled={data.array}
description="Indicate whether this attribute is required" />
<Selector.Checkbox
size="s"
id="array"
label="Array"
bind:checked={data.array}
disabled={data.required || editing}
description="Indicate whether this attribute should act as an array, with the default value set as an empty
array." />
@@ -53,6 +53,7 @@
}
$: onShow(showEdit);
$: title = `Update ${attributeOptions.find((v) => v.name === option.name)?.sentenceName ?? ''} attribute`;
function onShow(show: boolean) {
if (show) {
@@ -65,13 +66,7 @@
}
</script>
<Modal
{error}
size="big"
bind:show={showEdit}
onSubmit={submit}
icon={option?.icon}
iconNotMobile={option?.type === 'relationship'}>
<Modal {error} bind:show={showEdit} onSubmit={submit} {title}>
<svelte:fragment slot="title">
<div class="u-flex u-cross-center u-gap-8">
{option?.name}
@@ -43,6 +43,7 @@
export let data: Partial<Models.AttributeEmail>;
import { createConservative } from '$lib/helpers/stores';
import { Selector } from '@appwrite.io/pink-svelte';
let savedDefault = data.default;
@@ -75,10 +76,18 @@
bind:value={data.default}
disabled={data.required || data.array}
nullable={!data.required && !data.array} />
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
Indicate whether this is a required attribute
</InputChoice>
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
Indicate whether this attribute should act as an array, with the default value set as an empty
array.
</InputChoice>
<Selector.Checkbox
size="s"
id="required"
label="Required"
bind:checked={data.required}
disabled={data.array}
description="Indicate whether this attribute is required" />
<Selector.Checkbox
size="s"
id="array"
label="Array"
bind:checked={data.array}
disabled={data.required || editing}
description="Indicate whether this attribute should act as an array, with the default value set as an empty
array." />
@@ -44,6 +44,7 @@
export let data: Partial<Models.AttributeEnum>;
import { createConservative } from '$lib/helpers/stores';
import { Selector } from '@appwrite.io/pink-svelte';
let savedDefault = data.default;
@@ -99,10 +100,18 @@
placeholder="Select a value"
{options}
bind:value={data.default} />
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
Indicate whether this is a required attribute
</InputChoice>
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
Indicate whether this attribute should act as an array, with the default value set as an empty
array.
</InputChoice>
<Selector.Checkbox
size="s"
id="required"
label="Required"
bind:checked={data.required}
disabled={data.array}
description="Indicate whether this attribute is required" />
<Selector.Checkbox
size="s"
id="array"
label="Array"
bind:checked={data.array}
disabled={data.required || editing}
description="Indicate whether this attribute should act as an array, with the default value set as an empty
array." />
@@ -52,6 +52,7 @@
};
import { createConservative } from '$lib/helpers/stores';
import { Layout, Selector } from '@appwrite.io/pink-svelte';
let savedDefault = data.default;
@@ -77,28 +78,22 @@
$: handleDefaultState($required || $array);
</script>
<div>
<ul class="u-flex u-gap-16">
<li class="u-flex-basis-50-percent">
<InputNumber
id="min"
label="Min"
placeholder="Enter size"
bind:value={data.min}
step="any"
required={editing} />
</li>
<li class="u-flex-basis-50-percent">
<InputNumber
id="max"
label="Max"
placeholder="Enter size"
bind:value={data.max}
step="any"
required={editing} />
</li>
</ul>
</div>
<Layout.Stack direction="row" gap="s">
<InputNumber
id="min"
label="Min"
placeholder="Enter size"
bind:value={data.min}
step="any"
required={editing} />
<InputNumber
id="max"
label="Max"
placeholder="Enter size"
bind:value={data.max}
step="any"
required={editing} />
</Layout.Stack>
<InputNumber
id="default"
label="Default value"
@@ -109,10 +104,18 @@
disabled={data.required || data.array}
nullable={!data.required && !data.array}
step="any" />
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
Indicate whether this is a required attribute
</InputChoice>
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
Indicate whether this attribute should act as an array, with the default value set as an empty
array.
</InputChoice>
<Selector.Checkbox
size="s"
id="required"
label="Required"
bind:checked={data.required}
disabled={data.array}
description="Indicate whether this attribute is required" />
<Selector.Checkbox
size="s"
id="array"
label="Array"
bind:checked={data.array}
disabled={data.required || editing}
description="Indicate whether this attribute should act as an array, with the default value set as an empty
array." />
@@ -52,6 +52,7 @@
export let editing = false;
import { createConservative } from '$lib/helpers/stores';
import { Layout, Selector } from '@appwrite.io/pink-svelte';
let savedDefault = data.default;
@@ -77,27 +78,20 @@
$: handleDefaultState($required || $array);
</script>
<div>
<ul class="u-flex u-gap-16">
<li class="u-flex-basis-50-percent">
<InputNumber
id="min"
label="Min"
placeholder="Enter size"
bind:value={data.min}
required={editing} />
</li>
<li class="u-flex-basis-50-percent">
<InputNumber
id="max"
label="Max"
placeholder="Enter size"
bind:value={data.max}
required={editing} />
</li>
</ul>
</div>
<Layout.Stack direction="row" gap="s">
<InputNumber
id="min"
label="Min"
placeholder="Enter size"
bind:value={data.min}
required={editing} />
<InputNumber
id="max"
label="Max"
placeholder="Enter size"
bind:value={data.max}
required={editing} />
</Layout.Stack>
<InputNumber
id="default"
label="Default value"
@@ -107,10 +101,18 @@
bind:value={data.default}
disabled={data.required || data.array}
nullable={!data.required && !data.array} />
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
Indicate whether this is a required attribute
</InputChoice>
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
Indicate whether this attribute should act as an array, with the default value set as an empty
array.
</InputChoice>
<Selector.Checkbox
size="s"
id="required"
label="Required"
bind:checked={data.required}
disabled={data.array}
description="Indicate whether this attribute is required" />
<Selector.Checkbox
size="s"
id="array"
label="Array"
bind:checked={data.array}
disabled={data.required || editing}
description="Indicate whether this attribute should act as an array, with the default value set as an empty
array." />
@@ -41,6 +41,7 @@
export let data: Partial<Models.AttributeIp>;
import { createConservative } from '$lib/helpers/stores';
import { Selector } from '@appwrite.io/pink-svelte';
let savedDefault = data.default;
@@ -73,10 +74,18 @@
bind:value={data.default}
disabled={data.required || data.array}
nullable={!data.required && !data.array} />
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
Indicate whether this is a required attribute
</InputChoice>
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
Indicate whether this attribute should act as an array, with the default value set as an empty
array.
</InputChoice>
<Selector.Checkbox
size="s"
id="required"
label="Required"
bind:checked={data.required}
disabled={data.array}
description="Indicate whether this attribute is required" />
<Selector.Checkbox
size="s"
id="array"
label="Array"
bind:checked={data.array}
disabled={data.required || editing}
description="Indicate whether this attribute should act as an array, with the default value set as an empty
array." />
@@ -57,6 +57,8 @@
import { camelize } from '$lib/helpers/string';
import { SelectSearchItem } from '$lib/elements';
import { isValueOfStringEnum } from '$lib/helpers/types';
import { Card, Layout } from '@appwrite.io/pink-svelte';
import { IconArrowSmRight, IconSwitchHorizontal } from '@appwrite.io/pink-icons-svelte';
// Props
export let data: Models.AttributeRelationship;
@@ -130,99 +132,68 @@
}
</script>
<li>
<ul
class="grid-box"
style="--p-grid-item-size:16em; --p-grid-item-size-small-screens:16rem; --grid-gap: 0.5rem;">
<li>
<LabelCard
name="relationship"
bind:group={way}
value="one"
icon="arrow-sm-right"
disabled={editing}>
<svelte:fragment slot="title">One-way relationship</svelte:fragment>
One Relation attribute within this collection
</LabelCard>
</li>
<li>
<LabelCard
name="relationship"
bind:group={way}
value="two"
icon="switch-horizontal"
disabled={editing}>
<svelte:fragment slot="title">Two-way relationship</svelte:fragment>
One Relation attribute within this collection and another within the related collection
</LabelCard>
</li>
</ul>
</li>
<Layout.Stack direction="row" wrap="wrap">
<Card.Selector
title="One-way relationship"
bind:group={way}
name="one"
value="one"
icon={IconArrowSmRight}>
<p>One Relation attribute within this collection</p>
</Card.Selector>
<Card.Selector
title="Two-way relationship"
bind:group={way}
name="two"
value="two"
icon={IconSwitchHorizontal}>
<p>
One Relation attribute within this collection and another within the related collection
</p>
</Card.Selector>
</Layout.Stack>
<div>
<InputSelect
required
id="related"
label="Related collection"
placeholder="Select a collection"
bind:value={data.relatedCollection}
on:change={updateKeyName}
options={collections?.map((n) => ({ value: n.$id, label: `${n.name} (${n.$id})` })) ?? []} />
<!-- <div>
<InputSelectSearch
id="related"
label="Related Collection"
name="collections"
bind:search
bind:value={data.relatedCollection}
required
interactiveOutput={!editing}
placeholder="Select a collection"
disabled={editing}
options={collections?.map((n) => ({ value: n.$id, label: n.$id, data: [n.name] })) ?? []}
on:select={updateKeyName}
let:option={o}>
<SelectSearchItem data={o.data}>
{o.label}
</SelectSearchItem>
<svelte:fragment slot="output" let:option={o}>
<output class="input-text" class:is-read-only={editing}>
<SelectSearchItem data={o.data}>
{o.label}
</SelectSearchItem>
</output>
</svelte:fragment>
on:select={updateKeyName}>
</InputSelectSearch>
</div>
</div> -->
{#if data?.relatedCollection}
<div>
<InputText
id="key"
label="Attribute Key"
placeholder="Enter Key"
bind:value={data.key}
autofocus
required />
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
<span
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
aria-hidden="true" />
<span class="text u-line-height-1-5">Allowed characters: a-z, A-Z, 0-9, -, .</span>
</div>
</div>
<InputText
id="key"
label="Attribute key"
placeholder="Enter key"
bind:value={data.key}
autofocus
helper="Allowed characters: a-z, A-Z, 0-9, -, ."
required />
{#if way === 'two'}
<div>
<InputText
id="keyRelated"
label="Attribute Key (related collection)"
placeholder="Enter Key"
bind:value={data.twoWayKey}
required
readonly={editing} />
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
<span
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
aria-hidden="true" />
<span class="text u-line-height-1-5">
Allowed characters: a-z, A-Z, 0-9, -, . Once created, attribute key cannot be
adjusted to maintain data integrity.
</span>
</div>
</div>
<InputText
id="keyRelated"
label="Attribute key (related collection)"
placeholder="Enter key"
bind:value={data.twoWayKey}
required
helper="Allowed characters: a-z, A-Z, 0-9, -, . Once created, attribute key cannot be
adjusted to maintain data integrity."
readonly={editing} />
{/if}
<InputSelect
@@ -35,6 +35,7 @@ export type Option = {
| 'URL'
| 'Enum'
| 'Relationship';
sentenceName: string;
component: typeof SvelteComponent<unknown>;
type: 'string' | 'integer' | 'double' | 'boolean' | 'datetime' | 'relationship';
create: (
@@ -56,6 +57,7 @@ export type Option = {
export const attributeOptions: Option[] = [
{
name: 'String',
sentenceName: 'string',
component: String,
type: 'string',
create: submitString,
@@ -64,6 +66,7 @@ export const attributeOptions: Option[] = [
},
{
name: 'Integer',
sentenceName: 'integer',
component: Integer,
type: 'integer',
create: submitInteger,
@@ -72,6 +75,7 @@ export const attributeOptions: Option[] = [
},
{
name: 'Float',
sentenceName: 'float',
component: Float,
type: 'double',
create: submitFloat,
@@ -80,6 +84,7 @@ export const attributeOptions: Option[] = [
},
{
name: 'Boolean',
sentenceName: 'boolean',
component: Boolean,
type: 'boolean',
create: submitBoolean,
@@ -88,6 +93,7 @@ export const attributeOptions: Option[] = [
},
{
name: 'Datetime',
sentenceName: 'datetime',
component: Datetime,
type: 'datetime',
create: submitDatetime,
@@ -96,6 +102,7 @@ export const attributeOptions: Option[] = [
},
{
name: 'Email',
sentenceName: 'email',
component: Email,
type: 'string',
format: 'email',
@@ -105,6 +112,7 @@ export const attributeOptions: Option[] = [
},
{
name: 'IP',
sentenceName: 'IP',
component: Ip,
type: 'string',
format: 'ip',
@@ -114,6 +122,7 @@ export const attributeOptions: Option[] = [
},
{
name: 'URL',
sentenceName: 'URL',
component: Url,
type: 'string',
format: 'url',
@@ -123,6 +132,7 @@ export const attributeOptions: Option[] = [
},
{
name: 'Enum',
sentenceName: 'enum',
component: Enum,
type: 'string',
format: 'enum',
@@ -132,6 +142,7 @@ export const attributeOptions: Option[] = [
},
{
name: 'Relationship',
sentenceName: 'relationship',
component: Relationship,
type: 'relationship',
create: submitRelationship,
@@ -39,6 +39,7 @@
<script lang="ts">
import { InputChoice, InputNumber, InputText, InputTextarea } from '$lib/elements/forms';
import { createConservative } from '$lib/helpers/stores';
import { Selector } from '@appwrite.io/pink-svelte';
export let data: Partial<Models.AttributeString> = {
required: false,
@@ -97,10 +98,18 @@
maxlength={data.size}
bind:value={data.default} />
{/if}
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
Indicate whether this is a required attribute
</InputChoice>
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
Indicate whether this attribute should act as an array, with the default value set as an empty
array.
</InputChoice>
<Selector.Checkbox
size="s"
id="required"
label="Required"
bind:checked={data.required}
disabled={data.array}
description="Indicate whether this attribute is required" />
<Selector.Checkbox
size="s"
id="array"
label="Array"
bind:checked={data.array}
disabled={data.required || editing}
description="Indicate whether this attribute should act as an array, with the default value set as an empty
array." />
@@ -42,6 +42,7 @@
export let editing = false;
import { createConservative } from '$lib/helpers/stores';
import { Selector } from '@appwrite.io/pink-svelte';
let savedDefault = data.default;
@@ -74,10 +75,18 @@
bind:value={data.default}
disabled={data.required || data.array}
nullable={!data.required && !data.array} />
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
Indicate whether this is a required attribute
</InputChoice>
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
Indicate whether this attribute should act as an array, with the default value set as an empty
array.
</InputChoice>
<Selector.Checkbox
size="s"
id="required"
label="Required"
bind:checked={data.required}
disabled={data.array}
description="Indicate whether this attribute is required" />
<Selector.Checkbox
size="s"
id="array"
label="Array"
bind:checked={data.array}
disabled={data.required || editing}
description="Indicate whether this attribute should act as an array, with the default value set as an empty
array." />
@@ -64,27 +64,20 @@
default: null
};
}
$: title = `Create ${attributeOptions.find((option) => option.name === selectedOption)?.sentenceName ?? ''} attribute`;
</script>
<Modal {error} bind:show={showCreate} onSubmit={submit} title={selectedOption}>
<Modal {error} bind:show={showCreate} onSubmit={submit} {title}>
{#if selectedOption !== 'Relationship'}
<div>
<InputText
id="key"
label="Attribute Key"
placeholder="Enter Key"
bind:value={key}
autofocus
required />
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
<span
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
aria-hidden="true" />
<span class="text u-line-height-1-5">
Allowed characters: alphanumeric, hyphen, non-leading underscore, period.
</span>
</div>
</div>
<InputText
id="key"
label="Attribute key"
placeholder="Enter key"
bind:value={key}
autofocus
helper="Allowed characters: alphanumeric, hyphen, non-leading underscore, period."
required />
{/if}
{#if selectedOption}
<svelte:component this={$option.component} bind:data on:close={() => ($option = null)} />
@@ -1,5 +1,5 @@
<script lang="ts">
import { CardGrid, BoxAvatar, Heading, Alert } from '$lib/components';
import { CardGrid, BoxAvatar, Heading } from '$lib/components';
import { Container } from '$lib/layout';
import { Button } from '$lib/elements/forms';
import { sdk } from '$lib/stores/sdk';
@@ -13,6 +13,7 @@
import { Dependencies } from '$lib/constants';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { collection } from '../store';
import { Alert } from '@appwrite.io/pink-svelte';
let showDelete = false;
let permissions = $doc?.$permissions;
@@ -79,27 +80,30 @@
<svelte:fragment slot="aside">
{#if $collection.documentSecurity}
{#if showPermissionAlert}
<Alert type="info" dismissible on:dismiss={() => (showPermissionAlert = false)}>
<Alert.Inline
status="info"
dismissible
on:dismiss={() => (showPermissionAlert = false)}>
<svelte:fragment slot="title">Document security is enabled</svelte:fragment>
<p class="text">
Users will be able to access this document if they have been granted <b
>either document or collection permissions.
</b>
</p>
</Alert>
</Alert.Inline>
{/if}
{#if permissions}
<Permissions bind:permissions />
{/if}
{:else}
<Alert type="info">
<Alert.Inline status="info">
<svelte:fragment slot="title">Document security is disabled</svelte:fragment>
<p class="text">
If you want to assign document permissions. Go to Collection settings and
enable document security. Otherwise, only collection permissions will be
used.
</p>
</Alert>
</Alert.Inline>
{/if}
</svelte:fragment>
@@ -1,19 +1,19 @@
<script lang="ts">
import CustomId from '$lib/components/customId.svelte';
import Pill from '$lib/elements/pill.svelte';
import { Icon, Layout, Tag } from '@appwrite.io/pink-svelte';
import type { Attributes } from '../store';
import AttributeItem from './attributeItem.svelte';
import { IconPencil } from '@appwrite.io/pink-icons-svelte';
export let attributes: Attributes[] = [];
export let formValues: object = {};
export let customId: string | null | undefined = undefined;
export let gap: '16' | '24' | '32' = '32';
let showCustomId = false;
</script>
{#if attributes.length}
<ul class={`form-list u-gap-${gap}`}>
<Layout.Stack>
{#each attributes as attribute}
{@const label = attribute.key}
<AttributeItem {attribute} bind:formValues {label} />
@@ -21,16 +21,20 @@
{#if customId !== undefined}
{#if !showCustomId}
<div>
<Pill button on:click={() => (showCustomId = !showCustomId)}>
<span class="icon-pencil" aria-hidden="true" /><span class="text">
Document ID
</span>
</Pill>
</div>
<span>
<Tag size="s" on:click={() => (showCustomId = !showCustomId)}>
<Icon icon={IconPencil} slot="start" size="s" />
Document ID
</Tag>
</span>
{:else}
<CustomId autofocus bind:show={showCustomId} name="Document" bind:id={customId} />
<CustomId
autofocus
bind:show={showCustomId}
name="Document"
bind:id={customId}
fullWidth />
{/if}
{/if}
</ul>
</Layout.Stack>
{/if}
@@ -1,15 +1,6 @@
<script lang="ts">
import { Empty, DropList, DropListItem, Heading } from '$lib/components';
import { Pill } from '$lib/elements';
import {
Table,
TableHeader,
TableBody,
TableCellHead,
TableCell,
TableCellText,
TableRow
} from '$lib/elements/table';
import { Container } from '$lib/layout';
import { collection, indexes } from '../store';
import Delete from './deleteIndex.svelte';
@@ -22,8 +13,24 @@
import type { Option } from '../attributes/store';
import FailedModal from '../failedModal.svelte';
import { canWriteCollections } from '$lib/stores/roles';
import { Icon } from '@appwrite.io/pink-svelte';
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
import {
ActionMenu,
Badge,
Icon,
Layout,
Link,
Popover,
Table,
Typography
} from '@appwrite.io/pink-svelte';
import {
IconDotsHorizontal,
IconEye,
IconPencil,
IconPlus,
IconTrash
} from '@appwrite.io/pink-icons-svelte';
import type { ComponentProps } from 'svelte';
let showDropdown = [];
let selectedIndex: Models.Index = null;
@@ -35,12 +42,24 @@
let selectedAttribute: Option['name'] = null;
let showFailed = false;
let error = '';
function getAttributeStatusBadge(status: string): ComponentProps<Badge>['type'] {
switch (status) {
case 'processing':
return 'warning';
case 'deleting':
case 'stuck':
case 'failed':
return 'error';
default:
return undefined;
}
}
</script>
<Container>
<div class="u-flex u-gap-12 common-section u-main-space-between">
<Heading tag="h2" size="5">Indexes</Heading>
<Layout.Stack direction="row" justifyContent="space-between">
<Typography.Title>Indexes</Typography.Title>
{#if $canWriteCollections}
<Button
event="create_index"
@@ -50,89 +69,72 @@
Create index
</Button>
{/if}
</div>
</Layout.Stack>
{#if $collection?.attributes?.length}
{#if $indexes.length}
<Table>
<TableHeader>
<TableCellHead>Key</TableCellHead>
<TableCellHead onlyDesktop>Type</TableCellHead>
<TableCellHead onlyDesktop>Attributes</TableCellHead>
<TableCellHead onlyDesktop>Asc/Desc</TableCellHead>
<TableCellHead width={30} />
</TableHeader>
<TableBody>
{#each $indexes as index, i}
<TableRow>
<TableCell title="Key">
<div class="u-flex u-main-space-between">
<span class="text u-trim"> {index.key}</span>
{#if index.status !== 'available'}
<div class="u-inline-flex u-gap-12 u-cross-center">
<Pill
warning={index.status === 'processing'}
danger={['deleting', 'stuck', 'failed'].includes(
index.status
)}>
{index.status}
</Pill>
{#if index.error}
<Button
link
on:click={(e) => {
e.preventDefault();
error = index.error;
showFailed = true;
}}>Details</Button>
{/if}
</div>
<Table.Root>
<svelte:fragment slot="header">
<Table.Header.Cell>Key</Table.Header.Cell>
<Table.Header.Cell>Type</Table.Header.Cell>
<Table.Header.Cell>Attributes</Table.Header.Cell>
<Table.Header.Cell>Asc/Desc</Table.Header.Cell>
<Table.Header.Cell width="40px" />
</svelte:fragment>
{#each $indexes as index, i}
<Table.Row>
<Table.Cell>
<Layout.Stack direction="row" alignItems="center">
{index.key}
{#if index.status !== 'available'}
<Badge
size="s"
variant="secondary"
content={index.status}
type={getAttributeStatusBadge(index.status)} />
{#if index.error}
<Link.Button
variant="muted"
on:click={(e) => {
e.preventDefault();
error = index.error;
showFailed = true;
}}>Details</Link.Button>
{/if}
</div>
</TableCell>
<TableCellText title="Type" onlyDesktop>{index.type}</TableCellText>
<TableCellText title="Attributes" onlyDesktop>
{index.attributes}
</TableCellText>
<TableCellText title="ASC/DESC" onlyDesktop>
{index.orders}
</TableCellText>
<TableCell showOverflow>
<DropList
bind:show={showDropdown[i]}
placement="bottom-start"
noArrow>
<button
class="button is-only-icon is-text"
aria-label="More options"
on:click|preventDefault={() => {
showDropdown[i] = !showDropdown[i];
}}>
<span class="icon-dots-horizontal" aria-hidden="true" />
</button>
<svelte:fragment slot="list">
<DropListItem
icon="eye"
on:click={() => {
selectedIndex = index;
showOverview = true;
}}>Overview</DropListItem>
<DropListItem
icon="trash"
on:click={() => {
selectedIndex = index;
showDelete = true;
}}>Delete</DropListItem>
</svelte:fragment>
</DropList>
</TableCell>
</TableRow>
{/each}
</TableBody>
</Table>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {$indexes.length}</p>
</div>
{/if}
</Layout.Stack>
</Table.Cell>
<Table.Cell>{index.type}</Table.Cell>
<Table.Cell>
{index.attributes}
</Table.Cell>
<Table.Cell>
{index.orders}
</Table.Cell>
<Table.Cell>
<Popover let:toggle padding="none" placement="bottom-end">
<Button text icon ariaLabel="more options" on:click={toggle}>
<Icon icon={IconDotsHorizontal} size="s" />
</Button>
<ActionMenu.Root slot="tooltip">
<ActionMenu.Item.Button
leadingIcon={IconEye}
on:click={() => {
selectedIndex = index;
showOverview = true;
}}>Overview</ActionMenu.Item.Button>
<ActionMenu.Item.Button
leadingIcon={IconTrash}
on:click={() => {
selectedIndex = index;
showDelete = true;
}}>Delete</ActionMenu.Item.Button>
</ActionMenu.Root>
</Popover>
</Table.Cell>
</Table.Row>
{/each}
</Table.Root>
{:else}
<Empty
allowCreate={$canWriteCollections}
@@ -13,7 +13,7 @@
import { isRelationship } from '../document-[document]/attributes/store';
import { type Attributes, collection, indexes } from '../store';
import Select from './select.svelte';
import { Icon } from '@appwrite.io/pink-svelte';
import { Icon, Layout } from '@appwrite.io/pink-svelte';
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
export let showCreateIndex = false;
@@ -110,59 +110,61 @@
}
</script>
<Modal title="Create index" bind:error size="big" onSubmit={create} bind:show={showCreateIndex}>
<FormList>
<InputText id="key" label="Index Key" placeholder="Enter Key" bind:value={key} autofocus />
<InputSelect options={types} id="type" label="Index type" bind:value={selectedType} />
<Modal title="Create index" bind:error onSubmit={create} bind:show={showCreateIndex}>
<InputText
required
id="key"
label="Index Key"
placeholder="Enter Key"
bind:value={key}
autofocus />
<InputSelect required options={types} id="type" label="Index type" bind:value={selectedType} />
<Layout.Stack gap="s">
{#each attributeList as attribute, i}
<li class="form-item is-multiple">
<div class="form-item-part u-stretch">
<Select id={`attribute-${i}`} label="Attribute" bind:value={attribute.value}>
<option value="" disabled hidden>Select Attribute</option>
<optgroup label="Internal">
<option value="$id">$id</option>
<option value="$createdAt">$createdAt</option>
<option value="$updatedAt">$updatedAt</option>
</optgroup>
<optgroup label="Attributes">
{#each attributeOptions as option}
<option value={option.value}>
{option.label}
</option>
{/each}
</optgroup>
</Select>
</div>
<div class="form-item-part u-stretch">
<Select id={`order-${i}`} label="Order" bind:value={attribute.order}>
<option value="" disabled hidden>Select Order</option>
<option value="ASC"> ASC </option>
<option value="DESC"> DESC </option>
</Select>
</div>
<div class="form-item-part u-cross-child-end">
<Layout.Stack direction="row">
<InputSelect
required
options={[
{ value: '$id', label: '$id' },
{ value: '$createdAt', label: '$createdAt' },
{ value: '$updatedAt', label: '$updatedAt' },
...attributeOptions
]}
id={`attribute-${i}`}
label={i === 0 ? 'Attribute' : undefined}
placeholder="Select Attribute"
bind:value={attribute.value} />
<Layout.Stack direction="row" alignItems="flex-end" gap="xs">
<InputSelect
options={[
{ value: 'ASC', label: 'ASC' },
{ value: 'DESC', label: 'DESC' }
]}
required
id={`order-${i}`}
label={i === 0 ? 'Order' : undefined}
bind:value={attribute.order}
placeholder="Select Order" />
<Button
noMargin
text
icon
compact
disabled={attributeList.length <= 1}
on:click={() => {
attributeList = remove(attributeList, i);
}}>
<span class="icon-x" aria-hidden="true" />
</Button>
</div>
</li>
</Layout.Stack>
</Layout.Stack>
{/each}
<Button text on:click={addAttribute} disabled={addAttributeDisabled}>
<Icon icon={IconPlus} slot="start" size="s" />
Add attribute
</Button>
</FormList>
<div>
<Button secondary on:click={addAttribute} disabled={addAttributeDisabled}>
<Icon icon={IconPlus} slot="start" size="s" />
Add attribute
</Button>
</div>
</Layout.Stack>
<svelte:fragment slot="footer">
<Button secondary on:click={() => (showCreateIndex = false)}>Cancel</Button>
<Button submit>Create</Button>
@@ -1,6 +1,4 @@
<script lang="ts">
import { Modal } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { collection } from '../store';
import { sdk } from '$lib/stores/sdk';
@@ -10,6 +8,7 @@
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import Confirm from '$lib/components/confirm.svelte';
import { Typography } from '@appwrite.io/pink-svelte';
export let showDelete = false;
export let selectedIndex: Models.Index;
@@ -39,5 +38,7 @@
</script>
<Confirm onSubmit={handleDelete} title="Delete index" bind:open={showDelete} bind:error>
Are you sure you want to delete <b>'{selectedIndex.key}' from {$collection.name}</b>?
<Typography.Text>
Are you sure you want to delete <b>{selectedIndex.key}</b> from <b>{$collection.name}</b>?
</Typography.Text>
</Confirm>
@@ -1,57 +1,45 @@
<script lang="ts">
import { Modal } from '$lib/components';
import { InputText, FormList } from '$lib/elements/forms';
import { InputText } from '$lib/elements/forms';
import { Layout } from '@appwrite.io/pink-svelte';
import type { Models } from '@appwrite.io/console';
export let showOverview = false;
export let selectedIndex: Models.Index = null;
//TODO: add error message when index failed
</script>
<Modal title="Overview" size="big" bind:show={showOverview}>
<FormList>
<InputText
id="key"
label="Index Key"
placeholder="Enter Key"
value={selectedIndex.key}
readonly />
<InputText
id="type"
label="Index type"
placeholder="Select type"
value={selectedIndex.type}
readonly />
<Modal title="Overview" bind:show={showOverview}>
<InputText
required
id="key"
label="Index Key"
placeholder="Enter Key"
value={selectedIndex.key}
readonly />
<InputText
required
id="type"
label="Index type"
placeholder="Select type"
value={selectedIndex.type}
readonly />
{#if selectedIndex?.attributes?.length}
{#each selectedIndex.attributes as attribute, i}
<li class="form-item is-multiple">
<div class="form-item-part u-stretch">
<label class="label" for={`value-${attribute}`}>Attribute</label>
<div class="input-text-wrapper">
<input
id={`value-${attribute}`}
placeholder=""
type="text"
class="input-text"
value={attribute}
readonly />
</div>
</div>
<div class="form-item-part u-stretch">
<label class="label" for={`value-${selectedIndex.orders[i]}`}>Order</label>
<div class="input-text-wrapper">
<input
id={`value-${selectedIndex.orders[i]}`}
placeholder=""
type="text"
class="input-text"
value={selectedIndex.orders[i]}
readonly />
</div>
</div>
</li>
{/each}
{/if}
</FormList>
{#if selectedIndex?.attributes?.length}
{#each selectedIndex.attributes as attribute, i}
<Layout.Stack direction="row">
<InputText
required
label={i === 0 ? 'Attribute' : ''}
id={`value-${attribute}`}
value={attribute}
readonly />
<InputText
required
label={i === 0 ? 'Order' : ''}
id={`value-${selectedIndex.orders[i]}`}
value={selectedIndex.orders[i]}
readonly />
</Layout.Stack>
{/each}
{/if}
</Modal>
@@ -1,9 +1,11 @@
<script lang="ts">
import { base } from '$app/paths';
import { page } from '$app/stores';
import { ClickableList, ClickableListItem, Modal, Paginator } from '$lib/components';
import { Modal, Paginator } from '$lib/components';
import Id from '$lib/components/id.svelte';
import { preferences } from '$lib/stores/preferences';
import type { Models } from '@appwrite.io/console';
import { Table } from '@appwrite.io/pink-svelte';
export let show = false;
export let data: [];
@@ -23,35 +25,33 @@
}
</script>
<Modal bind:show>
<svelte:fragment slot="title">
<span data-private>
{selectedRelationship.key}
</span>
</svelte:fragment>
<Modal bind:show title={selectedRelationship?.key} hideFooter>
{#if data?.length}
<Paginator items={data} {limit} let:paginatedItems>
<ClickableList>
<Table.Root>
<svelte:fragment slot="header">
<Table.Header.Cell width="150px">Document ID</Table.Header.Cell>
{#if args?.length}
{#each args as arg}
<Table.Header.Cell>{arg}</Table.Header.Cell>
{/each}
{/if}
</svelte:fragment>
{#each paginatedItems as doc}
<ClickableListItem
<Table.Link
href={`${base}/project-${projectId}/databases/database-${databaseId}/collection-${selectedRelationship.relatedCollection}/document-${doc.$id}`}
on:click={() => (show = false)}>
<Table.Cell>
<Id value={doc.$id}>{doc.$id}</Id>
</Table.Cell>
{#if args?.length}
{#each args as arg, i}
{#if i}
<span class="clickable-list-title-sep">|</span>
{/if}
<span data-private>{doc[arg]}</span>
{#each args as arg}
<Table.Cell>{doc[arg]}</Table.Cell>
{/each}
{/if}
<svelte:fragment slot="desc">
{doc.$id}
</svelte:fragment>
</ClickableListItem>
</Table.Link>
{/each}
</ClickableList>
</Table.Root>
</Paginator>
{/if}
<svelte:fragment slot="footer" />
</Modal>
@@ -3,12 +3,11 @@
import { base } from '$app/paths';
import { page } from '$app/stores';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { Modal } from '$lib/components';
import Confirm from '$lib/components/confirm.svelte';
import { Dependencies } from '$lib/constants';
import { Button } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { Typography } from '@appwrite.io/pink-svelte';
import { collection } from '../store';
export let showDelete = false;
@@ -37,5 +36,7 @@
</script>
<Confirm onSubmit={handleDelete} title="Delete collection" bind:open={showDelete} bind:error>
Are you sure you want to delete <b>{$collection.name}</b>?
<Typography.Text>
Are you sure you want to delete <b>{$collection.name}</b>?
</Typography.Text>
</Confirm>
@@ -3,15 +3,15 @@
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { CardGrid, Heading } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button, Form, InputSelectSearch, InputText } from '$lib/elements/forms';
import { Button, Form, InputSelect, InputSelectSearch, InputText } from '$lib/elements/forms';
import { last, symmetricDifference } from '$lib/helpers/array';
import { addNotification } from '$lib/stores/notifications';
import type { Models } from '@appwrite.io/console';
import { attributes } from '../store';
import { preferences } from '$lib/stores/preferences';
import { page } from '$app/stores';
import { Icon } from '@appwrite.io/pink-svelte';
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
import { Icon, Layout } from '@appwrite.io/pink-svelte';
import { IconPlus, IconX } from '@appwrite.io/pink-icons-svelte';
const collectionId = $page.params.collection;
let names: string[] = [...(preferences.getDisplayNames()?.[collectionId] ?? [])];
@@ -63,75 +63,50 @@
You can specify up to 5 names.
<svelte:fragment slot="aside">
<div class="u-flex u-flex-vertical u-gap-4">
<ul class="u-flex-vertical u-gap-8">
<li class="u-flex u-gap-8">
<InputText
id="id"
label="Document ID"
showLabel={false}
placeholder="Document ID"
readonly
fullWidth />
<div class="form-item-part u-cross-child-end u-opacity-0">
<Button text noMargin disabled>
<span class="icon-x" aria-hidden="true" />
<Layout.Stack gap="s">
<Layout.Stack direction="row" gap="xxs">
<InputText id="id" value="Document ID" readonly />
<span style:visibility="hidden">
<Button icon extraCompact>
<Icon icon={IconX} />
</Button>
</span>
</Layout.Stack>
{#if names?.length}
{#each names as name, i}
<Layout.Stack direction="row" gap="xxs">
<InputSelect
id={name}
placeholder="Select attribute"
bind:value={names[i]}
disabled={!!names[i] && names.length > i + 1}
{options} />
<Button
icon
extraCompact
on:click={() => {
names.splice(i, 1);
names = names;
}}>
<Icon icon={IconX} />
</Button>
</div>
</li>
{#if names?.length}
{#each names as name, i}
<div class="u-flex u-gap-8">
{#if names[i]}
<InputSelectSearch
id={name}
label={name}
showLabel={false}
interactiveOutput
placeholder="Select attribute"
bind:value={names[i]}
bind:search={names[i]}
name="attributes"
disabled
{options} />
{:else}
<InputSelectSearch
id={name}
label={name}
showLabel={false}
placeholder="Select attribute"
bind:value={names[i]}
bind:search
name="attributes"
{options} />
{/if}
<div class="form-item-part u-cross-child-end">
<Button
text
noMargin
on:click={() => {
names.splice(i, 1);
names = names;
}}>
<span class="icon-x" aria-hidden="true" />
</Button>
</div>
</div>
{/each}
{/if}
</ul>
<Button
text
disabled={addAttributeDisabled}
on:click={() => {
names[names.length] = null;
search = null;
names = names;
}}>
<Icon icon={IconPlus} slot="start" size="s" />
Add attribute
</Button>
</div>
</Layout.Stack>
{/each}
{/if}
<div>
<Button
secondary
disabled={addAttributeDisabled}
on:click={() => {
names[names.length] = null;
search = null;
names = names;
}}>
<Icon icon={IconPlus} slot="start" size="s" />
Add attribute
</Button>
</div>
</Layout.Stack>
</svelte:fragment>
<svelte:fragment slot="actions">
@@ -2,7 +2,7 @@
import { invalidate } from '$app/navigation';
import { page } from '$app/stores';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { CardGrid, Heading } from '$lib/components';
import { CardGrid } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button, Form, InputText } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
@@ -48,14 +48,13 @@
<CardGrid>
<svelte:fragment slot="title">Name</svelte:fragment>
<svelte:fragment slot="aside">
<ul>
<InputText
id="name"
label="Name"
placeholder="Enter name"
autocomplete={false}
bind:value={collectionName} />
</ul>
<InputText
required
id="name"
label="Name"
placeholder="Enter name"
autocomplete={false}
bind:value={collectionName} />
</svelte:fragment>
<svelte:fragment slot="actions">
@@ -2,7 +2,7 @@
import { invalidate } from '$app/navigation';
import { page } from '$app/stores';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { CardGrid, Heading } from '$lib/components';
import { CardGrid } from '$lib/components';
import { Permissions } from '$lib/components/permissions';
import { Dependencies } from '$lib/constants';
import { Button } from '$lib/elements/forms';
@@ -11,6 +11,7 @@
import { sdk } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { collection } from '../store';
import { Link } from '@appwrite.io/pink-svelte';
const databaseId = $page.params.database;
@@ -58,13 +59,12 @@
<CardGrid>
<svelte:fragment slot="title">Permissions</svelte:fragment>
Choose who can access your collection and documents. For more about
<a
<Link.Anchor
href="https://appwrite.io/docs/products/databases/permissions"
target="_blank"
rel="noopener noreferrer"
class="link">
rel="noopener noreferrer">
Permissions
</a>.
</Link.Anchor>.
<svelte:fragment slot="aside">
{#if collectionPermissions}
<Permissions bind:permissions={collectionPermissions} withCreate />
@@ -5,19 +5,7 @@
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { Alert, FloatingActionBar, Id, Modal } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button, InputChoice } from '$lib/elements/forms';
import {
TableBody,
TableCell,
TableCellCheck,
TableCellHead,
TableCellHeadCheck,
TableCellText,
TableHeader,
TableRow,
TableRowLink,
TableScroll
} from '$lib/elements/table';
import { Button as ConsoleButton, InputChoice } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { preferences } from '$lib/stores/preferences';
import { sdk } from '$lib/stores/sdk';
@@ -27,10 +15,9 @@
import { isRelationship, isRelationshipToMany } from './document-[document]/attributes/store';
import RelationshipsModal from './relationshipsModal.svelte';
import { attributes, collection, columns } from './store';
import { clickOnEnter } from '$lib/helpers/a11y';
import type { ColumnType } from '$lib/helpers/types';
import { toLocaleDateTime } from '$lib/helpers/date';
import { Tooltip } from '@appwrite.io/pink-svelte';
import { Tooltip, Table, Selector, Button, Link } from '@appwrite.io/pink-svelte';
export let data: PageData;
@@ -159,110 +146,105 @@
let checked = false;
</script>
<TableScroll isSticky>
<TableHeader>
<TableCellHeadCheck
bind:selected={selectedDb}
pageItemsIds={data.documents.documents.map((d) => d.$id)} />
<TableCellHead width={150} eyebrow={false}>Document ID</TableCellHead>
<Table.Root>
<svelte:fragment slot="header">
<Table.Header.Selector width="40px" />
<Table.Header.Cell width="150px">Document ID</Table.Header.Cell>
{#each $columns.filter((n) => n.show) as column}
{#if column.show}
<TableCellHead eyebrow={false}>{column.title}</TableCellHead>
<Table.Header.Cell>{column.title}</Table.Header.Cell>
{/if}
{/each}
<TableCellHead eyebrow={false}>Created</TableCellHead>
<TableCellHead eyebrow={false}>Updated</TableCellHead>
</TableHeader>
<TableBody>
{#each data.documents.documents as document}
<TableRowLink
href={`${base}/project-${projectId}/databases/database-${databaseId}/collection-${$collection.$id}/document-${document.$id}`}>
<TableCellCheck bind:selectedIds={selectedDb} id={document.$id} />
<Table.Header.Cell>Created</Table.Header.Cell>
<Table.Header.Cell>Updated</Table.Header.Cell>
</svelte:fragment>
{#each data.documents.documents as document}
<Table.Link
href={`${base}/project-${projectId}/databases/database-${databaseId}/collection-${$collection.$id}/document-${document.$id}`}>
<Table.Cell>
<Selector.Checkbox size="s" />
</Table.Cell>
<Table.Cell width="150px">
{#key document.$id}
<Id value={document.$id}>
{document.$id}
</Id>
{/key}
</Table.Cell>
<TableCell width={150}>
{#key document.$id}
<Id value={document.$id}>
{document.$id}
</Id>
{/key}
</TableCell>
{#each $columns as column}
{#if column.show}
{@const attr = $attributes.find((n) => n.key === column.id)}
{#if isRelationship(attr)}
{@const args = displayNames?.[attr.relatedCollection] ?? ['$id']}
<TableCell title={column.title}>
{#if !isRelationshipToMany(attr)}
{#if document[column.id]}
{@const related = document[column.id]}
<div
tabindex="0"
class="link is-5px-offset u-trim-1 u-break-word"
role="button"
on:keyup={clickOnEnter}
on:click|preventDefault|stopPropagation={() =>
goto(
`${base}/project-${projectId}/databases/database-${databaseId}/collection-${attr.relatedCollection}/document-${related.$id}`
)}>
{#each args as arg, i}
{#if arg !== undefined}
{#if i}
&nbsp;|
{/if}
<span class="text" data-private>
{related?.[arg]}
</span>
{#each $columns as column}
{#if column.show}
{@const attr = $attributes.find((n) => n.key === column.id)}
{#if isRelationship(attr)}
{@const args = displayNames?.[attr.relatedCollection] ?? ['$id']}
<Table.Cell>
{#if !isRelationshipToMany(attr)}
{#if document[column.id]}
{@const related = document[column.id]}
<Link.Button
variant="muted"
on:click={(e) => {
e.preventDefault();
e.stopPropagation();
goto(
`${base}/project-${projectId}/databases/database-${databaseId}/collection-${attr.relatedCollection}/document-${related.$id}`
);
}}>
{#each args as arg, i}
{#if arg !== undefined}
{#if i}
&nbsp;|
{/if}
{/each}
</div>
{:else}
<span class="text">n/a</span>
{/if}
<span class="text" data-private>
{related?.[arg]}
</span>
{/if}
{/each}
</Link.Button>
{:else}
{@const itemsNum = document[column.id]?.length}
<button
class="button is-text"
on:click|preventDefault|stopPropagation={() => {
relationshipData = document[column.id];
showRelationships = true;
selectedRelationship = attr;
}}
disabled={!itemsNum}>
Items <span class="inline-tag">{itemsNum ?? 0}</span>
</button>
<span class="text">n/a</span>
{/if}
</TableCell>
{:else}
{@const formatted = formatColumn(document[column.id])}
<TableCell>
<Tooltip disabled={!formatted.truncated}>
<div
class="u-width-fit-content"
data-private
class:truncated={formatted.whole.length >
formatted.value.length}
class:less-width-truncated={$columns.filter(
(col) => col.show
).length > 1}>
{formatted.value}
</div>
<span>{formatted.whole}</span>
</Tooltip>
</TableCell>
{/if}
{:else}
{@const itemsNum = document[column.id]?.length}
<Button.Button
variant="extra-compact"
disabled={!itemsNum}
badge={itemsNum ?? 0}
on:click={(e) => {
e.stopPropagation();
e.preventDefault();
relationshipData = document[column.id];
showRelationships = true;
selectedRelationship = attr;
}}>
Items
</Button.Button>
{/if}
</Table.Cell>
{:else}
{@const formatted = formatColumn(document[column.id])}
<Table.Cell>
<Tooltip disabled={!formatted.truncated} placement="bottom">
<span>
{formatted.value}
</span>
<span style:white-space="pre-wrap" slot="tooltip">
{formatted.whole}
</span>
</Tooltip>
</Table.Cell>
{/if}
{/each}
<TableCellText>
{toLocaleDateTime(document.$createdAt)}
</TableCellText>
<TableCellText>
{toLocaleDateTime(document.$updatedAt)}
</TableCellText>
</TableRowLink>
{/each}
</TableBody>
</TableScroll>
{/if}
{/each}
<Table.Cell>
{toLocaleDateTime(document.$createdAt)}
</Table.Cell>
<Table.Cell>
{toLocaleDateTime(document.$updatedAt)}
</Table.Cell>
</Table.Link>
{/each}
</Table.Root>
<RelationshipsModal bind:show={showRelationships} {selectedRelationship} data={relationshipData} />
@@ -279,10 +261,10 @@
</div>
<div class="u-flex u-cross-center u-gap-8">
<Button text on:click={() => (selectedDb = [])}>Cancel</Button>
<Button secondary on:click={() => (showDelete = true)}>
<ConsoleButton text on:click={() => (selectedDb = [])}>Cancel</ConsoleButton>
<ConsoleButton secondary on:click={() => (showDelete = true)}>
<p>Delete</p>
</Button>
</ConsoleButton>
</div>
</div>
</FloatingActionBar>
@@ -339,10 +321,11 @@
</div>
<svelte:fragment slot="footer">
<Button text on:click={() => (showDelete = false)} disabled={deleting}>Cancel</Button>
<Button secondary submit disabled={deleting || (relAttributes?.length && !checked)}>
<ConsoleButton text on:click={() => (showDelete = false)} disabled={deleting}
>Cancel</ConsoleButton>
<ConsoleButton secondary submit disabled={deleting || (relAttributes?.length && !checked)}>
Delete
</Button>
</ConsoleButton>
</svelte:fragment>
</Modal>
@@ -13,6 +13,5 @@
<AttributeForm
bind:formValues={$createDocument.document}
attributes={$createDocument.attributes}
bind:customId={$createDocument.id}
gap="24" />
bind:customId={$createDocument.id} />
</WizardStep>
@@ -3,7 +3,7 @@
import { WizardStep } from '$lib/layout';
import { createDocument } from './store';
import { collection } from '../store';
import { Alert } from '$lib/components';
import { Alert } from '@appwrite.io/pink-svelte';
</script>
<WizardStep>
@@ -18,21 +18,17 @@
</a>.
</svelte:fragment>
{#if $collection.documentSecurity}
<div class="common-section">
<Alert type="info">
<svelte:fragment slot="title">Document security is enabled</svelte:fragment>
Users will be able to access this document if they have been granted
<b>either document or collection permissions</b>.
</Alert>
</div>
<div class="common-section">
<Permissions bind:permissions={$createDocument.permissions} />
</div>
<Alert.Inline status="info">
<svelte:fragment slot="title">Document security is enabled</svelte:fragment>
Users will be able to access this document if they have been granted
<b>either document or collection permissions</b>.
</Alert.Inline>
<Permissions bind:permissions={$createDocument.permissions} />
{:else}
<Alert type="info">
<Alert.Inline status="info">
<svelte:fragment slot="title">Document security is disabled</svelte:fragment>
If you want to assign document permissions, navigate to Collection settings and enable document
security. Otherwise, only collection permissions will be used.
</Alert>
</Alert.Inline>
{/if}
</WizardStep>