mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
update: scopes.
This commit is contained in:
@@ -19,14 +19,15 @@ export const canWritePlatforms = derived(scopes, ($scopes) => $scopes.includes('
|
||||
export const canWriteTargets = derived(scopes, ($scopes) => $scopes.includes('targets.write'));
|
||||
export const canWriteUsers = derived(scopes, ($scopes) => $scopes.includes('users.write'));
|
||||
export const canWriteTeams = derived(scopes, ($scopes) => $scopes.includes('teams.write'));
|
||||
export const canWriteCollections = derived(scopes, ($scopes) =>
|
||||
$scopes.includes('collections.write')
|
||||
);
|
||||
export const canWriteTables = derived(scopes, ($scopes) => {
|
||||
return $scopes.includes('collections.write') || $scopes.includes('tables.write');
|
||||
});
|
||||
export const canWriteSites = derived(scopes, ($scopes) => $scopes.includes('sites.write'));
|
||||
export const canWriteDomains = derived(scopes, ($scopes) => $scopes.includes('domains.write')); //TODO: check if correct
|
||||
|
||||
// TODO: @itznotabug - add new scopes as well, don't replace completely!
|
||||
export const canWriteDocuments = derived(scopes, ($scopes) => $scopes.includes('documents.write'));
|
||||
export const canWriteRows = derived(scopes, ($scopes) => {
|
||||
return $scopes.includes('documents.write') || $scopes.includes('rows.write');
|
||||
});
|
||||
export const canWriteExecutions = derived(scopes, ($scopes) =>
|
||||
$scopes.includes('executions.write')
|
||||
);
|
||||
|
||||
@@ -7,6 +7,7 @@ import type { PageLoad } from './$types';
|
||||
export const load: PageLoad = async ({ url, params, route, depends }) => {
|
||||
depends(Dependencies.ORGANIZATION);
|
||||
depends(Dependencies.MEMBERS);
|
||||
|
||||
const page = getPage(url);
|
||||
const search = getSearch(url);
|
||||
const limit = getLimit(url, route, PAGE_LIMIT);
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@
|
||||
import CreateTable from './createTable.svelte';
|
||||
import { showCreate } from './store';
|
||||
import { TablesPanel } from '$lib/commandCenter/panels';
|
||||
import { canWriteCollections, canWriteDatabases } from '$lib/stores/roles';
|
||||
import { canWriteTables, canWriteDatabases } from '$lib/stores/roles';
|
||||
import { showCreateBackup, showCreatePolicy } from './backups/store';
|
||||
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
|
||||
import { currentPlan } from '$lib/stores/organization';
|
||||
@@ -43,7 +43,7 @@
|
||||
}
|
||||
},
|
||||
keys: page.url.pathname.endsWith(databaseId) ? ['c'] : ['c', 'c'],
|
||||
disabled: page.url.pathname.includes('table-') || !$canWriteCollections,
|
||||
disabled: page.url.pathname.includes('table-') || !$canWriteTables,
|
||||
group: 'databases',
|
||||
icon: IconPlus
|
||||
},
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@
|
||||
import Table from './table.svelte';
|
||||
import Grid from './grid.svelte';
|
||||
import type { PageData } from './$types';
|
||||
import { canWriteCollections } from '$lib/stores/roles';
|
||||
import { canWriteTables } from '$lib/stores/roles';
|
||||
import { Icon } from '@appwrite.io/pink-svelte';
|
||||
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
columns={tableViewColumns}
|
||||
hasSearch
|
||||
searchPlaceholder="Search by name or ID">
|
||||
{#if $canWriteCollections}
|
||||
{#if $canWriteTables}
|
||||
<Button on:click={() => ($showCreate = true)} event="create_table">
|
||||
<Icon icon={IconPlus} slot="start" size="s" />
|
||||
Create table
|
||||
@@ -42,7 +42,7 @@
|
||||
{:else}
|
||||
<Empty
|
||||
single
|
||||
allowCreate={$canWriteCollections}
|
||||
allowCreate={$canWriteTables}
|
||||
href="https://appwrite.io/docs/products/databases/tables"
|
||||
target="table"
|
||||
on:click={() => ($showCreate = true)} />
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/state';
|
||||
import { CardContainer, GridItem1, Id } from '$lib/components';
|
||||
import { canWriteCollections } from '$lib/stores/roles';
|
||||
import { canWriteTables } from '$lib/stores/roles';
|
||||
import type { PageData } from './$types';
|
||||
import { Badge } from '@appwrite.io/pink-svelte';
|
||||
export let data: PageData;
|
||||
@@ -12,7 +12,7 @@
|
||||
</script>
|
||||
|
||||
<CardContainer
|
||||
disableEmpty={!$canWriteCollections}
|
||||
disableEmpty={!$canWriteTables}
|
||||
total={data.tables.total}
|
||||
on:click={() => (showCreate = true)}
|
||||
event="table">
|
||||
|
||||
+7
-7
@@ -31,7 +31,7 @@
|
||||
import { page } from '$app/state';
|
||||
import CreateIndex from './indexes/createIndex.svelte';
|
||||
import { base } from '$app/paths';
|
||||
import { canWriteCollections } from '$lib/stores/roles';
|
||||
import { canWriteTables } from '$lib/stores/roles';
|
||||
import { IconEye, IconLockClosed, IconPlus, IconPuzzle } from '@appwrite.io/pink-icons-svelte';
|
||||
|
||||
onMount(() => {
|
||||
@@ -68,7 +68,7 @@
|
||||
},
|
||||
icon: IconPlus,
|
||||
group: 'columns',
|
||||
disabled: !$canWriteCollections
|
||||
disabled: !$canWriteTables
|
||||
},
|
||||
{
|
||||
label: 'Go to rows',
|
||||
@@ -133,7 +133,7 @@
|
||||
`${base}/project-${page.params.region}-${page.params.project}/databases/database-${$database?.$id}/table-${$table?.$id}/settings`
|
||||
);
|
||||
},
|
||||
disabled: page.url.pathname.endsWith('settings') || !$canWriteCollections,
|
||||
disabled: page.url.pathname.endsWith('settings') || !$canWriteTables,
|
||||
group: 'tables'
|
||||
},
|
||||
{
|
||||
@@ -147,7 +147,7 @@
|
||||
disabled:
|
||||
page.url.pathname.endsWith('display-name') ||
|
||||
page.url.pathname.endsWith('settings') ||
|
||||
!$canWriteCollections,
|
||||
!$canWriteTables,
|
||||
icon: IconEye
|
||||
},
|
||||
{
|
||||
@@ -161,7 +161,7 @@
|
||||
disabled:
|
||||
page.url.pathname.endsWith('permissions') ||
|
||||
page.url.pathname.endsWith('settings') ||
|
||||
!$canWriteCollections,
|
||||
!$canWriteTables,
|
||||
icon: IconPuzzle
|
||||
},
|
||||
{
|
||||
@@ -175,7 +175,7 @@
|
||||
disabled:
|
||||
page.url.pathname.endsWith('row-security') ||
|
||||
page.url.pathname.endsWith('settings') ||
|
||||
!$canWriteCollections,
|
||||
!$canWriteTables,
|
||||
icon: IconLockClosed
|
||||
},
|
||||
{
|
||||
@@ -186,7 +186,7 @@
|
||||
},
|
||||
icon: IconPlus,
|
||||
group: 'indexes',
|
||||
disabled: !$canWriteCollections
|
||||
disabled: !$canWriteTables
|
||||
}
|
||||
]);
|
||||
|
||||
|
||||
+4
-4
@@ -6,7 +6,7 @@
|
||||
import type { Column, ColumnType } from '$lib/helpers/types';
|
||||
import { Container } from '$lib/layout';
|
||||
import { preferences } from '$lib/stores/preferences';
|
||||
import { canWriteCollections, canWriteDocuments } from '$lib/stores/roles';
|
||||
import { canWriteTables, canWriteRows } from '$lib/stores/roles';
|
||||
import { Card, Icon, Layout, Empty as PinkEmpty } from '@appwrite.io/pink-svelte';
|
||||
import type { PageData } from './$types';
|
||||
import CreateColumnDropdown from './columns/createColumnDropdown.svelte';
|
||||
@@ -164,7 +164,7 @@
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<Empty
|
||||
allowCreate={$canWriteDocuments}
|
||||
allowCreate={$canWriteRows}
|
||||
single
|
||||
href="https://appwrite.io/docs/products/databases/rows"
|
||||
target="row">
|
||||
@@ -179,7 +179,7 @@
|
||||
<Button
|
||||
href={`${base}/project-${page.params.region}-${page.params.project}/databases/database-${page.params.database}/table-${page.params.table}/create`}
|
||||
secondary
|
||||
disabled={!$canWriteDocuments}
|
||||
disabled={!$canWriteRows}
|
||||
size="s">
|
||||
Create row
|
||||
</Button>
|
||||
@@ -198,7 +198,7 @@
|
||||
text
|
||||
event="empty_documentation"
|
||||
size="s">Documentation</Button>
|
||||
{#if $canWriteCollections}
|
||||
{#if $canWriteTables}
|
||||
<CreateColumnDropdown
|
||||
bind:selectedOption={selectedColumn}
|
||||
bind:showCreate={showCreateColumn}
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@
|
||||
import { Empty } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Container } from '$lib/layout';
|
||||
import { canWriteCollections } from '$lib/stores/roles';
|
||||
import { canWriteTables } from '$lib/stores/roles';
|
||||
import {
|
||||
ActionMenu,
|
||||
Badge,
|
||||
@@ -77,7 +77,7 @@
|
||||
<Container>
|
||||
<Layout.Stack direction="row" justifyContent="space-between">
|
||||
<Typography.Title>Columns</Typography.Title>
|
||||
{#if $canWriteCollections}
|
||||
{#if $canWriteTables}
|
||||
<CreateColumnDropdown bind:selectedOption bind:showCreate />
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
@@ -236,7 +236,7 @@
|
||||
text
|
||||
event="empty_documentation"
|
||||
ariaLabel={'create column'}>Documentation</Button>
|
||||
{#if $canWriteCollections}
|
||||
{#if $canWriteTables}
|
||||
<CreateColumnDropdown bind:selectedOption bind:showCreate let:toggle>
|
||||
<Button secondary event="create_column" on:click={toggle}>
|
||||
Create column
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
import { Id, Tab, Tabs } from '$lib/components';
|
||||
import { isTabSelected } from '$lib/helpers/load';
|
||||
import { Cover, CoverTitle } from '$lib/layout';
|
||||
import { canWriteCollections } from '$lib/stores/roles';
|
||||
import { canWriteTables } from '$lib/stores/roles';
|
||||
import { table } from './store';
|
||||
import { isTabletViewport } from '$lib/stores/viewport';
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
href: `${path}/settings`,
|
||||
title: 'Settings',
|
||||
event: 'settings',
|
||||
disabled: !$canWriteCollections
|
||||
disabled: !$canWriteTables
|
||||
}
|
||||
].filter((tab) => !tab.disabled)
|
||||
);
|
||||
|
||||
+4
-4
@@ -11,7 +11,7 @@
|
||||
import CreateColumnDropdown from '../columns/createColumnDropdown.svelte';
|
||||
import type { Option } from '../columns/store';
|
||||
import FailedModal from '../failedModal.svelte';
|
||||
import { canWriteCollections } from '$lib/stores/roles';
|
||||
import { canWriteTables } from '$lib/stores/roles';
|
||||
import {
|
||||
ActionMenu,
|
||||
Badge,
|
||||
@@ -59,7 +59,7 @@
|
||||
<Container>
|
||||
<Layout.Stack direction="row" justifyContent="space-between">
|
||||
<Typography.Title>Indexes</Typography.Title>
|
||||
{#if $canWriteCollections}
|
||||
{#if $canWriteTables}
|
||||
<Button
|
||||
event="create_index"
|
||||
disabled={!$table?.columns?.length}
|
||||
@@ -150,7 +150,7 @@
|
||||
</Table.Root>
|
||||
{:else}
|
||||
<Empty
|
||||
allowCreate={$canWriteCollections}
|
||||
allowCreate={$canWriteTables}
|
||||
single
|
||||
href="https://appwrite.io/docs/products/databases/tables#indexes"
|
||||
target="index"
|
||||
@@ -165,7 +165,7 @@
|
||||
text
|
||||
event="empty_documentation"
|
||||
ariaLabel="create index">Documentation</Button>
|
||||
{#if $canWriteCollections}
|
||||
{#if $canWriteTables}
|
||||
<CreateColumnDropdown
|
||||
bind:selectedOption={selectedColumn}
|
||||
bind:showCreate={showCreateColumn}
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { canWriteCollections } from '$lib/stores/roles';
|
||||
import { canWriteTables } from '$lib/stores/roles';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Badge, FloatingActionBar, Table, Typography } from '@appwrite.io/pink-svelte';
|
||||
import type { PageData } from './$types';
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
<Table.Root
|
||||
columns={$tableViewColumns}
|
||||
allowSelection={$canWriteCollections}
|
||||
allowSelection={$canWriteTables}
|
||||
bind:selectedRows={selectedTables}
|
||||
let:root>
|
||||
<svelte:fragment slot="header" let:root>
|
||||
|
||||
Reference in New Issue
Block a user