Skip to content

Commit 235fe34

Browse files
Refactor domain verification status handling
Change verified prop from boolean to boolean|undefined to better represent three-state verification (undefined/pending, true/verified, false/failed). Remove "Pending verification" badges and standardize verification error messages. Fix grid layout for domain metrics and improve error handling by displaying error messages instead of error objects.
1 parent 056a066 commit 235fe34

File tree

19 files changed

+80
-69
lines changed

19 files changed

+80
-69
lines changed

src/lib/components/domains/cnameTable.svelte

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
1313
1414
export let domain: string;
15-
export let verified = false;
15+
export let verified = undefined;
1616
1717
let subdomain = domain.split('.').slice(0, -2).join('.');
1818
</script>
@@ -23,16 +23,10 @@
2323
<Typography.Text variant="l-500" color="--fgcolor-neutral-primary">
2424
{domain}
2525
</Typography.Text>
26-
{#if verified}
27-
<Badge variant="secondary" type="success" content="Verified" />
26+
{#if verified === true}
27+
<Badge variant="secondary" type="success" size="xs" content="Verified" />
2828
{:else if verified === false}
29-
<Badge variant="secondary" type="error" content="Verification failed" />
30-
{:else}
31-
<Badge
32-
variant="secondary"
33-
type="warning"
34-
size="xs"
35-
content="Pending verification" />
29+
<Badge variant="secondary" type="error" size="xs" content="Verification failed" />
3630
{/if}
3731
</Layout.Stack>
3832
<Typography.Text variant="m-400">

src/lib/components/domains/nameserverTable.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { Badge, Layout, Typography, Table, InteractiveText } from '@appwrite.io/pink-svelte';
55
66
export let domain: string;
7-
export let verified = false;
7+
export let verified = undefined;
88
99
const nameserverList = $regionalConsoleVariables?._APP_DOMAINS_NAMESERVERS
1010
? $regionalConsoleVariables?._APP_DOMAINS_NAMESERVERS?.split(',')
@@ -16,10 +16,10 @@
1616
<Typography.Text variant="l-500" color="--fgcolor-neutral-primary">
1717
{domain}
1818
</Typography.Text>
19-
{#if verified}
19+
{#if verified === true}
2020
<Badge variant="secondary" type="success" size="xs" content="Verified" />
2121
{:else if verified === false}
22-
<Badge variant="secondary" type="warning" size="xs" content="Pending verification" />
22+
<Badge variant="secondary" type="warning" size="xs" content="Verification failed" />
2323
{/if}
2424
</Layout.Stack>
2525
<Typography.Text variant="m-400">

src/lib/components/domains/recordTable.svelte

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
1212
1313
export let domain: string;
14-
export let verified = false;
14+
export let verified = undefined;
1515
export let variant: 'cname' | 'a' | 'aaaa';
1616
export let service: 'sites' | 'general' = 'general';
1717
@@ -37,16 +37,10 @@
3737
<Typography.Text variant="l-500" color="--fgcolor-neutral-primary">
3838
{domain}
3939
</Typography.Text>
40-
{#if verified}
40+
{#if verified === true}
4141
<Badge variant="secondary" type="success" size="xs" content="Verified" />
4242
{:else if verified === false}
4343
<Badge variant="secondary" type="error" size="xs" content="Verification failed" />
44-
{:else}
45-
<Badge
46-
variant="secondary"
47-
type="warning"
48-
size="xs"
49-
content="Pending verification" />
5044
{/if}
5145
</Layout.Stack>
5246
<Typography.Text variant="m-400">

src/lib/components/usageCard.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
</Typography.Caption>
1414
<slot>
1515
{#if value !== null && value !== undefined}
16-
<Typography.Text size="s" truncate color="--fgcolor-neutral-primary"
17-
>{value}</Typography.Text>
16+
<Typography.Text size="s" truncate color="--fgcolor-neutral-primary">
17+
{value}
18+
</Typography.Text>
1819
{:else}
1920
<Skeleton variant="line" width="100%" height={19.5} />
2021
{/if}

src/routes/(console)/organization-[organization]/domains/domain-[domain]/domainMetrics.svelte

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,26 @@
4343
];
4444
</script>
4545

46-
<Layout.Grid gap="m" columnsL={2} columns={1}>
47-
<Layout.Stack direction="row" gap="m">
48-
{#each metrics.slice(0, 3) as metric}
49-
{#if metric.description === 'Status'}
50-
<UsageCard description={metric.description}>
51-
<Layout.Stack direction="row" gap="xs" alignItems="center">
52-
<Status
53-
label={metric.value.toString()}
54-
status={isDomainVerified ? 'complete' : 'pending'} />
46+
<Layout.Grid gap="m" columnsL={6} columns={3} columnsS={2} columnsXXS={1}>
47+
{#each metrics.slice(0, 3) as metric}
48+
{#if metric.description === 'Status'}
49+
<UsageCard description={metric.description}>
50+
<Layout.Stack direction="row" gap="xs" alignItems="center">
51+
<Status
52+
--font-size-s="var(--font-size-xs)"
53+
label={metric.value.toString()}
54+
status={isDomainVerified ? 'complete' : 'pending'} />
5555

56-
{#if !isDomainVerified}
57-
<Link on:click={retryVerification}>Retry</Link>
58-
{/if}
59-
</Layout.Stack>
60-
</UsageCard>
61-
{:else}
62-
<UsageCard description={metric.description} bind:value={metric.value} />
63-
{/if}
64-
{/each}
65-
</Layout.Stack>
66-
<Layout.Stack direction="row" gap="m">
67-
{#each metrics.slice(3) as metric}
56+
{#if !isDomainVerified}
57+
<Link size="s" on:click={retryVerification}>Retry</Link>
58+
{/if}
59+
</Layout.Stack>
60+
</UsageCard>
61+
{:else}
6862
<UsageCard description={metric.description} bind:value={metric.value} />
69-
{/each}
70-
</Layout.Stack>
63+
{/if}
64+
{/each}
65+
{#each metrics.slice(3) as metric}
66+
<UsageCard description={metric.description} bind:value={metric.value} />
67+
{/each}
7168
</Layout.Grid>

src/routes/(console)/organization-[organization]/domains/recordsCard.svelte

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
} else {
4747
addNotification({
4848
type: 'error',
49-
message: 'Domain not verified'
49+
message:
50+
'Domain verification failed. Please check your domain settings or try again later'
5051
});
5152
}
5253
} catch (error) {
@@ -68,21 +69,18 @@
6869
</div>
6970
<Layout.Stack gap="s">
7071
<Layout.Stack gap="s" direction="row" alignItems="center">
71-
<Typography.Text variant="l-500" color="--fgcolor-neutral-primary"
72-
>{domain.domain}</Typography.Text>
72+
<Typography.Text variant="l-500" color="--fgcolor-neutral-primary">
73+
{domain.domain}
74+
</Typography.Text>
7375

7476
{#if verified === false}
7577
<Badge
7678
variant="secondary"
7779
type="error"
7880
size="xs"
7981
content="Verification failed" />
80-
{:else}
81-
<Badge
82-
variant="secondary"
83-
type="warning"
84-
size="xs"
85-
content="Pending verification" />
82+
{:else if verified === true}
83+
<Badge variant="secondary" type="success" size="xs" content="Verified" />
8684
{/if}
8785
</Layout.Stack>
8886
<Typography.Text variant="m-400">

src/routes/(console)/organization-[organization]/domains/retryDomainModal.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@
3131
} else {
3232
addNotification({
3333
type: 'error',
34-
message: `Domain verification failed. Please check your domain settings or try again later`
34+
message:
35+
'Domain verification failed. Please check your domain settings or try again later'
3536
});
3637
}
3738
await invalidate(Dependencies.DOMAINS);
3839
trackEvent(Submit.DomainUpdateVerification);
3940
} catch (e) {
40-
error = e;
41+
error = e.message;
4142
trackError(e, Submit.DomainUpdateVerification);
4243
}
4344
}

src/routes/(console)/project-[region]-[project]/functions/function-[function]/domains/add-domain/+page.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@
8282
await goto(routeBase);
8383
await invalidate(Dependencies.FUNCTION_DOMAINS);
8484
} else {
85-
await goto(`${routeBase}/add-domain/verify-${domainName}?rule=${rule.$id}`);
85+
await goto(
86+
`${routeBase}/add-domain/verify-${domainName}?rule=${rule.$id}&domain=${domain.$id}`
87+
);
8688
await invalidate(Dependencies.FUNCTION_DOMAINS);
8789
}
8890
} catch (error) {

src/routes/(console)/project-[region]-[project]/functions/function-[function]/domains/add-domain/verify-[domain]/+page.svelte

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
let { data } = $props();
2929
3030
const ruleId = page.url.searchParams.get('rule');
31+
const domainId = page.url.searchParams.get('domain');
3132
const isSubDomain = $derived.by(() => isASubdomain(page.params.domain));
3233
3334
let selectedTab = $state<'cname' | 'nameserver' | 'a' | 'aaaa'>('nameserver');
@@ -42,14 +43,15 @@
4243
selectedTab = 'nameserver';
4344
}
4445
});
45-
let verified = $state(false);
46+
let verified: boolean | undefined = $state(undefined);
4647
4748
let routeBase = `${base}/project-${page.params.region}-${page.params.project}/functions/function-${page.params.function}/domains`;
4849
let isSubmitting = $state(writable(false));
4950
5051
async function verify() {
5152
const isNewDomain =
52-
data.domainsList.domains.findIndex((rule) => rule.domain === page.params.domain) === -1;
53+
data.domainsList.domains.find((rule) => rule.domain === page.params.domain) ===
54+
undefined;
5355
try {
5456
if (selectedTab !== 'nameserver') {
5557
const ruleData = await sdk
@@ -62,6 +64,13 @@
6264
page.params.domain
6365
);
6466
verified = domainData.nameservers.toLocaleLowerCase() === 'appwrite';
67+
} else if (!isNewDomain && isCloud) {
68+
const domain = await sdk.forConsole.domains.updateNameservers(domainId);
69+
verified = domain.nameservers === 'Appwrite';
70+
if (!verified)
71+
throw new Error(
72+
'Domain verification failed. Please check your domain settings or try again later'
73+
);
6574
}
6675
6776
addNotification({

src/routes/(console)/project-[region]-[project]/functions/function-[function]/domains/retryDomainModal.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
});
2828
trackEvent(Submit.DomainUpdateVerification);
2929
} catch (e) {
30-
error = e;
30+
error = e.message;
3131
trackError(e, Submit.DomainUpdateVerification);
3232
}
3333
}

0 commit comments

Comments
 (0)