feat: domains page fixes

This commit is contained in:
Arman committed 2025-03-06 17:56:44 +01:00
1 parent 93896bd087
commit f501737907
17 files changed
+604 -318

No files matched your search

+4 -5
View File
@@ -1,9 +1,8 @@
<script lang="ts">
import { Alert } from '$lib/components';
import { Form } from '$lib/elements/forms';
import { disableCommands } from '$lib/commandCenter';
import { beforeNavigate } from '$app/navigation';
import { Layout, Modal } from '@appwrite.io/pink-svelte';
import { Alert, Layout, Modal } from '@appwrite.io/pink-svelte';
import { Click, trackEvent } from '$lib/actions/analytics';
export let show = false;
@@ -47,14 +46,14 @@
<slot slot="description" name="description" />
{#if error}
<div bind:this={alert}>
<Alert
<Alert.Inline
dismissible
type="warning"
status="warning"
on:dismiss={() => {
error = null;
}}>
{error}
</Alert>
</Alert.Inline>
</div>
{/if}
<slot />
@@ -70,18 +70,9 @@
<Table.Link
href={`${base}/organization-${$page.params.organization}/domains/domain-${domain.$id}`}>
<Table.Cell>
<Layout.Stack direction="row" alignItems="center" gap="xs">
<Link
external
href={`${$protocol}${domain.domain}`}
size="s"
variant="quiet">
<Layout.Stack direction="row" alignItems="center" gap="xs">
{domain.domain}
<Icon icon={IconExternalLink} size="s" />
</Layout.Stack>
</Link>
</Layout.Stack>
<Link external icon href={`${$protocol}${domain.domain}`} variant="quiet">
{domain.domain}
</Link>
</Table.Cell>
<Table.Cell>{domain?.registrar || '-'}</Table.Cell>
<Table.Cell>{domain?.nameservers || '-'}</Table.Cell>
@@ -93,7 +84,7 @@
<Table.Cell>{domain.autoRenewal ? 'On' : 'Off'}</Table.Cell>
<Table.Cell>
<Layout.Stack direction="row" justifyContent="flex-end">
<Popover let:toggle placement="bottom-start" padding="none">
<Popover let:toggle placement="bottom-end" padding="none">
<Button
text
icon
@@ -8,7 +8,8 @@
InlineCode,
Layout,
Button as PinkButton,
Popover
Popover,
Tooltip
} from '@appwrite.io/pink-svelte';
import DomainMetrics from './domainMetrics.svelte';
import { base } from '$app/paths';
@@ -21,41 +22,47 @@
import CreateRecordModal from './createRecordModal.svelte';
import Table from './table.svelte';
import AddPresetModal from './addPresetModal.svelte';
import ImportRecordModal from './importRecordModal.svelte';
export let data;
let showCreate = false;
let showPresetModal = false;
let showImportModal = false;
let selectedPreset = '';
const presets = ['Zoho', 'Mailgun', 'Outlook', 'Proton Mail', 'iCloud', 'Google Workspace'];
</script>
<Container>
<Layout.Stack gap="xxl">
<Layout.Stack gap="xxxl">
<DomainMetrics domain={data.domain} />
<Layout.Stack gap="l">
{#if data.recordList.total}
<Layout.Stack direction="row" justifyContent="space-between">
<Layout.Stack direction="row" gap="s" inline>
<Button secondary>
<Button secondary on:click={() => (showImportModal = true)}>
<Icon icon={IconUpload} size="s" slot="start" />
Import zone file
</Button>
<PinkButton.Button variant="secondary" icon>
<Icon icon={IconDownload} size="s" />
</PinkButton.Button>
<Tooltip>
<PinkButton.Button variant="secondary" icon>
<Icon icon={IconDownload} size="s" />
</PinkButton.Button>
<svelte:fragment slot="tooltip">Export as .txt</svelte:fragment>
</Tooltip>
</Layout.Stack>
<Layout.Stack direction="row" gap="s" inline>
<ViewSelector view={View.Table} {columns} hideView allowNoColumns />
<Popover let:toggle>
<Popover let:toggle padding="none">
<Button secondary on:click={toggle}>Add preset</Button>
<svelte:fragment slot="tooltip">
<svelte:fragment slot="tooltip" let:toggle>
<ActionMenu.Root>
{#each presets as preset}
<ActionMenu.Item.Button
on:click={() => {
on:click={(e) => {
toggle(e);
selectedPreset = preset;
showPresetModal = true;
}}>{preset}</ActionMenu.Item.Button>
@@ -108,3 +115,7 @@
{#if showPresetModal}
<AddPresetModal bind:show={showPresetModal} {selectedPreset} />
{/if}
{#if showImportModal}
<ImportRecordModal bind:show={showImportModal} />
{/if}
@@ -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);
</script>
<Modal
@@ -63,6 +69,7 @@
</Table.Row>
{/each}
{:then presetData}
{JSON.stringify(presetData)}
{#each presetData as record}
<Table.Row>
<Table.Cell>{record.type}</Table.Cell>
@@ -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.
</span>
<Layout.Stack gap="l">
<InputText id="name" label="Name" placeholder="subdomain" bind:value={name} />
<InputText id="name" label="Name" placeholder="subdomain" bind:value={name} required />
<Layout.Stack gap="xs">
<InputSelect {options} bind:value={type} id="type" label="Type" required />
<Layout.Stack direction="row" gap="xs">
<Icon icon={IconInfo} />
{options.find((option) => option.value === type)?.helper}
</Layout.Stack>
<InputSelect options={recordTypes} bind:value={type} id="type" label="Type" required />
<Input.Helper state="default">
{recordTypes.find((option) => option.value === type)?.helper}
</Input.Helper>
</Layout.Stack>
<InputText id="value" label="Value" placeholder="76.75.21.21" bind:value>
<Tooltip slot="info">
<Icon icon={IconInfo} />
<Icon icon={IconInfo} size="s" />
<span slot="tooltip">
Enter the target or destination for this DNS record (e.g., IP address, hostname,
or other required data)
@@ -118,7 +179,7 @@
<Layout.Stack direction="row" gap="l">
<InputNumber id="ttl" label="TTL" placeholder="Enter number" bind:value={ttl}>
<Tooltip slot="info">
<Icon icon={IconInfo} />
<Icon icon={IconInfo} size="s" />
<span slot="tooltip">
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}>
<Tooltip slot="info">
<Icon icon={IconInfo} />
<Icon icon={IconInfo} size="s" />
<span slot="tooltip">
Sets the priority for this DNS record. Lower numbers indicate higher
priority (e.g., 10 is higher than 20).
@@ -149,6 +210,6 @@
<svelte:fragment slot="footer">
<Button text on:click={() => (show = false)}>Cancel</Button>
<Button secondary submit>Create DNS record</Button>
<Button submit>Create</Button>
</svelte:fragment>
</Modal>
@@ -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 = '';
@@ -1,10 +1,12 @@
<script lang="ts">
import { Layout } from '@appwrite.io/pink-svelte';
import { UsageCard } from '$lib/components';
import type { Models } from '@appwrite.io/console';
import { Trim, UsageCard } from '$lib/components';
import { toLocaleDate } from '$lib/helpers/date';
import type { Domain } from '$lib/sdk/domains';
import { Link } from '$lib/elements';
import { protocol } from '$routes/(console)/store';
export let domain: Models.Domain;
export let domain: Domain;
let metrics = [
{
value: domain.domain,
@@ -23,7 +25,7 @@
description: 'Exipiry date'
},
{
value: domain?.autoRenewal ? 'On' : 'off',
value: domain?.autoRenewal ? 'On' : 'Off',
description: 'Auto renewal'
},
{
@@ -33,8 +35,25 @@
];
</script>
<Layout.Stack direction="row">
{#each metrics as metric}
<UsageCard description={metric.description} bind:value={metric.value} />
{/each}
</Layout.Stack>
<Layout.Grid gap="m" columnsL={2} columns={1}>
<Layout.Stack direction="row" gap="m">
{#each metrics.slice(0, 3) as metric}
{#if metric.description === 'Domain'}
<UsageCard description={metric.description}>
<Link external href={`${$protocol}/${metric.value}`} variant="quiet">
<Trim alternativeTrim>
{metric.value}
</Trim>
</Link>
</UsageCard>
{:else}
<UsageCard description={metric.description} bind:value={metric.value} />
{/if}
{/each}
</Layout.Stack>
<Layout.Stack direction="row" gap="m">
{#each metrics.slice(3) as metric}
<UsageCard description={metric.description} bind:value={metric.value} />
{/each}
</Layout.Stack>
</Layout.Grid>
@@ -1,158 +0,0 @@
<script lang="ts">
import {
Button,
InputNumber,
InputSelect,
InputText,
InputTextarea
} from '$lib/elements/forms';
import { Modal } from '$lib/components';
import { Icon, Layout, Tooltip } 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 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';
export let show = false;
export let selectedRecord: Models.DnsRecord;
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 record = deepClone(selectedRecord);
let error = '';
async function handleSubmit() {
try {
//TODO: update DNS record
show = false;
addNotification({
type: 'success',
message: `Record has been updated`
});
trackEvent(Submit.RecordUpdate);
} catch (e) {
error = e.message;
trackError(e, Submit.RecordUpdate);
}
}
$: if (!show) {
selectedRecord = null;
}
$: isDisabled = !symmetricDifference(Object.values(record), Object.values(selectedRecord))
?.length;
</script>
<Modal title="Update DNS record" bind:show bind:error onSubmit={handleSubmit}>
<span slot="description">
DNS records map domain names to IP addresses or other resources.
</span>
<Layout.Stack gap="l">
<InputText id="name" label="Name" placeholder="subdomain" bind:value={record.name} />
<Layout.Stack gap="xs">
<InputSelect {options} bind:value={record.type} id="type" label="Type" />
<Layout.Stack direction="row" gap="xs">
<Icon icon={IconInfo} />
</Layout.Stack>
</Layout.Stack>
<InputText id="value" label="Value" placeholder="76.75.21.21" bind:value={record.value}>
<Tooltip slot="info">
<Icon icon={IconInfo} />
<span slot="tooltip">
{options.find((option) => option.value === record.type)?.helper}
</span>
</Tooltip>
</InputText>
<Layout.Stack direction="row" gap="l">
<InputNumber id="ttl" label="TTL" placeholder="Enter number" bind:value={record.ttl}>
<Tooltip slot="info">
<Icon icon={IconInfo} />
<span slot="tooltip">
TTL defines how long DNS information is cached. Lower values update faster;
higher values reduce server load.
</span>
</Tooltip>
</InputNumber>
<InputNumber
id="priority"
label="Priority"
placeholder="Enter number"
bind:value={record.priority}>
<Tooltip slot="info">
<Icon icon={IconInfo} />
<span slot="tooltip">
Sets the priority for this DNS record. Lower numbers indicate higher
priority (e.g., 10 is higher than 20).
</span>
</Tooltip>
</InputNumber>
</Layout.Stack>
<InputTextarea
id="comment"
label="Comment"
placeholder="Provide an explanation of this DNS record's purpose"
bind:value={record.comment} />
</Layout.Stack>
<svelte:fragment slot="footer">
<Button text on:click={() => (show = false)}>Cancel</Button>
<Button secondary submit disabled={isDisabled}>Update DNS record</Button>
</svelte:fragment>
</Modal>
@@ -0,0 +1,59 @@
<script lang="ts">
import { Button } from '$lib/elements/forms';
import { Modal } from '$lib/components';
import { addNotification } from '$lib/stores/notifications';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { Icon, Layout, Tooltip, Typography, Upload } from '@appwrite.io/pink-svelte';
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
export let show = false;
let files: FileList;
let error = '';
async function handleSubmit() {
try {
//TODO: create DNS records
show = false;
addNotification({
type: 'success',
message: `Presets have been added`
});
trackEvent(Submit.RecordCreate);
} catch (e) {
error = e.message;
trackError(e, Submit.RecordCreate);
}
}
</script>
<Modal title="Import zone file" bind:show bind:error onSubmit={handleSubmit}>
<span slot="description">
Import DNS zone file to apply its records to your domain. <b
>If conflicts arise, the upload will be blocked</b
>.
</span>
<Upload.Dropzone bind:files>
<Layout.Stack alignItems="center" gap="s">
<Layout.Stack alignItems="center" gap="s">
<Layout.Stack alignItems="center" justifyContent="center" direction="row" gap="s">
<Typography.Text variant="l-500">
Drag and drop file here or click to upload
</Typography.Text>
<Tooltip>
<Layout.Stack alignItems="center" justifyContent="center" inline>
<Icon icon={IconInfo} size="s" />
</Layout.Stack>
<svelte:fragment slot="tooltip">Only .txt files allowed</svelte:fragment>
</Tooltip>
</Layout.Stack>
<Typography.Caption variant="400">Max file size 10MB</Typography.Caption>
</Layout.Stack>
</Layout.Stack>
</Upload.Dropzone>
<svelte:fragment slot="footer">
<Button text on:click={() => (show = false)}>Cancel</Button>
<Button size="s" submit disabled={!files?.length}>Import</Button>
</svelte:fragment>
</Modal>
@@ -1,6 +1,5 @@
<script lang="ts">
import { Container } from '$lib/layout';
import { Typography } from '@appwrite.io/pink-svelte';
import ChangeOrganization from './changeOrganization.svelte';
import DeleteDomain from './deleteDomain.svelte';
@@ -8,7 +7,6 @@
</script>
<Container>
<Typography.Title>Settings</Typography.Title>
<ChangeOrganization domain={data.domain} organizations={data.organizations} />
<DeleteDomain domain={data.domain} />
</Container>
@@ -1,19 +1,34 @@
<script lang="ts">
import { goto, invalidate } from '$app/navigation';
import { page } from '$app/stores';
import { CardGrid } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button, InputSelect } from '$lib/elements/forms';
import type { Domain } from '$lib/sdk/domains';
import { addNotification } from '$lib/stores/notifications';
import type { OrganizationList } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@appwrite.io/console';
export let domain: Models.Domain;
export let domain: Domain;
export let organizations: OrganizationList;
let selectedOrg: string = null;
async function moveDomain() {
try {
await sdk.forConsole.domains.updateTeam(domain.$id, selectedOrg);
} catch (error) {}
addNotification({
type: 'success',
message: 'Domain moved successfully'
});
await goto(`/console/organization-${selectedOrg}/domains/`);
await invalidate(Dependencies.ORGANIZATION);
await invalidate(Dependencies.DOMAINS);
} catch (e) {
addNotification({
type: 'error',
message: e.message
});
}
}
$: options = organizations.total
@@ -1,9 +1,9 @@
import { page } from '$app/stores';
import type { Column } from '$lib/helpers/types';
import type { Models } from '@appwrite.io/console';
import type { Domain } from '$lib/sdk/domains';
import { derived, writable } from 'svelte/store';
export const domain = derived(page, ($page) => $page.data.domain as Models.Domain);
export const domain = derived(page, ($page) => $page.data.domain as Domain);
export const columns = writable<Column[]>([
{ id: 'name', title: 'Name', type: 'string', show: true },
{ id: 'type', title: 'Type', type: 'string', show: true },
@@ -13,3 +13,56 @@ export const columns = writable<Column[]>([
{ id: 'comment', title: 'Comment', type: 'string', show: false },
{ id: '$createdAt', title: 'Created', type: 'datetime', show: true }
]);
export const recordTypes = [
{
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.'
}
];
@@ -15,7 +15,7 @@
import { timeFromNow } from '$lib/helpers/date';
import DeleteRecordModal from './deleteRecordModal.svelte';
import { capitalize } from '$lib/helpers/string';
import EditRecordModal from './editRecordModal.svelte';
import EditRecordModal from './updateRecordModal.svelte';
import type { DnsRecord } from '$lib/sdk/domains';
export let data;
@@ -56,7 +56,7 @@
</Table.Cell>
{:else if column.id === 'value'}
<Table.Cell>
<InteractiveText variant="secret" text={record.value} isVisible />
<InteractiveText variant="copy" text={record.value} isVisible />
</Table.Cell>
{:else if column.id === 'ttl'}
<Table.Cell>
@@ -109,7 +109,7 @@
showEdit = true;
toggle(e);
}}>
Edit
Update
</ActionMenu.Item.Button>
<ActionMenu.Item.Button
status="danger"
@@ -0,0 +1,223 @@
<script lang="ts">
import {
Button,
InputNumber,
InputSelect,
InputText,
InputTextarea
} from '$lib/elements/forms';
import { Modal } from '$lib/components';
import { Icon, Input, Layout, Tooltip } 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 { symmetricDifference } from '$lib/helpers/array';
import { deepClone } from '$lib/helpers/object';
import type { DnsRecord } from '$lib/sdk/domains';
import { sdk } from '$lib/stores/sdk';
import { page } from '$app/stores';
import { recordTypes } from './store';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
// type RecordType = 'A' | 'AAAA' | 'CNAME' | 'MX' | 'TXT' | 'NS' | 'SRV' | 'CAA' | 'PTR';
export let show = false;
export let selectedRecord: DnsRecord;
let record = deepClone(selectedRecord);
let error = '';
async function handleSubmit() {
try {
//TODO: update DNS record
switch (record.type) {
case 'A':
await sdk.forConsole.domains.updateRecordA(
$page.params.domain,
record.$id,
record.name,
record.value,
record.ttl,
record.comment
);
break;
case 'AAAA':
await sdk.forConsole.domains.updateRecordAAAA(
$page.params.domain,
record.$id,
record.name,
record.value,
record.ttl,
record.comment
);
break;
case 'CNAME':
await sdk.forConsole.domains.updateRecordCNAME(
$page.params.domain,
record.$id,
record.name,
record.value,
record.ttl,
record.comment
);
break;
case 'MX':
await sdk.forConsole.domains.updateRecordMX(
$page.params.domain,
record.$id,
record.name,
record.value,
record.ttl,
record.priority,
record.comment
);
break;
case 'TXT':
await sdk.forConsole.domains.updateRecordTXT(
$page.params.domain,
record.$id,
record.name,
record.value,
record.ttl,
record.comment
);
break;
case 'NS':
await sdk.forConsole.domains.updateRecordNS(
$page.params.domain,
record.$id,
record.name,
record.value,
record.ttl,
record.comment
);
break;
case 'CAA':
await sdk.forConsole.domains.updateRecordCAA(
$page.params.domain,
record.$id,
record.name,
record.value,
record.ttl,
record.comment
);
break;
case 'HTTPS':
await sdk.forConsole.domains.updateRecordHTTPS(
$page.params.domain,
record.$id,
record.name,
record.value,
record.ttl,
record.comment
);
break;
case 'ALIAS':
await sdk.forConsole.domains.updateRecordAlias(
$page.params.domain,
record.$id,
record.name,
record.value,
record.ttl,
record.comment
);
break;
default:
break;
}
show = false;
invalidate(Dependencies.DOMAINS);
addNotification({
type: 'success',
message: `Record has been updated`
});
trackEvent(Submit.RecordUpdate);
} catch (e) {
error = e.message;
trackError(e, Submit.RecordUpdate);
}
}
$: if (!show) {
selectedRecord = null;
}
$: isDisabled = !symmetricDifference(Object.values(record), Object.values(selectedRecord))
?.length;
</script>
<Modal title="Update DNS record" bind:show bind:error onSubmit={handleSubmit}>
<span slot="description">
DNS records map domain names to IP addresses or other resources.
</span>
<Layout.Stack gap="l">
<InputText
id="name"
required
label="Name"
placeholder="subdomain"
bind:value={record.name} />
<Layout.Stack gap="xs">
<InputSelect options={recordTypes} bind:value={record.type} id="type" label="Type" />
<Input.Helper state="default">
{recordTypes.find((option) => option.value === record.type)?.helper}
</Input.Helper>
</Layout.Stack>
<InputText id="value" label="Value" placeholder="76.75.21.21" bind:value={record.value}>
<Tooltip slot="info">
<Icon icon={IconInfo} size="s" />
<span slot="tooltip">
{recordTypes.find((option) => option.value === record.type)?.helper}
</span>
</Tooltip>
</InputText>
<Layout.Stack direction="row" gap="l">
<InputNumber id="ttl" label="TTL" placeholder="Enter number" bind:value={record.ttl}>
<Tooltip slot="info">
<Icon icon={IconInfo} size="s" />
<span slot="tooltip">
TTL defines how long DNS information is cached. Lower values update faster;
higher values reduce server load.
</span>
</Tooltip>
</InputNumber>
<InputNumber
id="priority"
label="Priority"
placeholder="Enter number"
bind:value={record.priority}>
<Tooltip slot="info">
<Icon icon={IconInfo} size="s" />
<span slot="tooltip">
Sets the priority for this DNS record. Lower numbers indicate higher
priority (e.g., 10 is higher than 20).
</span>
</Tooltip>
</InputNumber>
</Layout.Stack>
<InputTextarea
id="comment"
label="Comment"
placeholder="Provide an explanation of this DNS record's purpose"
bind:value={record.comment} />
</Layout.Stack>
<svelte:fragment slot="footer">
<Button text on:click={() => (show = false)}>Cancel</Button>
<Button submit disabled={isDisabled}>Update</Button>
</svelte:fragment>
</Modal>
@@ -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" />
<CardGrid>
<svelte:fragment slot="title">Transfer project</svelte:fragment>
Transfer your project to another organization that you own.
<svelte:fragment slot="aside">
<InputSelect
required
id="organization"
placeholder="Select an organization"
label="Available organizations"
bind:value={teamId}
options={$organizationList.teams
.filter((team) => team.$id !== $project.teamId)
.map((team) => ({
value: team.$id,
label: team.name
}))} />
</svelte:fragment>
<svelte:fragment slot="actions">
<Button
secondary
disabled={teamId === $project.teamId}
on:click={() => (showTransfer = true)}>Transfer</Button>
</svelte:fragment>
</CardGrid>
<ChangeOrganization />
<DeleteProject />
{/if}
{/if}
</Container>
{#if teamId}
<Transfer
bind:teamId
teamName={$organizationList.teams.find((t) => t.$id == teamId).name}
bind:show={showTransfer} />
{/if}
@@ -0,0 +1,43 @@
<script lang="ts">
import { CardGrid } from '$lib/components';
import { Button, InputSelect } from '$lib/elements/forms';
import { organizationList } from '$lib/stores/organization';
import { project } from '../store';
import TransferProjectModal from './transferProjectModal.svelte';
let teamId: string;
let showTransfer = false;
</script>
<CardGrid>
<svelte:fragment slot="title">Change organization</svelte:fragment>
Select an organization you own to move this project.
<svelte:fragment slot="aside">
<InputSelect
required
id="organization"
placeholder="Select destination"
label="Move to"
bind:value={teamId}
options={$organizationList.teams
.filter((team) => team.$id !== $project.teamId)
.map((team) => ({
value: team.$id,
label: team.name
}))} />
</svelte:fragment>
<svelte:fragment slot="actions">
<Button
secondary
disabled={teamId === $project.teamId}
on:click={() => (showTransfer = true)}>Move</Button>
</svelte:fragment>
</CardGrid>
{#if teamId}
<TransferProjectModal
bind:teamId
teamName={$organizationList.teams.find((t) => t.$id == teamId).name}
bind:show={showTransfer} />
{/if}
@@ -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 @@
};
</script>
<Modal title="Transfer project" bind:show onSubmit={handleTransfer}>
<Confirm title="Change organization" bind:open={show} onSubmit={handleTransfer}>
<Typography.Text
>Are you sure you want to transfer <b>{$project.name}</b> to
>Are you sure you want to move <b>{$project.name}</b> to
<b>{teamName}</b>?</Typography.Text>
<Typography.Text>
Members who are not part of the destination organization must be invited to gain access to
@@ -44,6 +44,6 @@
<svelte:fragment slot="footer">
<Button text on:click={() => (show = false)}>Cancel</Button>
<Button secondary submit>Transfer</Button>
<Button secondary submit>Move</Button>
</svelte:fragment>
</Modal>
</Confirm>