Skip to content

Commit dca376c

Browse files
committed
Fix: blocked resource info
1 parent 3b77754 commit dca376c

File tree

4 files changed

+117
-64
lines changed

4 files changed

+117
-64
lines changed

src/routes/(console)/project-[region]-[project]/databases/+page.svelte

Lines changed: 57 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import { Icon, Layout } from '@appwrite.io/pink-svelte';
1818
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
1919
import EmptySearch from '$lib/components/emptySearch.svelte';
20+
import ErrorResourceBlocked from '../errorResourceBlocked.svelte';
21+
import ErrorFailedToLoad from '../errorFailedToLoad.svelte';
2022
2123
export let data: PageData;
2224
@@ -46,56 +48,64 @@
4648
]);
4749
</script>
4850

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>
5379
</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} />
6886
{/if}
69-
</Layout.Stack>
70-
</Layout.Stack>
7187

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>
75100
{: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)} />
77107
{/if}
108+
</Container>
78109

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}

src/routes/(console)/project-[region]-[project]/databases/+page.ts

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,35 @@ export const load: PageLoad = async ({ url, route, depends, params, parent }) =>
2121
// already loaded by parent.
2222
const { currentPlan } = await parent();
2323

24-
const { databases, policies, lastBackups } = await fetchDatabasesAndBackups(
25-
limit,
26-
offset,
27-
params,
28-
search,
29-
currentPlan
30-
);
31-
32-
return {
33-
offset,
34-
limit,
35-
view,
36-
search,
37-
policies,
38-
databases,
39-
lastBackups
40-
};
24+
try {
25+
const { databases, policies, lastBackups } = await fetchDatabasesAndBackups(
26+
limit,
27+
offset,
28+
params,
29+
search,
30+
currentPlan
31+
);
32+
return {
33+
offset,
34+
limit,
35+
view,
36+
search,
37+
policies,
38+
databases,
39+
lastBackups
40+
};
41+
42+
} catch (error) {
43+
return {
44+
error: {
45+
type: error.type,
46+
},
47+
offset,
48+
limit,
49+
view,
50+
search,
51+
};
52+
}
4153
};
4254

4355
async function fetchDatabasesAndBackups(
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<script lang="ts">
2+
import { Card } from '$lib/components';
3+
import { Container } from '$lib/layout';
4+
import { Typography } from '@appwrite.io/pink-svelte';
5+
export let resource: string;
6+
</script>
7+
8+
<Container>
9+
<Card>
10+
<Typography.Title size="s">Failed to load {resource}</Typography.Title>
11+
<p class="text-red-500">
12+
An error occurred while trying to load the {resource.toLowerCase()}. Please try again later or contact support if the issue persists.
13+
</p>
14+
</Card>
15+
</Container>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<script lang="ts">
2+
import { Card } from '$lib/components';
3+
import { Container } from '$lib/layout';
4+
import { Typography } from '@appwrite.io/pink-svelte';
5+
export let resource: string;
6+
</script>
7+
8+
<Container>
9+
<Card>
10+
<Typography.Title size="s">Your {resource} is paused</Typography.Title>
11+
<p class="text-red-500">
12+
We've detected unusual activity and temporarily paused your {resource}. If you believe
13+
this is a mistake or need urgent access, please contact [email protected].
14+
</p>
15+
</Card>
16+
</Container>

0 commit comments

Comments
 (0)