mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Merge pull request #1904 from appwrite/fix-org-redirection
fix: org routing, project creation
This commit is contained in:
@@ -6,8 +6,7 @@
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { page } from '$app/state';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { ID, Region as ConsoleRegion, type Models } from '@appwrite.io/console';
|
||||
import { createProject } from './wizard/store';
|
||||
import { ID, Region as ConsoleRegion, type Models, Region } from '@appwrite.io/console';
|
||||
import { Button } from '@appwrite.io/pink-svelte';
|
||||
import { base } from '$app/paths';
|
||||
import CreateProject from '$lib/layout/createProject.svelte';
|
||||
@@ -17,6 +16,10 @@
|
||||
export let regions: Array<Models.ConsoleRegion> = [];
|
||||
export let showCreateProjectCloud: boolean;
|
||||
|
||||
let id: string = null;
|
||||
let name: string = 'Appwrite project';
|
||||
let region: string = Region.Fra;
|
||||
|
||||
async function onFinish() {
|
||||
await invalidate(Dependencies.FUNCTIONS);
|
||||
}
|
||||
@@ -25,19 +28,19 @@
|
||||
try {
|
||||
// TODO: fix typing once SDK is updated
|
||||
const project = await sdk.forConsole.projects.create(
|
||||
$createProject?.id ?? ID.unique(),
|
||||
$createProject.name,
|
||||
id ?? ID.unique(),
|
||||
name,
|
||||
teamId,
|
||||
$createProject.region as ConsoleRegion
|
||||
region as ConsoleRegion
|
||||
);
|
||||
trackEvent(Submit.ProjectCreate, {
|
||||
customId: !!$createProject?.id,
|
||||
customId: !!id,
|
||||
teamId,
|
||||
region: $createProject.region
|
||||
region: region
|
||||
});
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${$createProject.name} has been created`
|
||||
message: `${name} has been created`
|
||||
});
|
||||
await onFinish();
|
||||
await goto(`${base}/project-${project.region}-${project.$id}`);
|
||||
@@ -51,21 +54,14 @@
|
||||
}
|
||||
|
||||
onDestroy(() => {
|
||||
$createProject = {
|
||||
id: null,
|
||||
name: null,
|
||||
region: 'fra'
|
||||
};
|
||||
id = null;
|
||||
name = null;
|
||||
region = 'fra';
|
||||
});
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showCreateProjectCloud} title={'Create project'} onSubmit={create}>
|
||||
<CreateProject
|
||||
showTitle={false}
|
||||
bind:id={$createProject.id}
|
||||
bind:projectName={$createProject.name}
|
||||
bind:region={$createProject.region}
|
||||
{regions}>
|
||||
<CreateProject showTitle={false} bind:id bind:projectName={name} bind:region {regions}>
|
||||
</CreateProject>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button.Button type="submit" variant="primary" size="s">Create</Button.Button>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
});
|
||||
|
||||
$: avatars = $members.memberships?.map((m) => m.userName || m.userEmail) ?? [];
|
||||
$: organizationId = page.params.organization;
|
||||
$: organizationId = $organization?.$id ?? page.params.organization;
|
||||
$: path = `${base}/organization-${organizationId}`;
|
||||
$: tabs = [
|
||||
{
|
||||
@@ -75,7 +75,7 @@
|
||||
].filter((tab) => !tab.disabled);
|
||||
</script>
|
||||
|
||||
{#if $organization?.$id}
|
||||
{#if $organization.$id}
|
||||
<Cover>
|
||||
<svelte:fragment slot="header">
|
||||
<span class="u-flex u-cross-center u-gap-8 u-min-width-0">
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export const createProject = writable<{
|
||||
id?: string;
|
||||
name: string;
|
||||
region: string;
|
||||
}>({
|
||||
id: null,
|
||||
name: 'Appwrite project',
|
||||
region: 'fra'
|
||||
});
|
||||
Reference in New Issue
Block a user