|
6 | 6 | import Container from '$lib/layout/container.svelte'; |
7 | 7 | import type { Models } from '@appwrite.io/console'; |
8 | 8 | import { IconPlus } from '@appwrite.io/pink-icons-svelte'; |
9 | | - import { Card, Empty, Icon, Layout } from '@appwrite.io/pink-svelte'; |
| 9 | + import { Card, Empty, Icon, Layout, Tooltip } from '@appwrite.io/pink-svelte'; |
10 | 10 | import DeleteDomainModal from './deleteDomainModal.svelte'; |
11 | 11 | import RetryDomainModal from './retryDomainModal.svelte'; |
12 | 12 | import SearchQuery from '$lib/components/searchQuery.svelte'; |
13 | 13 | import { app } from '$lib/stores/app'; |
14 | 14 | import { Click, trackEvent } from '$lib/actions/analytics'; |
| 15 | + import { |
| 16 | + BODY_TOOLTIP_MAX_WIDTH, |
| 17 | + BODY_TOOLTIP_WRAPPER_STYLE_PRELINE |
| 18 | + } from '$lib/helpers/tooltipContent'; |
| 19 | + import { isServiceLimited } from '$lib/stores/billing'; |
| 20 | + import { organization } from '$lib/stores/organization'; |
15 | 21 | import Table from './table.svelte'; |
16 | 22 |
|
17 | 23 | let { data } = $props(); |
18 | 24 |
|
| 25 | + const isDomainLimitReached = $derived( |
| 26 | + isServiceLimited('domains', $organization, data.proxyRules.total) |
| 27 | + ); |
| 28 | +
|
19 | 29 | let showDelete = $state(false); |
20 | 30 | let showRetry = $state(false); |
21 | 31 | let selectedProxyRule: Models.ProxyRule = null; |
|
24 | 34 | <Container> |
25 | 35 | <Layout.Stack direction="row" justifyContent="space-between"> |
26 | 36 | <SearchQuery placeholder="Search domain" /> |
27 | | - <Button |
28 | | - href={`${base}/project-${page.params.region}-${page.params.project}/functions/function-${page.params.function}/domains/add-domain`} |
29 | | - on:click={() => { |
30 | | - trackEvent(Click.DomainCreateClick, { |
31 | | - source: 'functions_domain_overview' |
32 | | - }); |
33 | | - }}> |
34 | | - <Icon icon={IconPlus} size="s" /> |
35 | | - Add domain |
36 | | - </Button> |
| 37 | + <Tooltip disabled={!isDomainLimitReached} maxWidth={BODY_TOOLTIP_MAX_WIDTH}> |
| 38 | + <div> |
| 39 | + <Button |
| 40 | + disabled={isDomainLimitReached} |
| 41 | + href={isDomainLimitReached |
| 42 | + ? undefined |
| 43 | + : `${base}/project-${page.params.region}-${page.params.project}/functions/function-${page.params.function}/domains/add-domain`} |
| 44 | + on:click={() => { |
| 45 | + trackEvent(Click.DomainCreateClick, { |
| 46 | + source: 'functions_domain_overview' |
| 47 | + }); |
| 48 | + }}> |
| 49 | + <Icon icon={IconPlus} size="s" /> |
| 50 | + Add domain |
| 51 | + </Button> |
| 52 | + </div> |
| 53 | + <svelte:fragment slot="tooltip"> |
| 54 | + <div style={BODY_TOOLTIP_WRAPPER_STYLE_PRELINE}> |
| 55 | + You have reached the maximum number of custom domains for your plan. |
| 56 | + </div> |
| 57 | + </svelte:fragment> |
| 58 | + </Tooltip> |
37 | 59 | </Layout.Stack> |
38 | 60 | {#if data.proxyRules.total} |
39 | 61 | <Table proxyRules={data.proxyRules} organizationDomains={data.organizationDomains} /> |
|
70 | 92 | size="s" |
71 | 93 | ariaLabel="add domain">Documentation</Button> |
72 | 94 |
|
73 | | - <Button |
74 | | - secondary |
75 | | - href={`${base}/project-${page.params.region}-${page.params.project}/functions/function-${page.params.function}/domains/add-domain`} |
76 | | - size="s"> |
77 | | - Add domain |
78 | | - </Button> |
| 95 | + <Tooltip disabled={!isDomainLimitReached} maxWidth={BODY_TOOLTIP_MAX_WIDTH}> |
| 96 | + <div> |
| 97 | + <Button |
| 98 | + secondary |
| 99 | + disabled={isDomainLimitReached} |
| 100 | + href={isDomainLimitReached |
| 101 | + ? undefined |
| 102 | + : `${base}/project-${page.params.region}-${page.params.project}/functions/function-${page.params.function}/domains/add-domain`} |
| 103 | + size="s"> |
| 104 | + Add domain |
| 105 | + </Button> |
| 106 | + </div> |
| 107 | + <svelte:fragment slot="tooltip"> |
| 108 | + <div style={BODY_TOOLTIP_WRAPPER_STYLE_PRELINE}> |
| 109 | + You have reached the maximum number of custom domains for your plan. |
| 110 | + </div> |
| 111 | + </svelte:fragment> |
| 112 | + </Tooltip> |
79 | 113 | </svelte:fragment> |
80 | 114 | </Empty> |
81 | 115 | </Card.Base> |
|
0 commit comments