From f50173790750c85a9ef28b212fbf3143f8a9d8ac Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 6 Mar 2025 17:56:44 +0100 Subject: [PATCH] feat: domains page fixes --- src/lib/components/modal.svelte | 9 +- .../domains/+page.svelte | 17 +- .../domains/domain-[domain]/+page.svelte | 29 ++- .../domain-[domain]/addPresetModal.svelte | 13 +- .../domain-[domain]/createRecordModal.svelte | 191 ++++++++++----- .../domain-[domain]/deleteRecordModal.svelte | 4 +- .../domain-[domain]/domainMetrics.svelte | 37 ++- .../domain-[domain]/editRecordModal.svelte | 158 ------------- .../domain-[domain]/importRecordModal.svelte | 59 +++++ .../domain-[domain]/settings/+page.svelte | 2 - .../settings/changeOrganization.svelte | 21 +- .../domains/domain-[domain]/store.ts | 57 ++++- .../domains/domain-[domain]/table.svelte | 6 +- .../domain-[domain]/updateRecordModal.svelte | 223 ++++++++++++++++++ .../project-[project]/settings/+page.svelte | 39 +-- .../settings/changeOrganization.svelte | 43 ++++ ...ect.svelte => transferProjectModal.svelte} | 14 +- 17 files changed, 604 insertions(+), 318 deletions(-) delete mode 100644 src/routes/(console)/organization-[organization]/domains/domain-[domain]/editRecordModal.svelte create mode 100644 src/routes/(console)/organization-[organization]/domains/domain-[domain]/importRecordModal.svelte create mode 100644 src/routes/(console)/organization-[organization]/domains/domain-[domain]/updateRecordModal.svelte create mode 100644 src/routes/(console)/project-[project]/settings/changeOrganization.svelte rename src/routes/(console)/project-[project]/settings/{transferProject.svelte => transferProjectModal.svelte} (82%) diff --git a/src/lib/components/modal.svelte b/src/lib/components/modal.svelte index 17bc9bb00..9bd18b068 100644 --- a/src/lib/components/modal.svelte +++ b/src/lib/components/modal.svelte @@ -1,9 +1,8 @@ - + {#if data.recordList.total} - - - - + + + + + Export as .txt + - + - + {#each presets as preset} { + on:click={(e) => { + toggle(e); selectedPreset = preset; showPresetModal = true; }}>{preset} @@ -108,3 +115,7 @@ {#if showPresetModal} {/if} + +{#if showImportModal} + +{/if} 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 76534c2ef..e9d55fcda 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/addPresetModal.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/addPresetModal.svelte @@ -5,15 +5,19 @@ import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; import { Skeleton, Table } from '@appwrite.io/pink-svelte'; import { capitalize } from '$lib/helpers/string'; + import { sdk } from '$lib/stores/sdk'; + import { page } from '$app/stores'; export let show = false; export let selectedPreset; let error = ''; async function fetchPreset() { - //TODO: fetch preset data - let presetData; - return presetData; + switch (selectedPreset.toLowerCase()) { + //TODO: finish switch statement + case 'zoho': + return await sdk.forConsole.domains.getPresetZoho($page.params.domain); + } } async function handleSubmit() { @@ -33,6 +37,8 @@ trackError(e, Submit.RecordCreate); } } + + $: console.log(selectedPreset); {/each} {:then presetData} + {JSON.stringify(presetData)} {#each presetData as record} {record.type} 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 545390677..8df2d14cf 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/createRecordModal.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/createRecordModal.svelte @@ -7,66 +7,31 @@ InputTextarea } from '$lib/elements/forms'; import { Modal } from '$lib/components'; - import { Icon, Layout, Tooltip } from '@appwrite.io/pink-svelte'; + import { Icon, Layout, Tooltip, Input } from '@appwrite.io/pink-svelte'; import { IconInfo } from '@appwrite.io/pink-icons-svelte'; import { addNotification } from '$lib/stores/notifications'; import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; + import { sdk } from '$lib/stores/sdk'; + import { page } from '$app/stores'; + import { recordTypes } from './store'; + import { Dependencies } from '$lib/constants'; + import { invalidate } from '$app/navigation'; - type RecordType = 'A' | 'AAAA' | 'CNAME' | 'MX' | 'TXT' | 'NS' | 'SRV' | 'CAA' | 'PTR'; + type RecordType = + | 'A' + | 'AAAA' + | 'CNAME' + | 'MX' + | 'TXT' + | 'NS' + | 'SRV' + | 'CAA' + | 'PTR' + | 'HTTPS' + | 'ALIAS'; export let show = false; - const options = [ - { - value: 'A', - label: 'A ', - helper: 'A records map a domain to an IPv4 address, allowing browsers to find your website by translating the domain name to an IP address.' - }, - { - value: 'AAAA', - label: 'AAAA ', - helper: 'AAAA records map a domain to an IPv6 address, providing the same function as A records but for IPv6-enabled devices.' - }, - { - value: 'CNAME', - label: 'CNAME', - helper: 'CNAME records alias one domain name to another, allowing you to point subdomains or other domain names to an existing domain.' - }, - { - value: 'MX', - label: 'MX ', - helper: 'MX records specify mail servers responsible for receiving emails for a domain, helping route email traffic to the correct mail server.' - }, - { - value: 'TXT', - label: 'TXT', - helper: 'TXT records store arbitrary text data in DNS, commonly used for verification purposes, such as domain ownership or email security settings.' - }, - { - value: 'NS', - label: 'NS', - helper: "NS records define the authoritative DNS servers for a domain, directing queries to the servers that manage the domain's DNS settings." - }, - { - value: 'SRV', - label: 'SRV', - helper: 'SRV records specify the location (hostname and port number) of servers for specific services, directing traffic to particular servers based on service types.' - }, - { - value: 'CAA', - label: 'CAA', - helper: 'CAA records specify which certificate authorities are allowed to issue SSL certificates for your domain, helping to prevent unauthorized certificate issuance.' - }, - { - value: 'HTTPS', - label: 'HTTPS', - helper: 'HTTPS records define which service or endpoint handles secure HTTPS traffic for your domain, typically used in SSL/TLS configurations.' - }, - { - value: 'ALIAS', - label: 'ALIAS', - 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 = 'A'; let value: string; @@ -77,9 +42,106 @@ async function handleSubmit() { try { - //TODO: create DNS record + switch (type) { + case 'A': + await sdk.forConsole.domains.createRecordA( + $page.params.domain, + name, + value, + ttl, + comment || undefined + ); + + break; + case 'AAAA': + await sdk.forConsole.domains.createRecordAAAA( + $page.params.domain, + name, + value, + ttl, + comment + ); + + break; + case 'CNAME': + await sdk.forConsole.domains.createRecordCNAME( + $page.params.domain, + name, + value, + ttl, + comment + ); + + break; + case 'MX': + await sdk.forConsole.domains.createRecordMX( + $page.params.domain, + name, + value, + ttl, + priority, + comment + ); + + break; + case 'TXT': + await sdk.forConsole.domains.createRecordTXT( + $page.params.domain, + name, + value, + ttl, + comment + ); + + break; + case 'NS': + await sdk.forConsole.domains.createRecordNS( + $page.params.domain, + name, + value, + ttl, + comment + ); + + break; + + case 'CAA': + await sdk.forConsole.domains.createRecordCAA( + $page.params.domain, + name, + value, + ttl, + comment + ); + + break; + case 'HTTPS': + await sdk.forConsole.domains.createRecordHTTPS( + $page.params.domain, + name, + value, + ttl, + comment + ); + + break; + case 'ALIAS': + await sdk.forConsole.domains.createRecordAlias( + $page.params.domain, + name, + value, + ttl, + comment + ); + + break; + + default: + break; + } show = false; + invalidate(Dependencies.DOMAINS); addNotification({ type: 'success', message: `Record has been created` @@ -97,18 +159,17 @@ DNS records map domain names to IP addresses or other resources. - + - - - - {options.find((option) => option.value === type)?.helper} - + + + {recordTypes.find((option) => option.value === type)?.helper} + - + Enter the target or destination for this DNS record (e.g., IP address, hostname, or other required data) @@ -118,7 +179,7 @@ - + TTL defines how long DNS information is cached. Lower values update faster; higher values reduce server load. @@ -131,7 +192,7 @@ placeholder="Enter number" bind:value={priority}> - + Sets the priority for this DNS record. Lower numbers indicate higher priority (e.g., 10 is higher than 20). @@ -149,6 +210,6 @@ - + diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/deleteRecordModal.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/deleteRecordModal.svelte index e298d520b..fbf449188 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/deleteRecordModal.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/deleteRecordModal.svelte @@ -2,14 +2,14 @@ import { sdk } from '$lib/stores/sdk'; import { addNotification } from '$lib/stores/notifications'; import { invalidate } from '$app/navigation'; - import type { Models } from '@appwrite.io/console'; import { Submit, trackEvent, trackError } from '$lib/actions/analytics'; import { Dependencies } from '$lib/constants'; import { Confirm } from '$lib/components'; import { page } from '$app/stores'; + import type { DnsRecord } from '$lib/sdk/domains'; export let show = false; - export let selectedRecord: Models.DnsRecord; + export let selectedRecord: DnsRecord; let error = ''; diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/domainMetrics.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/domainMetrics.svelte index 43d0b64be..dab70a3b6 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/domainMetrics.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/domainMetrics.svelte @@ -1,10 +1,12 @@ - - {#each metrics as metric} - - {/each} - + + + {#each metrics.slice(0, 3) as metric} + {#if metric.description === 'Domain'} + + + + {metric.value} + + + + {:else} + + {/if} + {/each} + + + {#each metrics.slice(3) as metric} + + {/each} + + diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/editRecordModal.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/editRecordModal.svelte deleted file mode 100644 index a022a7822..000000000 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/editRecordModal.svelte +++ /dev/null @@ -1,158 +0,0 @@ - - - - - DNS records map domain names to IP addresses or other resources. - - - - - - - - - - - - - - - {options.find((option) => option.value === record.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]/importRecordModal.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/importRecordModal.svelte new file mode 100644 index 000000000..fe61b49f8 --- /dev/null +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/importRecordModal.svelte @@ -0,0 +1,59 @@ + + + + + Import DNS zone file to apply its records to your domain. If conflicts arise, the upload will be blocked. + + + + + + + + Drag and drop file here or click to upload + + + + + + Only .txt files allowed + + + Max file size 10MB + + + + + + + + diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.svelte index 7b08129ed..cc1828f62 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.svelte @@ -1,6 +1,5 @@ - Settings diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/changeOrganization.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/changeOrganization.svelte index c56753470..e505a962f 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/changeOrganization.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/changeOrganization.svelte @@ -1,19 +1,34 @@ + + + + DNS records map domain names to IP addresses or other resources. + + + + + + + {recordTypes.find((option) => option.value === record.type)?.helper} + + + + + + + + {recordTypes.find((option) => option.value === record.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)/project-[project]/settings/+page.svelte b/src/routes/(console)/project-[project]/settings/+page.svelte index 11579b9ec..999b11d80 100644 --- a/src/routes/(console)/project-[project]/settings/+page.svelte +++ b/src/routes/(console)/project-[project]/settings/+page.svelte @@ -2,7 +2,6 @@ import { sdk } from '$lib/stores/sdk'; import { onMount } from 'svelte'; import { addNotification } from '$lib/stores/notifications'; - import { organizationList } from '$lib/stores/organization'; import { project } from '../store'; import { Container } from '$lib/layout'; import { invalidate } from '$app/navigation'; @@ -12,16 +11,13 @@ import UpdateInstallations from './updateInstallations.svelte'; import UpdateVariables from '../updateVariables.svelte'; import DeleteProject from './deleteProject.svelte'; - import { CardGrid } from '$lib/components'; - import { Button, InputSelect } from '$lib/elements/forms'; import { Submit, trackEvent } from '$lib/actions/analytics'; - import Transfer from './transferProject.svelte'; import { canWriteProjects } from '$lib/stores/roles'; + import ChangeOrganization from './changeOrganization.svelte'; export let data; let teamId: string = null; - let showTransfer = false; onMount(() => { teamId ??= $project.teamId; @@ -87,39 +83,8 @@ isGlobal={true} variableList={data.variables} analyticsSource="project_settings" /> - - Transfer project - Transfer your project to another organization that you own. - - team.$id !== $project.teamId) - .map((team) => ({ - value: team.$id, - label: team.name - }))} /> - - - - - - + {/if} {/if} - -{#if teamId} - t.$id == teamId).name} - bind:show={showTransfer} /> -{/if} diff --git a/src/routes/(console)/project-[project]/settings/changeOrganization.svelte b/src/routes/(console)/project-[project]/settings/changeOrganization.svelte new file mode 100644 index 000000000..848b718db --- /dev/null +++ b/src/routes/(console)/project-[project]/settings/changeOrganization.svelte @@ -0,0 +1,43 @@ + + + + Change organization + Select an organization you own to move this project. + + team.$id !== $project.teamId) + .map((team) => ({ + value: team.$id, + label: team.name + }))} /> + + + + + + + +{#if teamId} + t.$id == teamId).name} + bind:show={showTransfer} /> +{/if} diff --git a/src/routes/(console)/project-[project]/settings/transferProject.svelte b/src/routes/(console)/project-[project]/settings/transferProjectModal.svelte similarity index 82% rename from src/routes/(console)/project-[project]/settings/transferProject.svelte rename to src/routes/(console)/project-[project]/settings/transferProjectModal.svelte index 877294fc5..3ad4c9e72 100644 --- a/src/routes/(console)/project-[project]/settings/transferProject.svelte +++ b/src/routes/(console)/project-[project]/settings/transferProjectModal.svelte @@ -2,7 +2,7 @@ import { goto } from '$app/navigation'; import { base } from '$app/paths'; import { Submit, trackEvent, trackError } from '$lib/actions/analytics'; - import { Modal } from '$lib/components'; + import { Confirm } from '$lib/components'; import { Button } from '$lib/elements/forms'; import { addNotification } from '$lib/stores/notifications'; import { sdk } from '$lib/stores/sdk'; @@ -10,8 +10,8 @@ import { project } from '../store'; export let show = false; - export let teamName; - export let teamId; + export let teamName: string; + export let teamId: string; const handleTransfer = async () => { try { @@ -33,9 +33,9 @@ }; - + Are you sure you want to transfer {$project.name} to + >Are you sure you want to move {$project.name} to {teamName}? Members who are not part of the destination organization must be invited to gain access to @@ -44,6 +44,6 @@ - + - +