|
17 | 17 | import { Icon, Layout } from '@appwrite.io/pink-svelte';
|
18 | 18 | import { IconPlus } from '@appwrite.io/pink-icons-svelte';
|
19 | 19 | import EmptySearch from '$lib/components/emptySearch.svelte';
|
| 20 | + import ErrorResourceBlocked from '../errorResourceBlocked.svelte'; |
| 21 | + import ErrorFailedToLoad from '../errorFailedToLoad.svelte'; |
20 | 22 |
|
21 | 23 | export let data: PageData;
|
22 | 24 |
|
|
46 | 48 | ]);
|
47 | 49 | </script>
|
48 | 50 |
|
49 |
| -<Container> |
50 |
| - <Layout.Stack direction="row" justifyContent="space-between"> |
51 |
| - <Layout.Stack direction="row" alignItems="center"> |
52 |
| - <SearchQuery placeholder="Search by name or ID" /> |
| 51 | +{#if data.error} |
| 52 | + {#if data.error.type === 'general_resource_blocked'} |
| 53 | + <ErrorResourceBlocked resource="Databases" /> |
| 54 | + {:else} |
| 55 | + <ErrorFailedToLoad resource="Databases" /> |
| 56 | + {/if} |
| 57 | +{:else} |
| 58 | + <Container> |
| 59 | + <Layout.Stack direction="row" justifyContent="space-between"> |
| 60 | + <Layout.Stack direction="row" alignItems="center"> |
| 61 | + <SearchQuery placeholder="Search by name or ID" /> |
| 62 | + </Layout.Stack> |
| 63 | + <Layout.Stack direction="row" alignItems="center" justifyContent="flex-end"> |
| 64 | + <ViewSelector |
| 65 | + {columns} |
| 66 | + view={data.view} |
| 67 | + hideColumns={!data.databases.total} |
| 68 | + hideView={!data.databases.total} /> |
| 69 | + {#if $canWriteDatabases} |
| 70 | + <Button |
| 71 | + on:click={() => (showCreate = true)} |
| 72 | + event="create_database" |
| 73 | + disabled={isCreationDisabled}> |
| 74 | + <Icon icon={IconPlus} slot="start" size="s" /> |
| 75 | + Create database |
| 76 | + </Button> |
| 77 | + {/if} |
| 78 | + </Layout.Stack> |
53 | 79 | </Layout.Stack>
|
54 |
| - <Layout.Stack direction="row" alignItems="center" justifyContent="flex-end"> |
55 |
| - <ViewSelector |
56 |
| - {columns} |
57 |
| - view={data.view} |
58 |
| - hideColumns={!data.databases.total} |
59 |
| - hideView={!data.databases.total} /> |
60 |
| - {#if $canWriteDatabases} |
61 |
| - <Button |
62 |
| - on:click={() => (showCreate = true)} |
63 |
| - event="create_database" |
64 |
| - disabled={isCreationDisabled}> |
65 |
| - <Icon icon={IconPlus} slot="start" size="s" /> |
66 |
| - Create database |
67 |
| - </Button> |
| 80 | + |
| 81 | + {#if data.databases.total} |
| 82 | + {#if data.view === 'grid'} |
| 83 | + <Grid {data} bind:showCreate /> |
| 84 | + {:else} |
| 85 | + <Table {data} /> |
68 | 86 | {/if}
|
69 |
| - </Layout.Stack> |
70 |
| - </Layout.Stack> |
71 | 87 |
|
72 |
| - {#if data.databases.total} |
73 |
| - {#if data.view === 'grid'} |
74 |
| - <Grid {data} bind:showCreate /> |
| 88 | + <PaginationWithLimit |
| 89 | + name="Databases" |
| 90 | + limit={data.limit} |
| 91 | + offset={data.offset} |
| 92 | + total={data.databases.total} /> |
| 93 | + {:else if data.search} |
| 94 | + <EmptySearch target="databases" hidePagination> |
| 95 | + <Button |
| 96 | + href={`${base}/project-${page.params.region}-${page.params.project}/databases`} |
| 97 | + size="s" |
| 98 | + secondary>Clear Search</Button> |
| 99 | + </EmptySearch> |
75 | 100 | {:else}
|
76 |
| - <Table {data} /> |
| 101 | + <Empty |
| 102 | + single |
| 103 | + href="https://appwrite.io/docs/products/databases/databases" |
| 104 | + target="database" |
| 105 | + allowCreate={$canWriteDatabases} |
| 106 | + on:click={() => (showCreate = true)} /> |
77 | 107 | {/if}
|
| 108 | + </Container> |
78 | 109 |
|
79 |
| - <PaginationWithLimit |
80 |
| - name="Databases" |
81 |
| - limit={data.limit} |
82 |
| - offset={data.offset} |
83 |
| - total={data.databases.total} /> |
84 |
| - {:else if data.search} |
85 |
| - <EmptySearch target="databases" hidePagination> |
86 |
| - <Button |
87 |
| - href={`${base}/project-${page.params.region}-${page.params.project}/databases`} |
88 |
| - size="s" |
89 |
| - secondary>Clear Search</Button> |
90 |
| - </EmptySearch> |
91 |
| - {:else} |
92 |
| - <Empty |
93 |
| - single |
94 |
| - href="https://appwrite.io/docs/products/databases/databases" |
95 |
| - target="database" |
96 |
| - allowCreate={$canWriteDatabases} |
97 |
| - on:click={() => (showCreate = true)} /> |
98 |
| - {/if} |
99 |
| -</Container> |
100 |
| - |
101 |
| -<Create bind:showCreate on:created={handleCreate} /> |
| 110 | + <Create bind:showCreate on:created={handleCreate} /> |
| 111 | +{/if} |
0 commit comments