|
14 | 14 | import Table from './table.svelte'; |
15 | 15 | import { registerCommands } from '$lib/commandCenter'; |
16 | 16 | import { canWriteDatabases } from '$lib/stores/roles'; |
17 | | - import { Icon } from '@appwrite.io/pink-svelte'; |
| 17 | + import { Icon, Tooltip } 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 { isServiceLimited } from '$lib/stores/billing'; |
| 21 | + import { organization } from '$lib/stores/organization'; |
20 | 22 |
|
21 | 23 | export let data: PageData; |
22 | 24 |
|
|
30 | 32 | ); |
31 | 33 | } |
32 | 34 |
|
| 35 | + $: isLimited = isServiceLimited('databases', $organization?.billingPlan, data.databases.total); |
| 36 | +
|
33 | 37 | $: $registerCommands([ |
34 | 38 | { |
35 | 39 | label: 'Create database', |
36 | 40 | callback: () => { |
37 | 41 | showCreate = true; |
38 | 42 | }, |
39 | 43 | keys: ['c'], |
40 | | - disabled: showCreate || !$canWriteDatabases, |
| 44 | + disabled: showCreate || !$canWriteDatabases || isLimited, |
41 | 45 | icon: IconPlus, |
42 | 46 | group: 'databases', |
43 | 47 | rank: 10 |
|
52 | 56 | bind:view={data.view} |
53 | 57 | searchPlaceholder="Search by name or ID"> |
54 | 58 | {#if $canWriteDatabases} |
55 | | - <Button event="create_database" on:click={() => (showCreate = true)}> |
56 | | - <Icon icon={IconPlus} slot="start" size="s" /> |
57 | | - Create database |
58 | | - </Button> |
| 59 | + <Tooltip disabled={!isLimited}> |
| 60 | + <div> |
| 61 | + <Button |
| 62 | + disabled={isLimited} |
| 63 | + event="create_database" |
| 64 | + on:click={() => (showCreate = true)}> |
| 65 | + <Icon icon={IconPlus} slot="start" size="s" /> |
| 66 | + Create database |
| 67 | + </Button> |
| 68 | + </div> |
| 69 | + <svelte:fragment slot="tooltip"> |
| 70 | + You have reached the maximum number of databases for your plan. |
| 71 | + </svelte:fragment> |
| 72 | + </Tooltip> |
59 | 73 | {/if} |
60 | 74 | </ResponsiveContainerHeader> |
61 | 75 |
|
|
0 commit comments