|
1 | | -<script lang="ts" context="module"> |
| 1 | +<script lang="ts" module> |
2 | 2 | export let showCreateBucket = writable(false); |
3 | 3 | </script> |
4 | 4 |
|
|
7 | 7 | import { Empty, PaginationWithLimit } from '$lib/components'; |
8 | 8 | import Create from './create.svelte'; |
9 | 9 | import { Container, ResponsiveContainerHeader } from '$lib/layout'; |
10 | | - import { base } from '$app/paths'; |
11 | 10 | import { page } from '$app/state'; |
12 | 11 | import type { Models } from '@appwrite.io/console'; |
13 | 12 | import { writable } from 'svelte/store'; |
14 | 13 | import { canWriteBuckets } from '$lib/stores/roles'; |
15 | | - import { Icon } from '@appwrite.io/pink-svelte'; |
| 14 | + import { Icon, Tooltip } from '@appwrite.io/pink-svelte'; |
16 | 15 | import { Button } from '$lib/elements/forms'; |
17 | 16 | import { columns } from './store'; |
18 | 17 | import Grid from './grid.svelte'; |
19 | 18 | import Table from './table.svelte'; |
20 | 19 | import { IconPlus } from '@appwrite.io/pink-icons-svelte'; |
| 20 | + import { resolveRoute } from '$lib/stores/navigation'; |
| 21 | + import { isServiceLimited } from '$lib/stores/billing'; |
| 22 | + import type { PageProps } from './$types'; |
| 23 | + import { organization } from '$lib/stores/organization'; |
21 | 24 |
|
22 | | - export let data; |
23 | | -
|
24 | | - const project = page.params.project; |
| 25 | + let { data }: PageProps = $props(); |
25 | 26 |
|
26 | 27 | async function bucketCreated(event: CustomEvent<Models.Bucket>) { |
27 | 28 | showCreateBucket.set(false); |
28 | 29 | await goto( |
29 | | - `${base}/project-${page.params.region}-${project}/storage/bucket-${event.detail.$id}` |
| 30 | + resolveRoute('/(console)/project-[region]-[project]/storage/bucket-[bucket]', { |
| 31 | + ...page.params, |
| 32 | + bucket: event.detail.$id |
| 33 | + }) |
30 | 34 | ); |
31 | 35 | } |
| 36 | +
|
| 37 | + const isLimited = $derived(isServiceLimited('buckets', $organization, data.buckets.total)); |
32 | 38 | </script> |
33 | 39 |
|
34 | 40 | <Container> |
|
38 | 44 | bind:view={data.view} |
39 | 45 | searchPlaceholder="Search by name or ID"> |
40 | 46 | {#if $canWriteBuckets} |
41 | | - <Button on:click={() => ($showCreateBucket = true)} event="create_bucket" size="s"> |
42 | | - <Icon icon={IconPlus} slot="start" size="s" /> |
43 | | - Create bucket |
44 | | - </Button> |
| 47 | + <Tooltip disabled={!isLimited} maxWidth="200px"> |
| 48 | + <div> |
| 49 | + <Button |
| 50 | + size="s" |
| 51 | + event="create_bucket" |
| 52 | + disabled={isLimited} |
| 53 | + on:click={() => ($showCreateBucket = true)}> |
| 54 | + <Icon icon={IconPlus} slot="start" size="s" /> |
| 55 | + Create bucket |
| 56 | + </Button> |
| 57 | + </div> |
| 58 | + <svelte:fragment slot="tooltip"> |
| 59 | + You have reached the maximum number of buckets for your plan. |
| 60 | + </svelte:fragment> |
| 61 | + </Tooltip> |
45 | 62 | {/if} |
46 | 63 | </ResponsiveContainerHeader> |
47 | 64 |
|
|
0 commit comments