mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
add: domain in bg if not exists.
This commit is contained in:
+17
@@ -18,6 +18,8 @@
|
||||
import { onMount } from 'svelte';
|
||||
import { ConnectRepoModal } from '$lib/components/git/index.js';
|
||||
import { isValueOfStringEnum } from '$lib/helpers/types.js';
|
||||
import { isCloud } from '$lib/system';
|
||||
import { project } from '$routes/(console)/project-[region]-[project]/store';
|
||||
|
||||
const routeBase = `${base}/project-${page.params.region}-${page.params.project}/functions/function-${page.params.function}/domains`;
|
||||
|
||||
@@ -45,6 +47,21 @@
|
||||
});
|
||||
|
||||
async function addDomain() {
|
||||
let domain = data.domains?.domains.find((d) => d.domain === domainName);
|
||||
|
||||
if (!domain && isCloud) {
|
||||
try {
|
||||
domain = await sdk.forConsole.domains.create($project.teamId, domainName);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
let rule: Models.ProxyRule;
|
||||
if (behaviour === 'BRANCH') {
|
||||
|
||||
+5
-2
@@ -2,23 +2,26 @@ import { sdk } from '$lib/stores/sdk';
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { RuleTrigger, RuleType } from '$lib/stores/sdk';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { isCloud } from '$lib/system';
|
||||
|
||||
export const load = async ({ parent, depends, params }) => {
|
||||
const { function: func } = await parent();
|
||||
depends(Dependencies.DOMAINS, Dependencies.FUNCTION_DOMAINS);
|
||||
|
||||
const [domains, installations] = await Promise.all([
|
||||
const [rules, installations, domains] = await Promise.all([
|
||||
sdk
|
||||
.forProject(params.region, params.project)
|
||||
.proxy.listRules([
|
||||
Query.equal('type', RuleType.DEPLOYMENT),
|
||||
Query.equal('trigger', RuleTrigger.MANUAL)
|
||||
]),
|
||||
sdk.forProject(params.region, params.project).vcs.listInstallations()
|
||||
sdk.forProject(params.region, params.project).vcs.listInstallations(),
|
||||
isCloud ? sdk.forConsole.domains.list() : Promise.resolve(null)
|
||||
]);
|
||||
|
||||
return {
|
||||
func,
|
||||
rules,
|
||||
domains,
|
||||
installations,
|
||||
branches:
|
||||
|
||||
Reference in New Issue
Block a user