From cd550741727f4cdbc393adc2e2d0447a5124cbac Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 20 Feb 2025 17:04:23 +0100 Subject: [PATCH 1/2] feat: more work on domains --- .../domains/deleteDomainModal.svelte | 5 +- .../domains/domain-[domain]/+layout.ts | 2 +- .../domain-[domain]/addPresetModal.svelte | 1 - .../deleteCertificateModal.svelte | 6 +- .../domain-[domain]/createRecordModal.svelte | 8 +- .../domain-[domain]/deleteRecordModal.svelte | 35 ++++ .../domain-[domain]/editRecordModal.svelte | 152 ++++++++++++++++++ .../domains/domain-[domain]/table.svelte | 8 +- 8 files changed, 203 insertions(+), 14 deletions(-) create mode 100644 src/routes/(console)/organization-[organization]/domains/domain-[domain]/deleteRecordModal.svelte create mode 100644 src/routes/(console)/organization-[organization]/domains/domain-[domain]/editRecordModal.svelte diff --git a/src/routes/(console)/organization-[organization]/domains/deleteDomainModal.svelte b/src/routes/(console)/organization-[organization]/domains/deleteDomainModal.svelte index 98e11b70d..4e477cc7b 100644 --- a/src/routes/(console)/organization-[organization]/domains/deleteDomainModal.svelte +++ b/src/routes/(console)/organization-[organization]/domains/deleteDomainModal.svelte @@ -29,10 +29,7 @@ } -

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

-

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

+

Your site will no longer be available at this domain. This action is irreversible.

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 2256854df..fed93acca 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/+layout.ts +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/+layout.ts @@ -4,7 +4,7 @@ import { Dependencies } from '$lib/constants'; import { sdk } from '$lib/stores/sdk'; export const load = async ({ depends, params }) => { - depends(Dependencies.SITE); + depends(Dependencies.DOMAIN); return { domain: await sdk.forConsole.domains.get(params.domain), diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/addPresetModal.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/addPresetModal.svelte index 61b30d753..76534c2ef 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/addPresetModal.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/addPresetModal.svelte @@ -4,7 +4,6 @@ import { addNotification } from '$lib/stores/notifications'; import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; import { Skeleton, Table } from '@appwrite.io/pink-svelte'; - import { onMount } from 'svelte'; import { capitalize } from '$lib/helpers/string'; export let show = false; diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/deleteCertificateModal.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/deleteCertificateModal.svelte index f0f5ec638..8ea29833c 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/deleteCertificateModal.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/deleteCertificateModal.svelte @@ -1,11 +1,9 @@ - Are you sure you want to delete SSL certificate? This action is irreversible. + Are you sure you want to delete this SSL certificate? This action is irreversible. diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/createRecordModal.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/createRecordModal.svelte index 0571b00e4..545390677 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/createRecordModal.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/createRecordModal.svelte @@ -68,7 +68,7 @@ } ]; let name: string; - let type: RecordType; + let type: RecordType = 'A'; let value: string; let ttl = 3600; let priority: number; @@ -99,9 +99,10 @@ - + + {options.find((option) => option.value === type)?.helper} @@ -109,7 +110,8 @@ - {options.find((option) => option.value === type)?.helper} + Enter the target or destination for this DNS record (e.g., IP address, hostname, + or other required data) diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/deleteRecordModal.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/deleteRecordModal.svelte new file mode 100644 index 000000000..e298d520b --- /dev/null +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/deleteRecordModal.svelte @@ -0,0 +1,35 @@ + + + +

Are you sure you want to delete this record? This action is irreversible.

+
diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/editRecordModal.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/editRecordModal.svelte new file mode 100644 index 000000000..0571b00e4 --- /dev/null +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/editRecordModal.svelte @@ -0,0 +1,152 @@ + + + + + DNS records map domain names to IP addresses or other resources. + + + + + + + + + + + + + + + {options.find((option) => option.value === type)?.helper} + + + + + + + + + TTL defines how long DNS information is cached. Lower values update faster; + higher values reduce server load. + + + + + + + + Sets the priority for this DNS record. Lower numbers indicate higher + priority (e.g., 10 is higher than 20). + + + + + + + + + + + + + diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte index e845733eb..184af04ed 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte @@ -15,6 +15,8 @@ import { columns } from './store'; import { timeFromNow } from '$lib/helpers/date'; import type { Models } from '@appwrite.io/console'; + import DeleteRecordModal from './deleteRecordModal.svelte'; + import { capitalize } from '$lib/helpers/string'; export let data; @@ -79,7 +81,7 @@ {:else if column.id === '$createdAt'} - {timeFromNow(record.$createdAt)} + {capitalize(timeFromNow(record.$createdAt))} {/if} @@ -137,3 +139,7 @@ offset={data.offset} total={data.recordList.total} />
+ +{#if showDelete} + +{/if} From 08d67a6527df5ef18d60871e1bcdb16db961f618 Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 20 Feb 2025 17:15:12 +0100 Subject: [PATCH 2/2] feat: edit record modal --- src/lib/actions/analytics.ts | 1 + .../domain-[domain]/editRecordModal.svelte | 46 +++++++++++-------- .../domains/domain-[domain]/table.svelte | 4 ++ .../auth/user-[user]/updateLabels.svelte | 2 +- 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/lib/actions/analytics.ts b/src/lib/actions/analytics.ts index c0f5ea4d4..19975c6ee 100644 --- a/src/lib/actions/analytics.ts +++ b/src/lib/actions/analytics.ts @@ -343,5 +343,6 @@ export enum Submit { SiteDisconnectRepo = 'submit_site_disconnect_repo', SiteActivateDeployment = 'submit_site_activate_deployment', RecordCreate = 'submit_dns_record_create', + RecordUpdate = 'submit_dns_record_update', RecordDelete = 'submit_dns_record_delete' } diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/editRecordModal.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/editRecordModal.svelte index 0571b00e4..a022a7822 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/editRecordModal.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/editRecordModal.svelte @@ -11,10 +11,14 @@ import { IconInfo } from '@appwrite.io/pink-icons-svelte'; import { addNotification } from '$lib/stores/notifications'; import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; + import type { Models } from '@appwrite.io/console'; + import { symmetricDifference } from '$lib/helpers/array'; + import { deepClone } from '$lib/helpers/object'; - type RecordType = 'A' | 'AAAA' | 'CNAME' | 'MX' | 'TXT' | 'NS' | 'SRV' | 'CAA' | 'PTR'; + // type RecordType = 'A' | 'AAAA' | 'CNAME' | 'MX' | 'TXT' | 'NS' | 'SRV' | 'CAA' | 'PTR'; export let show = false; + export let selectedRecord: Models.DnsRecord; const options = [ { value: 'A', @@ -67,54 +71,56 @@ helper: 'ALIAS records are similar to CNAMEs but can be used for the root domain, allowing you to point your domain to another domain or server.' } ]; - let name: string; - let type: RecordType; - let value: string; - let ttl = 3600; - let priority: number; - let comment: string; + let record = deepClone(selectedRecord); let error = ''; async function handleSubmit() { try { - //TODO: create DNS record + //TODO: update DNS record show = false; addNotification({ type: 'success', - message: `Record has been created` + message: `Record has been updated` }); - trackEvent(Submit.RecordCreate); + trackEvent(Submit.RecordUpdate); } catch (e) { error = e.message; - trackError(e, Submit.RecordCreate); + trackError(e, Submit.RecordUpdate); } } + + $: if (!show) { + selectedRecord = null; + } + + $: isDisabled = !symmetricDifference(Object.values(record), Object.values(selectedRecord)) + ?.length; - + DNS records map domain names to IP addresses or other resources. - + - + - + - {options.find((option) => option.value === type)?.helper} + {options.find((option) => option.value === record.type)?.helper} - + @@ -127,7 +133,7 @@ id="priority" label="Priority" placeholder="Enter number" - bind:value={priority}> + bind:value={record.priority}> @@ -142,11 +148,11 @@ id="comment" label="Comment" placeholder="Provide an explanation of this DNS record's purpose" - bind:value={comment} /> + bind:value={record.comment} /> - + diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte index 184af04ed..13e39a9b9 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte @@ -17,6 +17,7 @@ import type { Models } from '@appwrite.io/console'; import DeleteRecordModal from './deleteRecordModal.svelte'; import { capitalize } from '$lib/helpers/string'; + import EditRecordModal from './editRecordModal.svelte'; export let data; @@ -143,3 +144,6 @@ {#if showDelete} {/if} +{#if showEdit} + +{/if} diff --git a/src/routes/(console)/project-[project]/auth/user-[user]/updateLabels.svelte b/src/routes/(console)/project-[project]/auth/user-[user]/updateLabels.svelte index 56e9fbf10..1e5ea732f 100644 --- a/src/routes/(console)/project-[project]/auth/user-[user]/updateLabels.svelte +++ b/src/routes/(console)/project-[project]/auth/user-[user]/updateLabels.svelte @@ -2,7 +2,7 @@ import { onMount } from 'svelte'; import { invalidate } from '$app/navigation'; import { Submit, trackEvent, trackError } from '$lib/actions/analytics'; - import { CardGrid, Heading } from '$lib/components'; + import { CardGrid } from '$lib/components'; import { Dependencies } from '$lib/constants'; import { Button, Form, Helper, InputTags } from '$lib/elements/forms'; import { symmetricDifference } from '$lib/helpers/array';