mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
feat: verbose rules, sites domain fixes
This commit is contained in:
1 parent
61b560765c
commit
98ebb04317
19 files changed
+2279
-413
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -24,6 +24,7 @@ import {
|
||||
} from '@appwrite.io/console';
|
||||
import { Billing } from '../sdk/billing';
|
||||
import { Backups } from '../sdk/backups';
|
||||
import { Domains } from '$lib/sdk/domains';
|
||||
import { Sources } from '$lib/sdk/sources';
|
||||
|
||||
export function getApiEndpoint(): string {
|
||||
@@ -83,7 +84,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();
|
||||
|
||||
+78
-100
@@ -15,12 +15,13 @@
|
||||
import Details from '../../details.svelte';
|
||||
import ProductionBranch from '../../productionBranch.svelte';
|
||||
import Aside from '../../aside.svelte';
|
||||
import { BuildRuntime, ConsoleResourceType, Framework, ID, Type } from '@appwrite.io/console';
|
||||
import { BuildRuntime, Framework, ID, Type } from '@appwrite.io/console';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { onMount } from 'svelte';
|
||||
import Configuration from '../../configuration.svelte';
|
||||
import Domain from '../../domain.svelte';
|
||||
// import Domain from '../../domain.svelte';
|
||||
import { consoleVariables } from '$routes/(console)/store';
|
||||
import { buildVerboseDomain } from '../../store';
|
||||
|
||||
export let data;
|
||||
let showExitModal = false;
|
||||
@@ -40,44 +41,16 @@
|
||||
let variables: Partial<Models.Variable>[] = [];
|
||||
let silentMode = false;
|
||||
let domain = id;
|
||||
let domainIsValid = true;
|
||||
// let domainIsValid = true;
|
||||
|
||||
onMount(async () => {
|
||||
installation.set(data.installation);
|
||||
repository.set(data.repository);
|
||||
name = data.repository.name;
|
||||
|
||||
// Format repository name by removing spaces and slashes
|
||||
const formattedRepoName = data.repository.name.replace(/[\s\/]/g, '-');
|
||||
const formattedOrgName = data.repository.organization.replace(/[\s\/]/g, '-');
|
||||
|
||||
domain = formattedRepoName;
|
||||
const isFirstDomainAvailable = !(await checkDomain(domain));
|
||||
|
||||
// If first option is not available, try repo-org
|
||||
if (!isFirstDomainAvailable) {
|
||||
domain = `${formattedRepoName}-${formattedOrgName}`;
|
||||
const isSecondDomainAvailable = !(await checkDomain(domain));
|
||||
|
||||
// If second option is not available, use repo-org-uniqueID
|
||||
if (!isSecondDomainAvailable) {
|
||||
domain = `${formattedRepoName}-${formattedOrgName}-${ID.unique()}`;
|
||||
}
|
||||
}
|
||||
// domain = await buildVerboseDomain(data.repository.name, data.repository.organization, id);
|
||||
});
|
||||
|
||||
async function checkDomain(domain: string) {
|
||||
try {
|
||||
await sdk.forConsole.console.getResource(
|
||||
`${domain}.${$consoleVariables._APP_DOMAIN_SITES}`,
|
||||
ConsoleResourceType.Rules
|
||||
);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadBranches() {
|
||||
const { branches } = await sdk.forProject.vcs.listRepositoryBranches(
|
||||
data.installation.$id,
|
||||
@@ -94,76 +67,81 @@
|
||||
}
|
||||
|
||||
async function create() {
|
||||
if (!domainIsValid) {
|
||||
// if (!domainIsValid) {
|
||||
// addNotification({
|
||||
// type: 'error',
|
||||
// message: 'Please enter a valid domain'
|
||||
// });
|
||||
// return;
|
||||
// } else {}
|
||||
|
||||
try {
|
||||
domain = await buildVerboseDomain(
|
||||
data.repository.name,
|
||||
data.repository.organization,
|
||||
id
|
||||
);
|
||||
const fr = Object.values(Framework).find((f) => f === framework.key);
|
||||
const buildRuntime = Object.values(BuildRuntime).find(
|
||||
(f) => f === framework.buildRuntime
|
||||
);
|
||||
let site = await sdk.forProject.sites.create(
|
||||
id || ID.unique(),
|
||||
name,
|
||||
fr,
|
||||
buildRuntime,
|
||||
undefined,
|
||||
undefined,
|
||||
installCommand,
|
||||
buildCommand,
|
||||
outputDirectory,
|
||||
framework.adapters[Object.keys(framework.adapters)[0]].key, //TODO: fix this
|
||||
data.installation.$id,
|
||||
null,
|
||||
data.repository.id,
|
||||
branch,
|
||||
silentMode,
|
||||
rootDir
|
||||
);
|
||||
|
||||
// Add domain
|
||||
await sdk.forProject.proxy.createSiteRule(
|
||||
`${domain}.${$consoleVariables._APP_DOMAIN_SITES}`,
|
||||
site.$id
|
||||
);
|
||||
|
||||
//Add variables
|
||||
const promises = variables.map((variable) =>
|
||||
sdk.forProject.sites.createVariable(
|
||||
site.$id,
|
||||
variable.key,
|
||||
variable.value,
|
||||
variable?.secret ?? false
|
||||
)
|
||||
);
|
||||
await Promise.all(promises);
|
||||
|
||||
const deployment = await sdk.forProject.sites.createVcsDeployment(
|
||||
site.$id,
|
||||
Type.Branch,
|
||||
branch,
|
||||
true
|
||||
);
|
||||
|
||||
trackEvent(Submit.SiteCreate, {
|
||||
source: 'repository',
|
||||
framework: framework.key
|
||||
});
|
||||
|
||||
await goto(
|
||||
`${base}/project-${$page.params.project}/sites/create-site/deploying?site=${site.$id}&deployment=${deployment.$id}`
|
||||
);
|
||||
} catch (e) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: 'Please enter a valid domain'
|
||||
message: e.message
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
const fr = Object.values(Framework).find((f) => f === framework.key);
|
||||
const buildRuntime = Object.values(BuildRuntime).find(
|
||||
(f) => f === framework.buildRuntime
|
||||
);
|
||||
let site = await sdk.forProject.sites.create(
|
||||
id || ID.unique(),
|
||||
name,
|
||||
fr,
|
||||
buildRuntime,
|
||||
undefined,
|
||||
undefined,
|
||||
installCommand,
|
||||
buildCommand,
|
||||
outputDirectory,
|
||||
framework.adapters[Object.keys(framework.adapters)[0]].key, //TODO: fix this
|
||||
data.installation.$id,
|
||||
null,
|
||||
data.repository.id,
|
||||
branch,
|
||||
silentMode,
|
||||
rootDir
|
||||
);
|
||||
|
||||
// Add domain
|
||||
await sdk.forProject.proxy.createSiteRule(
|
||||
`${domain}.${$consoleVariables._APP_DOMAIN_SITES}`,
|
||||
site.$id
|
||||
);
|
||||
|
||||
//Add variables
|
||||
const promises = variables.map((variable) =>
|
||||
sdk.forProject.sites.createVariable(
|
||||
site.$id,
|
||||
variable.key,
|
||||
variable.value,
|
||||
variable?.secret ?? false
|
||||
)
|
||||
);
|
||||
await Promise.all(promises);
|
||||
|
||||
const deployment = await sdk.forProject.sites.createVcsDeployment(
|
||||
site.$id,
|
||||
Type.Branch,
|
||||
branch,
|
||||
true
|
||||
);
|
||||
|
||||
trackEvent(Submit.SiteCreate, {
|
||||
source: 'repository',
|
||||
framework: framework.key
|
||||
});
|
||||
|
||||
await goto(
|
||||
`${base}/project-${$page.params.project}/sites/create-site/deploying?site=${site.$id}&deployment=${deployment.$id}`
|
||||
);
|
||||
} catch (e) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: e.message
|
||||
});
|
||||
trackError(e, Submit.SiteCreate);
|
||||
}
|
||||
trackError(e, Submit.SiteCreate);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -227,7 +205,7 @@
|
||||
bind:variables
|
||||
frameworks={data.frameworks.frameworks} />
|
||||
|
||||
<Domain bind:domain bind:domainIsValid />
|
||||
<!-- <Domain bind:domain bind:domainIsValid /> -->
|
||||
</Layout.Stack>
|
||||
</Form>
|
||||
<svelte:fragment slot="aside">
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { consoleVariables } from '$routes/(console)/store';
|
||||
import { ConsoleResourceType, ID } from '@appwrite.io/console';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
function toURLSafe(s: string) {
|
||||
return s.replace(/[^a-zA-Z0-9-]/g, '-');
|
||||
}
|
||||
|
||||
export async function checkDomain(domain: string) {
|
||||
try {
|
||||
await sdk.forConsole.console.getResource(
|
||||
`${domain}.${get(consoleVariables)._APP_DOMAIN_SITES}`,
|
||||
ConsoleResourceType.Rules
|
||||
);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export async function buildVerboseDomain(name: string, specifier: string, unique?: string) {
|
||||
const safeName = toURLSafe(name).toLowerCase();
|
||||
const safeSpecifier = toURLSafe(specifier).toLowerCase();
|
||||
const safeUnique = unique ? toURLSafe(unique).toLowerCase() : ID.unique();
|
||||
let domain = `${safeName}`;
|
||||
if (await checkDomain(domain)) {
|
||||
return domain;
|
||||
}
|
||||
domain = `${safeName}-${safeSpecifier}`;
|
||||
if (await checkDomain(domain)) {
|
||||
return domain;
|
||||
}
|
||||
domain = `${safeName}-${safeSpecifier}-${safeUnique}`;
|
||||
if (await checkDomain(domain)) {
|
||||
return domain;
|
||||
}
|
||||
}
|
||||
+18
-12
@@ -27,11 +27,13 @@
|
||||
import Configuration from './configuration.svelte';
|
||||
import Aside from '../../aside.svelte';
|
||||
import { Adapter, BuildRuntime, Framework, ID } from '@appwrite.io/console';
|
||||
import Domain from '../../domain.svelte';
|
||||
// import Domain from '../../domain.svelte';
|
||||
import { NewRepository, Repositories, RepositoryBehaviour } from '$lib/components/git';
|
||||
import { getFrameworkIcon } from '../../../store';
|
||||
import { app, iconPath } from '$lib/stores/app';
|
||||
import { consoleVariables } from '$routes/(console)/store';
|
||||
import { project } from '$routes/(console)/project-[project]/store';
|
||||
import { buildVerboseDomain } from '../../store';
|
||||
|
||||
export let data;
|
||||
|
||||
@@ -45,7 +47,7 @@
|
||||
let name = data.template.name;
|
||||
let id = ID.unique();
|
||||
let domain = id;
|
||||
let domainIsValid = true;
|
||||
// let domainIsValid = true;
|
||||
let framework = data?.template?.frameworks[0];
|
||||
let branch = 'main';
|
||||
let rootDir = './';
|
||||
@@ -59,7 +61,7 @@
|
||||
let variables = [];
|
||||
let silentMode = false;
|
||||
|
||||
onMount(() => {
|
||||
onMount(async () => {
|
||||
if (!$installation?.$id) {
|
||||
$installation = data.installations.installations[0];
|
||||
}
|
||||
@@ -111,14 +113,18 @@
|
||||
message: 'Please select a repository'
|
||||
});
|
||||
return;
|
||||
} else if (!domainIsValid) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: 'Please enter a valid domain'
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
// else if (!domainIsValid) {
|
||||
// addNotification({
|
||||
// type: 'error',
|
||||
// message: 'Please enter a valid domain'
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
else {
|
||||
try {
|
||||
domain = await buildVerboseDomain(data.template.name, $project.name, id);
|
||||
|
||||
const fr = Object.values(Framework).find((f) => f === framework.key);
|
||||
const buildRuntime = Object.values(BuildRuntime).find(
|
||||
(f) => f === framework.buildRuntime
|
||||
@@ -242,7 +248,7 @@
|
||||
{#if data.template.variables?.length}
|
||||
<Configuration bind:variables templateVariables={data.template.variables} />
|
||||
{/if}
|
||||
<Domain bind:domain bind:domainIsValid />
|
||||
<!-- <Domain bind:domain bind:domainIsValid /> -->
|
||||
</Layout.Stack>
|
||||
{:else}
|
||||
{@const options = data.template.frameworks.map((framework) => {
|
||||
@@ -324,7 +330,7 @@
|
||||
{#if data.template.variables?.length}
|
||||
<Configuration bind:variables templateVariables={data.template.variables} />
|
||||
{/if}
|
||||
<Domain bind:domain bind:domainIsValid />
|
||||
<!-- <Domain bind:domain bind:domainIsValid /> -->
|
||||
{/if}
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
import { EmptySearch, PaginationWithLimit } from '$lib/components/index.js';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import Link from '$lib/elements/link.svelte';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import Container from '$lib/layout/container.svelte';
|
||||
import { protocol } from '$routes/(console)/store.js';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
@@ -17,7 +16,6 @@
|
||||
} from '@appwrite.io/pink-icons-svelte';
|
||||
import {
|
||||
ActionMenu,
|
||||
Badge,
|
||||
Card,
|
||||
Empty,
|
||||
Icon,
|
||||
@@ -30,6 +28,7 @@
|
||||
import { queries } from '$lib/components/filters';
|
||||
import SearchQuery from '$lib/components/searchQuery.svelte';
|
||||
import { app } from '$lib/stores/app';
|
||||
import { RuleType } from '$lib/stores/sdk';
|
||||
|
||||
export let data;
|
||||
|
||||
@@ -38,12 +37,6 @@
|
||||
let selectedDomain: Models.ProxyRule = null;
|
||||
|
||||
$: console.log(data.domains);
|
||||
|
||||
// TODO: replace status once backend is fixed
|
||||
// created - Verification Failed
|
||||
// verified - Verification OK , Certificate OK
|
||||
// verifying - Verifiacitok OK
|
||||
// unverified - Verificaiton OK , Certificate Failed
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
@@ -60,38 +53,32 @@
|
||||
<Table.Root>
|
||||
<svelte:fragment slot="header">
|
||||
<Table.Header.Cell>Domain</Table.Header.Cell>
|
||||
<Table.Header.Cell>Updated</Table.Header.Cell>
|
||||
<Table.Header.Cell>Redirect to</Table.Header.Cell>
|
||||
<Table.Header.Cell>Production branch</Table.Header.Cell>
|
||||
<Table.Header.Cell />
|
||||
</svelte:fragment>
|
||||
{#each data.domains.rules as domain}
|
||||
<Table.Link
|
||||
href={`${base}/project-${$page.params.project}/sites/site-${$page.params.site}/domains/domain-${domain.$id}`}>
|
||||
<Table.Row>
|
||||
<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>
|
||||
{#if domain.status === 'created'}
|
||||
<Badge
|
||||
variant="secondary"
|
||||
content="Verification failed"
|
||||
type="error" />
|
||||
{:else if domain.status === 'veryfing'}
|
||||
<Badge
|
||||
variant="secondary"
|
||||
content="Pending verification"
|
||||
type="warning" />
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
<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>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{domain.type === RuleType.REDIRECT ? (domain?.value ?? '-') : 'No redirect'}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{domain.automation.includes('branch')
|
||||
? domain.automation.split('branch=')[1]
|
||||
: '-'}
|
||||
</Table.Cell>
|
||||
<Table.Cell>{toLocaleDateTime(domain.$updatedAt)}</Table.Cell>
|
||||
<Table.Cell>
|
||||
<Layout.Stack direction="row" justifyContent="flex-end">
|
||||
<Popover let:toggle placement="bottom-start" padding="none">
|
||||
@@ -135,7 +122,7 @@
|
||||
</Popover>
|
||||
</Layout.Stack>
|
||||
</Table.Cell>
|
||||
</Table.Link>
|
||||
</Table.Row>
|
||||
{/each}
|
||||
</Table.Root>
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export const load = async ({ params, depends, url, route }) => {
|
||||
search,
|
||||
domains: await sdk.forProject.proxy.listRules(
|
||||
[
|
||||
Query.equal('type', RuleType.DEPLOYMENT),
|
||||
Query.equal('type', [RuleType.DEPLOYMENT, RuleType.REDIRECT]),
|
||||
Query.equal('automation', `site=${params.site}`),
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
|
||||
+119
-13
@@ -2,8 +2,7 @@
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import Card from '$lib/components/card.svelte';
|
||||
import { Button, Form } from '$lib/elements/forms';
|
||||
import { InputDomain } from '$lib/elements/forms/index.js';
|
||||
import { Button, Form, InputSelect } from '$lib/elements/forms';
|
||||
import { Wizard } from '$lib/layout';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
@@ -14,27 +13,90 @@
|
||||
Fieldset,
|
||||
Layout,
|
||||
Typography,
|
||||
Spinner
|
||||
Spinner,
|
||||
Input
|
||||
} from '@appwrite.io/pink-svelte';
|
||||
import RecordsCard from '../recordsCard.svelte';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { sortBranches } from '$lib/stores/vcs';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { consoleVariables } from '$routes/(console)/store';
|
||||
import InputDomain from '$lib/elements/forms/inputDomain.svelte';
|
||||
|
||||
const backPage = `${base}/project-${$page.params.project}/sites/site-${$page.params.site}/domains`;
|
||||
|
||||
export let data;
|
||||
let domain = '';
|
||||
let domainData: Models.ProxyRule;
|
||||
|
||||
let redirect = null;
|
||||
let statusCode = null;
|
||||
|
||||
let branch = null;
|
||||
|
||||
const domainsOptions = data.domains.rules.map((domain) => ({
|
||||
label: domain.domain,
|
||||
value: domain.domain
|
||||
}));
|
||||
|
||||
const statusCodeOptions = [
|
||||
{
|
||||
label: '301 Moved permanently',
|
||||
value: 301
|
||||
},
|
||||
{
|
||||
label: '302 Found',
|
||||
value: 302
|
||||
},
|
||||
{
|
||||
label: '303 See other',
|
||||
value: 303
|
||||
},
|
||||
{
|
||||
label: '307 Temporary redirect',
|
||||
value: 307
|
||||
},
|
||||
{
|
||||
label: '308 Permanent redirect',
|
||||
value: 308
|
||||
}
|
||||
];
|
||||
|
||||
async function addDomain() {
|
||||
try {
|
||||
domainData = await sdk.forProject.proxy.createSiteRule(domain, $page.params.site);
|
||||
console.log(domainData);
|
||||
invalidate(Dependencies.SITES_DOMAINS);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
const isNewDomain = data.domains.rules.findIndex((rule) => rule.domain === domain) === -1;
|
||||
const isSubDomain = domain.endsWith(`.${$consoleVariables._APP_DOMAIN_SITES}`);
|
||||
if (redirect) {
|
||||
try {
|
||||
if (isNewDomain && !isSubDomain) {
|
||||
await sdk.forConsole.domains.create($organization.$id, domain);
|
||||
}
|
||||
domainData = await sdk.forProject.proxy.createRedirectRule(domain, redirect);
|
||||
invalidate(Dependencies.SITES_DOMAINS);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
if (isNewDomain && !isSubDomain) {
|
||||
await sdk.forConsole.domains.create($organization.$id, domain);
|
||||
}
|
||||
domainData = await sdk.forProject.proxy.createSiteRule(
|
||||
domain,
|
||||
$page.params.site,
|
||||
branch
|
||||
);
|
||||
console.log(domainData);
|
||||
invalidate(Dependencies.SITES_DOMAINS);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +123,8 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$: console.log($consoleVariables);
|
||||
</script>
|
||||
|
||||
<Wizard title="Add domain" href={backPage} column columnSize="s">
|
||||
@@ -98,13 +162,55 @@
|
||||
<Fieldset legend="Configuration">
|
||||
<Form onSubmit={addDomain}>
|
||||
<Layout.Stack gap="xl">
|
||||
<InputDomain
|
||||
<!-- <Input.ComboBox
|
||||
label="Domain"
|
||||
id="domain"
|
||||
name="domain"
|
||||
bind:value={domain}
|
||||
options={domainsOptions}
|
||||
required
|
||||
placeholder="appwrite.example.com" /> -->
|
||||
<InputDomain
|
||||
label="Domain"
|
||||
id="domain"
|
||||
bind:value={domain}
|
||||
required
|
||||
placeholder="appwrite.example.com" />
|
||||
<InputSelect
|
||||
label="Redirect to"
|
||||
id="redirect"
|
||||
options={[
|
||||
{
|
||||
label: 'No redirect',
|
||||
value: null
|
||||
},
|
||||
...domainsOptions
|
||||
]}
|
||||
bind:value={redirect}
|
||||
required />
|
||||
{#if redirect}
|
||||
<InputSelect
|
||||
options={statusCodeOptions}
|
||||
label="Status code"
|
||||
id="code"
|
||||
bind:value={statusCode}
|
||||
placeholder="Select status code" />
|
||||
{/if}
|
||||
|
||||
{#if data.branches.total}
|
||||
{@const sortedBranches = sortBranches(data.branches.branches)}
|
||||
{@const options = sortedBranches.map((branch) => ({
|
||||
label: branch.name,
|
||||
value: branch.name
|
||||
}))}
|
||||
<InputSelect
|
||||
disabled={!!redirect}
|
||||
{options}
|
||||
label="Production branch"
|
||||
id="branch"
|
||||
bind:value={branch}
|
||||
placeholder="Select branch" />
|
||||
{/if}
|
||||
|
||||
<Divider />
|
||||
<Layout.Stack alignItems="flex-end">
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { RuleType } from '$lib/stores/sdk';
|
||||
|
||||
export const load = async ({ parent }) => {
|
||||
const { site } = await parent();
|
||||
|
||||
return {
|
||||
domains: await sdk.forProject.proxy.listRules([Query.equal('type', RuleType.DEPLOYMENT)]),
|
||||
branches:
|
||||
site?.installationId && site?.providerRepositoryId
|
||||
? await sdk.forProject.vcs.listRepositoryBranches(
|
||||
site.installationId,
|
||||
site.providerRepositoryId
|
||||
)
|
||||
: undefined
|
||||
};
|
||||
};
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
import Breadcrumbs from './breadcrumbs.svelte';
|
||||
import Header from './header.svelte';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
|
||||
export const load = async ({ depends }) => {
|
||||
depends(Dependencies.SITE);
|
||||
return {
|
||||
header: Header,
|
||||
breadcrumbs: Breadcrumbs
|
||||
};
|
||||
};
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { Heading } from '$lib/components';
|
||||
import { Container } from '$lib/layout';
|
||||
import DeleteDomain from './deleteDomain.svelte';
|
||||
import DomainDetails from './domainDetails.svelte';
|
||||
|
||||
export let data;
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<Heading tag="h2" size="5">Settings</Heading>
|
||||
<DomainDetails domain={data.domain} />
|
||||
<DeleteDomain domain={data.domain} />
|
||||
</Container>
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
|
||||
export const load = async ({ params, depends }) => {
|
||||
depends(Dependencies.SITES_DOMAINS);
|
||||
|
||||
return {
|
||||
domain: await sdk.forProject.proxy.getRule(params.domain)
|
||||
};
|
||||
};
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid } from '$lib/components';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { Table } from '@appwrite.io/pink-svelte';
|
||||
|
||||
export let domain: Models.ProxyRule;
|
||||
</script>
|
||||
|
||||
<CardGrid>
|
||||
<svelte:fragment slot="title">SSL certificates</svelte:fragment>
|
||||
SSL certificates secure your site with HTTPS, protecting data and boosting trust. Appwrite renews
|
||||
your SSL certificates automatically.
|
||||
<svelte:fragment slot="aside">
|
||||
<Table.Root>
|
||||
<svelte:fragment slot="header">
|
||||
<Table.Header.Cell>Domain</Table.Header.Cell>
|
||||
<Table.Header.Cell>Expiration date</Table.Header.Cell>
|
||||
<Table.Header.Cell>Renewal</Table.Header.Cell>
|
||||
<Table.Header.Cell>Created</Table.Header.Cell>
|
||||
<Table.Header.Cell />
|
||||
</svelte:fragment>
|
||||
{#each domain.logs as log}
|
||||
<Table.Row>
|
||||
{JSON.stringify(domain)}
|
||||
</Table.Row>
|
||||
{/each}
|
||||
</Table.Root>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { Breadcrumbs } from '$lib/layout';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { project } from '../../../../store';
|
||||
|
||||
$: breadcrumbs = [
|
||||
{
|
||||
href: `${base}/organization-${$organization?.$id}`,
|
||||
title: $organization?.name
|
||||
},
|
||||
{
|
||||
href: `${base}/project-${$project?.$id}`,
|
||||
title: $project?.name
|
||||
},
|
||||
{
|
||||
href: `${base}/project-${$project?.$id}/sites`,
|
||||
title: 'Sites'
|
||||
},
|
||||
{
|
||||
href: `${base}/project-${$project?.$id}/sites/site-${$page.params.site}`,
|
||||
title: $page.params.site
|
||||
},
|
||||
{
|
||||
href: `${base}/project-${$project?.$id}/sites/site-${$page.params.site}/domains`,
|
||||
title: 'Domains'
|
||||
},
|
||||
{
|
||||
href: `${base}/project-${$project?.$id}/sites/site-${$page.params.site}/domains/domain-${$page.params.domain}`,
|
||||
title: $page.params.domain
|
||||
}
|
||||
];
|
||||
</script>
|
||||
|
||||
<Breadcrumbs {breadcrumbs} />
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { BoxAvatar, CardGrid } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import Delete from '../deleteDomainModal.svelte';
|
||||
|
||||
export let domain: Models.ProxyRule;
|
||||
let show = false;
|
||||
</script>
|
||||
|
||||
<CardGrid>
|
||||
<svelte:fragment slot="title">Delete domain</svelte:fragment>
|
||||
Deleting this domain will remove the domain from all associated projects.
|
||||
<svelte:fragment slot="aside">
|
||||
<BoxAvatar>
|
||||
<svelte:fragment slot="title">
|
||||
<h6 class="u-bold u-trim-1">{domain.domain}</h6>
|
||||
</svelte:fragment>
|
||||
<p>Last updated: {toLocaleDateTime(domain.$updatedAt)}</p>
|
||||
</BoxAvatar>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button secondary on:click={() => (show = true)}>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
|
||||
<Delete bind:show selectedDomain={domain} />
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid, Trim } from '$lib/components';
|
||||
import Heading from '$lib/components/heading.svelte';
|
||||
import Link from '$lib/elements/link.svelte';
|
||||
import { toLocaleDate } from '$lib/helpers/date';
|
||||
import { protocol } from '$routes/(console)/store';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { IconExternalLink } from '@appwrite.io/pink-icons-svelte';
|
||||
import { Icon, Layout, Typography } from '@appwrite.io/pink-svelte';
|
||||
|
||||
export let domain: Models.ProxyRule;
|
||||
</script>
|
||||
|
||||
<CardGrid>
|
||||
<svelte:fragment slot="title">SSL certificates</svelte:fragment>
|
||||
SSL certificates secure your site with HTTPS, protecting data and boosting trust. Appwrite renews
|
||||
your SSL certificates automatically.
|
||||
<svelte:fragment slot="aside">
|
||||
<Layout.Stack gap="xl">
|
||||
<Layout.Stack gap="xl" direction="row">
|
||||
<Layout.Stack gap="xs">
|
||||
<Typography.Text variant="m-400" color="--color-fgcolor-neutral-tertiary">
|
||||
Domain
|
||||
</Typography.Text>
|
||||
<Link external href={`${$protocol}${domain.domain}`} variant="muted">
|
||||
<Layout.Stack gap="xxs" direction="row" alignItems="center">
|
||||
<Trim alternativeTrim>
|
||||
{domain.domain}
|
||||
</Trim>
|
||||
<Icon icon={IconExternalLink} size="s" />
|
||||
</Layout.Stack>
|
||||
</Link>
|
||||
</Layout.Stack>
|
||||
<Layout.Stack gap="xs">
|
||||
<Typography.Text variant="m-400" color="--color-fgcolor-neutral-tertiary">
|
||||
Registrar
|
||||
</Typography.Text>
|
||||
MISSING BACKEND DATA
|
||||
</Layout.Stack>
|
||||
</Layout.Stack>
|
||||
<Layout.Stack gap="xl" direction="row">
|
||||
<Layout.Stack gap="xs">
|
||||
<Typography.Text variant="m-400" color="--color-fgcolor-neutral-tertiary">
|
||||
Expiry date
|
||||
</Typography.Text>
|
||||
|
||||
{toLocaleDate(domain.renewAt)}
|
||||
</Layout.Stack>
|
||||
<Layout.Stack gap="xs">
|
||||
<Typography.Text variant="m-400" color="--color-fgcolor-neutral-tertiary">
|
||||
Activity
|
||||
</Typography.Text>
|
||||
{toLocaleDate(domain.$updatedAt)}
|
||||
</Layout.Stack>
|
||||
</Layout.Stack>
|
||||
</Layout.Stack>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { Id } from '$lib/components';
|
||||
import { Cover, CoverTitle } from '$lib/layout';
|
||||
import { domain } from './store';
|
||||
</script>
|
||||
|
||||
<Cover>
|
||||
<svelte:fragment slot="header">
|
||||
<CoverTitle
|
||||
href={`${base}/project-${$page.params.project}/sites/site-${$page.params.site}/domains`}>
|
||||
{$domain.domain}
|
||||
</CoverTitle>
|
||||
<Id value={$domain.$id}>{$domain.$id}</Id>
|
||||
</svelte:fragment>
|
||||
</Cover>
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
import { page } from '$app/stores';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { derived } from 'svelte/store';
|
||||
|
||||
export const domain = derived(page, ($page) => $page.data.domain as Models.ProxyRule);
|
||||
@@ -1,41 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { Modal } from '$lib/components';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
export let showDelete = false;
|
||||
export let selectedExecution: Models.Execution;
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
await sdk.forProject.sites.deleteExecution($page.params.$id, selectedExecution.$id);
|
||||
await invalidate(Dependencies.EXECUTIONS);
|
||||
showDelete = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Execution has been deleted`
|
||||
});
|
||||
trackEvent(Submit.ExecutionDelete);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.ExecutionDelete);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal title="Delete execution" bind:show={showDelete} onSubmit={handleSubmit}>
|
||||
<p data-private>Are you sure you want to delete this execution?</p>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (showDelete = false)}>Cancel</Button>
|
||||
<Button secondary submit>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
Reference in new issue
Block a user