mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
feat: re-enable domain check, disconect repo
This commit is contained in:
@@ -338,5 +338,6 @@ export enum Submit {
|
||||
SiteUpdateBuildSettings = 'submit_site_update_build_settings',
|
||||
SiteUpdateSinglePageApplication = 'submit_site_update_single_page_application',
|
||||
SiteConnectRepo = 'submit_site_connect_repo',
|
||||
SiteRedeploy = 'submit_site_redeploy'
|
||||
SiteRedeploy = 'submit_site_redeploy',
|
||||
SiteDisconnectRepo = 'submit_site_disconnect_repo'
|
||||
}
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
<script lang="ts">
|
||||
import Card from '$lib/components/card.svelte';
|
||||
import { Button, InputText } from '$lib/elements/forms';
|
||||
import { debounce } from '$lib/helpers/debounce';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { consoleVariables } from '$routes/(console)/store';
|
||||
import { ResourceType } from '@appwrite.io/console';
|
||||
import { Fieldset, Layout, Divider, Status, Typography } from '@appwrite.io/pink-svelte';
|
||||
|
||||
export let domain: string;
|
||||
export let domainIsValid = true;
|
||||
const orginalDomain = domain.split('').join('');
|
||||
let showConfig = false;
|
||||
let domainSuccess = true;
|
||||
|
||||
//TODO: debounce this
|
||||
const checkDomain = debounce(async (value: string) => {
|
||||
try {
|
||||
await sdk.forProject.proxy.checkSubdomain(ResourceType.Site, value);
|
||||
domainIsValid = true;
|
||||
} catch {
|
||||
domainIsValid = false;
|
||||
}
|
||||
}, 300);
|
||||
|
||||
$: if (domain) {
|
||||
sdk.forProject.proxy
|
||||
.checkSubdomain(ResourceType.Site, domain)
|
||||
.then(() => {
|
||||
domainSuccess = true;
|
||||
})
|
||||
.catch(() => {
|
||||
domainSuccess = false;
|
||||
});
|
||||
checkDomain(domain);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -36,8 +38,8 @@
|
||||
</svelte:fragment>
|
||||
</InputText>
|
||||
<Status
|
||||
status={domainSuccess ? 'complete' : 'failed'}
|
||||
label={domainSuccess ? 'Domain is available' : 'Domain is not available'}>
|
||||
status={domainIsValid ? 'complete' : 'failed'}
|
||||
label={domainIsValid ? 'Domain is available' : 'Domain is not available'}>
|
||||
</Status>
|
||||
</Layout.Stack>
|
||||
<Divider />
|
||||
@@ -49,7 +51,7 @@
|
||||
showConfig = false;
|
||||
}}>Cancel</Button>
|
||||
|
||||
<Button secondary disabled={!domainSuccess} on:click={() => (showConfig = false)}>
|
||||
<Button secondary disabled={!domainIsValid} on:click={() => (showConfig = false)}>
|
||||
Update
|
||||
</Button>
|
||||
</Layout.Stack>
|
||||
@@ -64,11 +66,9 @@
|
||||
{domain}.{$consoleVariables._APP_DOMAIN_TARGET}
|
||||
</Layout.Stack>
|
||||
</Typography.Text>
|
||||
<!-- TODO: reenable -->
|
||||
<Button
|
||||
size="s"
|
||||
secondary
|
||||
disabled
|
||||
on:click={() => {
|
||||
showConfig = true;
|
||||
}}>
|
||||
|
||||
+56
-49
@@ -42,6 +42,7 @@
|
||||
let name = data.template.name;
|
||||
let id = ID.unique();
|
||||
let domain = id;
|
||||
let domainIsValid = true;
|
||||
let framework = data?.template?.frameworks[0];
|
||||
let branch = 'main';
|
||||
let rootDir = './';
|
||||
@@ -107,54 +108,61 @@
|
||||
message: 'Please select a repository'
|
||||
});
|
||||
return;
|
||||
}
|
||||
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,
|
||||
framework.installCommand,
|
||||
framework.buildCommand,
|
||||
framework.outputDirectory,
|
||||
domain,
|
||||
framework.adapter,
|
||||
selectedInstallationId || undefined,
|
||||
framework.fallbackFile,
|
||||
selectedRepository || undefined,
|
||||
branch || undefined,
|
||||
selectedRepository ? silentMode : undefined,
|
||||
rootDir || undefined,
|
||||
data.template.providerRepositoryId || undefined,
|
||||
data.template.providerOwner || undefined,
|
||||
framework.providerRootDirectory || undefined,
|
||||
data.template.providerVersion || undefined
|
||||
);
|
||||
|
||||
trackEvent(Submit.SiteCreate, {
|
||||
source: 'template'
|
||||
});
|
||||
|
||||
const { deployments } = await sdk.forProject.sites.listDeployments(site.$id, [
|
||||
Query.limit(1)
|
||||
]);
|
||||
const deployment = deployments[0];
|
||||
await goto(
|
||||
`${base}/project-${$page.params.project}/sites/create-site/deploying?site=${site.$id}&deployment=${deployment.$id}`
|
||||
);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
} else if (!domainIsValid) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: e.message
|
||||
message: 'Please enter a valid domain'
|
||||
});
|
||||
trackError(e, Submit.SiteCreate);
|
||||
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,
|
||||
framework.installCommand,
|
||||
framework.buildCommand,
|
||||
framework.outputDirectory,
|
||||
domain,
|
||||
framework.adapter,
|
||||
selectedInstallationId || undefined,
|
||||
framework.fallbackFile,
|
||||
selectedRepository || undefined,
|
||||
branch || undefined,
|
||||
selectedRepository ? silentMode : undefined,
|
||||
rootDir || undefined,
|
||||
data.template.providerRepositoryId || undefined,
|
||||
data.template.providerOwner || undefined,
|
||||
framework.providerRootDirectory || undefined,
|
||||
data.template.providerVersion || undefined
|
||||
);
|
||||
|
||||
trackEvent(Submit.SiteCreate, {
|
||||
source: 'template'
|
||||
});
|
||||
|
||||
const { deployments } = await sdk.forProject.sites.listDeployments(site.$id, [
|
||||
Query.limit(1)
|
||||
]);
|
||||
const deployment = deployments[0];
|
||||
await goto(
|
||||
`${base}/project-${$page.params.project}/sites/create-site/deploying?site=${site.$id}&deployment=${deployment.$id}`
|
||||
);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: e.message
|
||||
});
|
||||
trackError(e, Submit.SiteCreate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +217,7 @@
|
||||
{#if data.template.variables?.length}
|
||||
<Configuration bind:variables templateVariables={data.template.variables} />
|
||||
{/if}
|
||||
<Domain bind:domain />
|
||||
<Domain bind:domain bind:domainIsValid />
|
||||
</Layout.Stack>
|
||||
{:else}
|
||||
{@const options = data.template.frameworks.map((framework) => {
|
||||
@@ -284,7 +292,7 @@
|
||||
{#if data.template.variables?.length}
|
||||
<Configuration bind:variables templateVariables={data.template.variables} />
|
||||
{/if}
|
||||
<Domain bind:domain />
|
||||
<Domain bind:domain bind:domainIsValid />
|
||||
{/if}
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
@@ -295,8 +303,7 @@
|
||||
<Typography.Text variant="m-500" truncate>
|
||||
{name || data.template.name}
|
||||
</Typography.Text>
|
||||
<!-- TODO: re-enable -->
|
||||
<Button secondary size="s" href={data.template.demoUrl} disabled>View demo</Button>
|
||||
<Button secondary size="s" external href={data.template.demoUrl}>View demo</Button>
|
||||
</Layout.Stack>
|
||||
|
||||
<Image
|
||||
|
||||
+26
-7
@@ -5,7 +5,8 @@
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { BuildRuntime, Framework, Models } from '@appwrite.io/console';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
export let show = false;
|
||||
@@ -14,21 +15,39 @@
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
const handleSubmit = async () => {
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
await invalidate(Dependencies.FUNCTION);
|
||||
await sdk.forProject.sites.update(
|
||||
site.$id,
|
||||
site.name,
|
||||
site.framework as Framework,
|
||||
site.enabled || undefined,
|
||||
site.timeout || undefined,
|
||||
site.installCommand || undefined,
|
||||
site.buildCommand || undefined,
|
||||
site.outputDirectory || undefined,
|
||||
(site?.buildRuntime as BuildRuntime) || undefined,
|
||||
site.adapter,
|
||||
site.fallbackFile || undefined,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
undefined,
|
||||
''
|
||||
);
|
||||
await invalidate(Dependencies.SITE);
|
||||
dispatch('success');
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Repository has been disconnected from your function`
|
||||
message: `Repository has been disconnected from your site`
|
||||
});
|
||||
trackEvent(Submit.FunctionDisconnectRepo);
|
||||
trackEvent(Submit.SiteDisconnectRepo);
|
||||
show = false;
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
trackError(e, Submit.FunctionDisconnectRepo);
|
||||
trackError(e, Submit.SiteDisconnectRepo);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
$: if (!show) {
|
||||
error = '';
|
||||
|
||||
Reference in New Issue
Block a user