From 05f68ea331e95af9ed685eb9125c53c49913cd69 Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 20 Feb 2025 15:41:19 +0100 Subject: [PATCH] feat: domains --- package.json | 2 +- pnpm-lock.yaml | 12 +++--- src/lib/components/usageCard.svelte | 2 +- src/lib/stores/sdk.ts | 9 ++-- .../organization-[organization]/+page.svelte | 1 - .../domains/+page.svelte | 20 +++++---- .../domains/+page.ts | 15 +++---- .../domains/add-domain/+page.svelte | 10 ++--- .../domains/deleteDomainModal.svelte | 21 +++------- .../domains/domain-[domain]/+layout.ts | 2 +- .../domains/domain-[domain]/+page.svelte | 2 +- .../domains/domain-[domain]/+page.ts | 42 +------------------ .../domain-[domain]/certificates/+page.ts | 2 +- .../domain-[domain]/domainMetrics.svelte | 6 +-- .../settings/changeOrganization.svelte | 8 +++- .../settings/deleteDomain.svelte | 2 +- .../domains/domain-[domain]/store.ts | 3 +- .../domains/domain-[domain]/table.svelte | 16 +++---- .../organization-[organization]/header.svelte | 3 +- 19 files changed, 67 insertions(+), 111 deletions(-) diff --git a/package.json b/package.json index 64818c5f9..bd447131c 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "e2e:ui": "playwright test tests/e2e --ui" }, "dependencies": { - "@appwrite.io/console": "https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@d13e864", + "@appwrite.io/console": "https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@53cae2d", "@appwrite.io/pink-icons": "0.25.0", "@appwrite.io/pink-icons-svelte": "https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@011c2131", "@appwrite.io/pink-legacy": "^1.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5bab9a8b8..d3236de39 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@appwrite.io/console': - specifier: https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@d13e864 - version: https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@d13e864 + specifier: https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@53cae2d + version: https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@53cae2d '@appwrite.io/pink-icons': specifier: 0.25.0 version: 0.25.0 @@ -211,9 +211,9 @@ packages: '@analytics/type-utils@0.6.2': resolution: {integrity: sha512-TD+xbmsBLyYy/IxFimW/YL/9L2IEnM7/EoV9Aeh56U64Ify8o27HJcKjo38XY9Tcn0uOq1AX3thkKgvtWvwFQg==} - '@appwrite.io/console@https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@d13e864': - resolution: {tarball: https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@d13e864} - version: 1.2.1 + '@appwrite.io/console@https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@53cae2d': + resolution: {tarball: https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@53cae2d} + version: 1.4.1 '@appwrite.io/pink-icons-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@011c2131': resolution: {tarball: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@011c2131} @@ -4097,7 +4097,7 @@ snapshots: '@analytics/type-utils@0.6.2': {} - '@appwrite.io/console@https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@d13e864': {} + '@appwrite.io/console@https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@53cae2d': {} '@appwrite.io/pink-icons-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@011c2131(svelte@4.2.19)': dependencies: diff --git a/src/lib/components/usageCard.svelte b/src/lib/components/usageCard.svelte index af652f91d..fc4888741 100644 --- a/src/lib/components/usageCard.svelte +++ b/src/lib/components/usageCard.svelte @@ -3,7 +3,7 @@ import { Layout, Skeleton, Typography } from '@appwrite.io/pink-svelte'; export let description: string; - export let value: string = null; + export let value: string | number = null; diff --git a/src/lib/stores/sdk.ts b/src/lib/stores/sdk.ts index b33a0bd8e..fea512f86 100644 --- a/src/lib/stores/sdk.ts +++ b/src/lib/stores/sdk.ts @@ -20,7 +20,8 @@ import { Teams, Users, Vcs, - Sites + Sites, + Domains } from '@appwrite.io/console'; import { Billing } from '../sdk/billing'; import { Backups } from '../sdk/backups'; @@ -57,7 +58,8 @@ const sdkForProject = { vcs: new Vcs(clientProject), proxy: new Proxy(clientProject), migrations: new Migrations(clientProject), - sites: new Sites(clientProject) + sites: new Sites(clientProject), + domains: new Domains(clientProject) }; export const getSdkForProject = (projectId: string) => { @@ -83,7 +85,8 @@ export const sdk = { console: new Console(clientConsole), assistant: new Assistant(clientConsole), billing: new Billing(clientConsole), - sources: new Sources(clientConsole) + sources: new Sources(clientConsole), + domains: new Domains(clientConsole) }, get forProject() { const projectId = getProjectId(); diff --git a/src/routes/(console)/organization-[organization]/+page.svelte b/src/routes/(console)/organization-[organization]/+page.svelte index 489505a02..b81a0710e 100644 --- a/src/routes/(console)/organization-[organization]/+page.svelte +++ b/src/routes/(console)/organization-[organization]/+page.svelte @@ -39,7 +39,6 @@ IconApple, IconCode, IconFlutter, - IconGlobe, IconPlus, IconReact, IconUnity diff --git a/src/routes/(console)/organization-[organization]/domains/+page.svelte b/src/routes/(console)/organization-[organization]/domains/+page.svelte index 3631617b9..ea30ac199 100644 --- a/src/routes/(console)/organization-[organization]/domains/+page.svelte +++ b/src/routes/(console)/organization-[organization]/domains/+page.svelte @@ -35,7 +35,7 @@ let showDelete = false; let showRetry = false; - let selectedDomain: Models.ProxyRule = null; + let selectedDomain: Models.Domain = null; $: console.log(data.domains); @@ -66,7 +66,7 @@ Auto renewal - {#each data.domains.rules as domain} + {#each data.domains.domains as domain} @@ -81,24 +81,26 @@ - {#if domain.status === 'created'} + {#if !domain.verified} {:else if domain.status === 'veryfing'} {/if} - {domain?.registrar ?? '-'} - {domain?.nameservers ?? '-'} - {domain?.expiry ?? '-'} + {domain?.registrar || '-'} + {domain?.nameservers || '-'} + {domain?.expiry || '-'} - {domain.renewAt ? toLocaleDateTime(domain.renewAt) : '-'} + {domain.renewal ? toLocaleDateTime(domain.renewal) : '-'} {domain.autoRenewal ? 'On' : 'Off'} @@ -116,7 +118,7 @@ - {#if domain.status !== 'verified'} + { limit, query, search, - domains: await sdk.forProject.proxy.listRules( - [ - Query.limit(limit), - Query.offset(offset), - Query.orderDesc(''), - ...parsedQueries.values() - ], - search || undefined - ) + domains: await sdk.forConsole.domains.list([ + Query.limit(limit), + Query.offset(offset), + Query.orderDesc(''), + ...parsedQueries.values() + ]) }; }; diff --git a/src/routes/(console)/organization-[organization]/domains/add-domain/+page.svelte b/src/routes/(console)/organization-[organization]/domains/add-domain/+page.svelte index 398a7d031..b178bdf9d 100644 --- a/src/routes/(console)/organization-[organization]/domains/add-domain/+page.svelte +++ b/src/routes/(console)/organization-[organization]/domains/add-domain/+page.svelte @@ -23,15 +23,11 @@ const backPage = `${base}/project-${$page.params.project}/sites/site-${$page.params.site}/domains`; let domain = ''; - let domainData: Models.ProxyRule; + let domainData: Models.Domain; async function addDomain() { try { - domainData = await sdk.forProject.proxy.createRule( - domain, - ResourceType.Site, - $page.params.site - ); + domainData = await sdk.forConsole.domains.create($page.params.organization, domain); console.log(domainData); invalidate(Dependencies.SITES_DOMAINS); } catch (error) { @@ -44,7 +40,7 @@ async function verifyStatus() { try { - domainData = await sdk.forProject.proxy.updateRuleVerification(domainData.$id); + // domainData = await sdk.forConsole.domains.verification(domainData.$id); console.log(domainData); } catch (error) { addNotification({ diff --git a/src/routes/(console)/organization-[organization]/domains/deleteDomainModal.svelte b/src/routes/(console)/organization-[organization]/domains/deleteDomainModal.svelte index bbe3b6924..98e11b70d 100644 --- a/src/routes/(console)/organization-[organization]/domains/deleteDomainModal.svelte +++ b/src/routes/(console)/organization-[organization]/domains/deleteDomainModal.svelte @@ -8,25 +8,13 @@ import { Confirm } from '$lib/components'; export let show = false; - export let selectedDomain: Models.ProxyRule; + export let selectedDomain: Models.Domain; let error = ''; - function getCorrectMessage(): string { - const resourceType = selectedDomain.resourceType; - switch (resourceType) { - case 'api': - return `access ${resourceType}`; - case 'function': - return `execute your ${resourceType}`; - case 'site': - return `view your ${resourceType} `; - } - } - async function deleteDomain() { try { - await sdk.forProject.proxy.deleteRule(selectedDomain.$id); + await sdk.forConsole.domains.delete(selectedDomain.$id); await invalidate(Dependencies.DOMAINS); show = false; addNotification({ @@ -41,7 +29,10 @@ } +

Are you sure you want to delete {selectedDomain?.domain}?

-

You will no longer be able to {getCorrectMessage()} by visiting this domain.

+

+ You will no longer be able to access any projects or services associated with this domain. +

diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/+layout.ts b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/+layout.ts index b8fdc658c..2256854df 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/+layout.ts +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/+layout.ts @@ -7,7 +7,7 @@ export const load = async ({ depends, params }) => { depends(Dependencies.SITE); return { - domain: await sdk.forProject.proxy.getRule(params.domain), + domain: await sdk.forConsole.domains.get(params.domain), header: Header, breadcrumbs: Breadcrumbs }; diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/+page.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/+page.svelte index e398d88e5..7d232ef38 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/+page.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/+page.svelte @@ -36,7 +36,7 @@ - {#if data.records.total} + {#if data.recordList.total} + @@ -133,5 +135,5 @@ name="Domains" limit={data.limit} offset={data.offset} - total={data.records.total} /> + total={data.recordList.total} /> diff --git a/src/routes/(console)/organization-[organization]/header.svelte b/src/routes/(console)/organization-[organization]/header.svelte index 18d40de2d..0c1fa061d 100644 --- a/src/routes/(console)/organization-[organization]/header.svelte +++ b/src/routes/(console)/organization-[organization]/header.svelte @@ -54,7 +54,8 @@ { href: `${path}/domains`, event: 'domains', - title: 'Domains' + title: 'Domains', + disabled: !isCloud // disabled: !(isCloud && $canSeeDomains) //TODO: enable this before release }, {