mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: domain creation flow
This commit is contained in:
1 parent
a1bd0199c5
commit
0d08e180e9
2 files changed
+29
-20
No files matched your search
+22
-19
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { Button, Form, InputDomain, InputSelect } from '$lib/elements/forms';
|
||||
import { Button, Form, InputDomain, InputSelect, InputURL } from '$lib/elements/forms';
|
||||
import { Wizard } from '$lib/layout';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
@@ -9,10 +9,10 @@
|
||||
import { goto, invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { sortBranches } from '$lib/stores/vcs';
|
||||
import { consoleVariables, protocol } from '$routes/(console)/store';
|
||||
import { protocol } from '$routes/(console)/store';
|
||||
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
|
||||
import { LabelCard } from '$lib/components';
|
||||
import { StatusCode } from '@appwrite.io/console';
|
||||
import { StatusCode, type Models } from '@appwrite.io/console';
|
||||
import { statusCodeOptions } from '$lib/stores/domains';
|
||||
import ConnectRepoModal from '../../../(components)/connectRepoModal.svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
@@ -33,13 +33,6 @@
|
||||
let statusCode = 307;
|
||||
let branch = null;
|
||||
|
||||
const redirectOptions = data.rules.rules
|
||||
.filter((d) => !d.domain.endsWith($consoleVariables._APP_DOMAIN_SITES))
|
||||
.map((domain) => ({
|
||||
label: domain.domain,
|
||||
value: domain.domain
|
||||
}));
|
||||
|
||||
onMount(() => {
|
||||
if (
|
||||
$page.url.searchParams.has('connectRepo') &&
|
||||
@@ -47,20 +40,31 @@
|
||||
) {
|
||||
showConnectRepo = true;
|
||||
}
|
||||
if ($page.url.searchParams.has('domain')) {
|
||||
domainName = $page.url.searchParams.get('domain');
|
||||
}
|
||||
});
|
||||
|
||||
async function addDomain() {
|
||||
try {
|
||||
let rule: Models.ProxyRule;
|
||||
if (behaviour === 'BRANCH') {
|
||||
await sdk.forProject.proxy.createSiteRule(domainName, $page.params.site, branch);
|
||||
rule = await sdk.forProject.proxy.createSiteRule(
|
||||
domainName,
|
||||
$page.params.site,
|
||||
branch
|
||||
);
|
||||
} else if (behaviour === 'REDIRECT') {
|
||||
const sc = Object.values(StatusCode).find((code) => parseInt(code) === statusCode);
|
||||
await sdk.forProject.proxy.createRedirectRule(domainName, $protocol + redirect, sc);
|
||||
rule = await sdk.forProject.proxy.createRedirectRule(
|
||||
domainName,
|
||||
$protocol + redirect,
|
||||
sc
|
||||
);
|
||||
} else if (behaviour === 'ACTIVE') {
|
||||
await sdk.forProject.proxy.createSiteRule(domainName, $page.params.site);
|
||||
rule = await sdk.forProject.proxy.createSiteRule(domainName, $page.params.site);
|
||||
}
|
||||
|
||||
await goto(`${routeBase}/add-domain/verify-${domainName}`);
|
||||
await goto(`${routeBase}/add-domain/verify-${domainName}?rule=${rule.$id}`);
|
||||
await invalidate(Dependencies.SITES_DOMAINS);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
@@ -158,11 +162,10 @@
|
||||
{:else if behaviour === 'REDIRECT'}
|
||||
<Fieldset legend="Settings">
|
||||
<Layout.Stack gap="xl">
|
||||
<InputSelect
|
||||
<InputURL
|
||||
label="Redirect to"
|
||||
id="redirect"
|
||||
placeholder="Select domain"
|
||||
options={redirectOptions}
|
||||
placeholder="https://appwrite.io/docs"
|
||||
bind:value={redirect}
|
||||
required>
|
||||
<Tooltip slot="info">
|
||||
@@ -172,7 +175,7 @@
|
||||
listed here.
|
||||
</span>
|
||||
</Tooltip>
|
||||
</InputSelect>
|
||||
</InputURL>
|
||||
<InputSelect
|
||||
options={statusCodeOptions}
|
||||
label="Status code"
|
||||
|
||||
+7
-1
@@ -51,7 +51,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function back() {}
|
||||
async function back() {
|
||||
if ($page.url.searchParams.has('rule')) {
|
||||
const rule = $page.url.searchParams.get('rule');
|
||||
await sdk.forProject.proxy.deleteRule(rule);
|
||||
}
|
||||
await goto(`${routeBase}/add-domain?domain=${$page.params.domain}`);
|
||||
}
|
||||
|
||||
$: isVerified = domainData?.nameservers
|
||||
? domainData?.nameservers.toLocaleLowerCase() === 'appwrite'
|
||||
|
||||
Reference in new issue
Block a user