|
9 | 9 | Alert |
10 | 10 | } from '@appwrite.io/pink-svelte'; |
11 | 11 | import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store'; |
| 12 | + import { getSubdomain } from '$lib/helpers/tlds'; |
| 13 | + import { isCloud } from '$lib/system'; |
12 | 14 |
|
13 | | - export let domain: string; |
14 | | - export let verified = undefined; |
15 | | - export let variant: 'cname' | 'a' | 'aaaa'; |
16 | | - export let service: 'sites' | 'general' = 'general'; |
| 15 | + let { |
| 16 | + domain, |
| 17 | + verified = undefined, |
| 18 | + variant, |
| 19 | + service = 'general', |
| 20 | + ruleStatus = undefined, |
| 21 | + onNavigateToNameservers = () => {}, |
| 22 | + onNavigateToA = () => {}, |
| 23 | + onNavigateToAAAA = () => {} |
| 24 | + }: { |
| 25 | + domain: string; |
| 26 | + verified?: boolean; |
| 27 | + variant: 'cname' | 'a' | 'aaaa'; |
| 28 | + service?: 'sites' | 'functions' | 'general'; |
| 29 | + ruleStatus?: 'created' | 'verifying' | 'unverified' | 'verified'; |
| 30 | + onNavigateToNameservers?: () => void; |
| 31 | + onNavigateToA?: () => void; |
| 32 | + onNavigateToAAAA?: () => void; |
| 33 | + } = $props(); |
17 | 34 |
|
18 | | - let subdomain = domain?.split('.')?.slice(0, -2)?.join('.'); |
| 35 | + const subdomain = $derived(getSubdomain(domain)); |
| 36 | + const caaText = $derived( |
| 37 | + $regionalConsoleVariables._APP_DOMAIN_TARGET_CAA?.includes(' ') |
| 38 | + ? $regionalConsoleVariables._APP_DOMAIN_TARGET_CAA |
| 39 | + : `0 issue "${$regionalConsoleVariables._APP_DOMAIN_TARGET_CAA}"` |
| 40 | + ); |
| 41 | + const aTabVisible = $derived( |
| 42 | + !isCloud && |
| 43 | + Boolean($regionalConsoleVariables._APP_DOMAIN_TARGET_A) && |
| 44 | + $regionalConsoleVariables._APP_DOMAIN_TARGET_A !== '127.0.0.1' |
| 45 | + ); |
| 46 | + const aaaaTabVisible = $derived( |
| 47 | + !isCloud && |
| 48 | + Boolean($regionalConsoleVariables._APP_DOMAIN_TARGET_AAAA) && |
| 49 | + $regionalConsoleVariables._APP_DOMAIN_TARGET_AAAA !== '::1' |
| 50 | + ); |
19 | 51 |
|
20 | 52 | function setTarget() { |
21 | 53 | switch (variant) { |
22 | 54 | case 'cname': |
23 | | - return service === 'general' |
24 | | - ? $regionalConsoleVariables._APP_DOMAIN_TARGET_CNAME |
25 | | - : $regionalConsoleVariables._APP_DOMAIN_SITES; |
| 55 | + if (service === 'sites') { |
| 56 | + return $regionalConsoleVariables._APP_DOMAIN_SITES; |
| 57 | + } else if (service === 'functions') { |
| 58 | + return $regionalConsoleVariables._APP_DOMAIN_FUNCTIONS; |
| 59 | + } else { |
| 60 | + return $regionalConsoleVariables._APP_DOMAIN_TARGET_CNAME; |
| 61 | + } |
26 | 62 | case 'a': |
27 | 63 | return $regionalConsoleVariables._APP_DOMAIN_TARGET_A; |
28 | 64 | case 'aaaa': |
|
37 | 73 | <Typography.Text variant="l-500" color="--fgcolor-neutral-primary"> |
38 | 74 | {domain} |
39 | 75 | </Typography.Text> |
40 | | - {#if verified === true} |
41 | | - <Badge variant="secondary" type="success" size="xs" content="Verified" /> |
42 | | - {:else if verified === false} |
43 | | - <Badge variant="secondary" type="warning" size="xs" content="Verification failed" /> |
| 76 | + {#if verified !== undefined} |
| 77 | + {#if ruleStatus === 'created'} |
| 78 | + <Badge |
| 79 | + variant="secondary" |
| 80 | + type="error" |
| 81 | + size="xs" |
| 82 | + content="Verification failed" /> |
| 83 | + {:else if ruleStatus === 'verifying'} |
| 84 | + <Badge variant="secondary" size="xs" content="Generating certificate" /> |
| 85 | + {:else if ruleStatus === 'unverified'} |
| 86 | + <Badge |
| 87 | + variant="secondary" |
| 88 | + type="error" |
| 89 | + size="xs" |
| 90 | + content="Certificate generation failed" /> |
| 91 | + {:else if verified === true} |
| 92 | + <Badge variant="secondary" type="success" size="xs" content="Verified" /> |
| 93 | + {/if} |
44 | 94 | {/if} |
45 | 95 | </Layout.Stack> |
46 | 96 | <Typography.Text variant="m-400"> |
47 | | - Add the following record on your DNS provider. Note that DNS changes may take time to |
48 | | - propagate fully. |
| 97 | + Add the following {$regionalConsoleVariables._APP_DOMAIN_TARGET_CAA |
| 98 | + ? 'records' |
| 99 | + : 'record'} on your DNS provider. Note that DNS changes may take up to 48 hours to propagate |
| 100 | + fully. |
49 | 101 | </Typography.Text> |
50 | 102 | </Layout.Stack> |
51 | 103 |
|
52 | | - <Table.Root columns={3} let:root> |
| 104 | + <Table.Root |
| 105 | + columns={[ |
| 106 | + { id: 'type', width: { min: 150 } }, |
| 107 | + { id: 'name', width: { min: 80 } }, |
| 108 | + { id: 'value', width: { min: 100 } } |
| 109 | + ]} |
| 110 | + let:root> |
53 | 111 | <svelte:fragment slot="header" let:root> |
54 | | - <Table.Header.Cell {root}>Type</Table.Header.Cell> |
55 | | - <Table.Header.Cell {root}>Name</Table.Header.Cell> |
56 | | - <Table.Header.Cell {root}>Value</Table.Header.Cell> |
| 112 | + <Table.Header.Cell column="type" {root}>Type</Table.Header.Cell> |
| 113 | + <Table.Header.Cell column="name" {root}>Name</Table.Header.Cell> |
| 114 | + <Table.Header.Cell column="value" {root}>Value</Table.Header.Cell> |
57 | 115 | </svelte:fragment> |
58 | 116 | <Table.Row.Base {root}> |
59 | | - <Table.Cell {root}>{variant.toUpperCase()}</Table.Cell> |
60 | | - <Table.Cell {root}>{subdomain || '@'}</Table.Cell> |
61 | | - <Table.Cell {root}> |
| 117 | + <Table.Cell column="type" {root}>{variant.toUpperCase()}</Table.Cell> |
| 118 | + <Table.Cell column="name" {root}>{subdomain || '@'}</Table.Cell> |
| 119 | + <Table.Cell column="value" {root}> |
62 | 120 | <InteractiveText variant="copy" isVisible text={setTarget()} /> |
63 | 121 | </Table.Cell> |
64 | 122 | </Table.Row.Base> |
| 123 | + {#if $regionalConsoleVariables._APP_DOMAIN_TARGET_CAA} |
| 124 | + <Table.Row.Base {root}> |
| 125 | + <Table.Cell column="type" {root}> |
| 126 | + <Layout.Stack gap="s" direction="row" alignItems="center"> |
| 127 | + <span>CAA</span> |
| 128 | + <Badge variant="secondary" size="xs" content="Recommended" /> |
| 129 | + </Layout.Stack> |
| 130 | + </Table.Cell> |
| 131 | + <Table.Cell column="name" {root}>@</Table.Cell> |
| 132 | + <Table.Cell column="value" {root}> |
| 133 | + <InteractiveText variant="copy" isVisible text={caaText} /> |
| 134 | + </Table.Cell> |
| 135 | + </Table.Row.Base> |
| 136 | + {/if} |
65 | 137 | </Table.Root> |
66 | 138 | <Layout.Stack gap="s" direction="row" alignItems="center"> |
67 | | - {#if variant === 'cname'} |
68 | | - <Alert.Inline> |
69 | | - If your domain uses CAA records, ensure certainly.com is authorized — otherwise, SSL |
70 | | - setup may fail. A list of all domain providers and their DNS setting is available <Link |
71 | | - variant="muted" |
72 | | - external |
73 | | - href="https://appwrite.io/docs/advanced/platform/custom-domains">here</Link |
74 | | - >. |
75 | | - </Alert.Inline> |
| 139 | + {#if variant === 'cname' && !subdomain} |
| 140 | + {#if isCloud} |
| 141 | + <Alert.Inline> |
| 142 | + Since <Badge variant="secondary" size="s" content={domain} /> is an apex domain, CNAME |
| 143 | + record is only supported by certain providers. If yours doesn't, please verify using |
| 144 | + <Link variant="muted" on:click={onNavigateToNameservers}>nameservers</Link> instead. |
| 145 | + </Alert.Inline> |
| 146 | + {:else if aTabVisible || aaaaTabVisible} |
| 147 | + <Alert.Inline> |
| 148 | + Since <Badge variant="secondary" size="s" content={domain} /> is an apex domain, CNAME |
| 149 | + record is only supported by certain providers. If yours doesn't, please verify using |
| 150 | + {#if aTabVisible} |
| 151 | + <Link variant="muted" on:click={onNavigateToA}>A record</Link> |
| 152 | + {#if aaaaTabVisible} |
| 153 | + or <Link variant="muted" on:click={onNavigateToAAAA}>AAAA record</Link |
| 154 | + >{/if} |
| 155 | + {:else if aaaaTabVisible} |
| 156 | + <Link variant="muted" on:click={onNavigateToAAAA}>AAAA record</Link> |
| 157 | + {/if} instead. |
| 158 | + </Alert.Inline> |
| 159 | + {/if} |
76 | 160 | {:else} |
77 | 161 | <Typography.Text variant="m-400" color="--fgcolor-neutral-secondary"> |
78 | 162 | A list of all domain providers and their DNS setting is available <Link |
|
0 commit comments