From 1dec4d2735c5acfd2d7d4cb606c75c548b5b465c Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 26 Jul 2023 14:36:32 +0200 Subject: [PATCH] fix: push some changes --- package-lock.json | 8 +- package.json | 2 +- src/lib/layout/logs.svelte | 2 - src/lib/layout/shell.svelte | 18 +- src/lib/layout/wizardCover.svelte | 35 +++ src/lib/pages/domains/create.svelte | 6 +- src/lib/stores/wizard.ts | 10 +- .../functions/components/repositories.svelte | 217 ++++++++++++++++++ .../wizards/functions/connectExisting.svelte | 6 +- src/lib/wizards/functions/cover.svelte | 163 +++++++++++++ src/lib/wizards/functions/createGit.svelte | 15 +- src/lib/wizards/functions/createManual.svelte | 9 +- .../wizards/functions/createStarter.svelte | 6 +- .../functions/steps/selectRepository.svelte | 192 +--------------- src/routes/console/+layout.svelte | 2 + src/routes/console/+layout.ts | 2 +- .../createDocument.svelte | 6 +- .../project-[project]/functions/+page.svelte | 49 ++-- .../overview/keys/wizard.svelte | 7 +- .../overview/platforms/createAndroid.svelte | 6 +- .../overview/platforms/createApple.svelte | 6 +- .../overview/platforms/createFlutter.svelte | 6 +- .../overview/platforms/createWeb.svelte | 6 +- .../settings/GitInstallationModal.svelte | 11 +- .../settings/updateInstallations.svelte | 9 +- .../settings/webhooks/+page.svelte | 5 - vite.config.ts | 9 +- 27 files changed, 502 insertions(+), 311 deletions(-) create mode 100644 src/lib/layout/wizardCover.svelte create mode 100644 src/lib/wizards/functions/components/repositories.svelte create mode 100644 src/lib/wizards/functions/cover.svelte diff --git a/package-lock.json b/package-lock.json index c6b68ff0f..24d315d0d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "dependencies": { "@analytics/google-analytics": "^1.0.5", "@appwrite.io/console": "npm:matej-appwrite-console@7.1.102", - "@appwrite.io/pink": "0.0.6-rc.10", + "@appwrite.io/pink": "0.0.6-rc.15", "@popperjs/core": "^2.11.6", "@sentry/svelte": "^7.44.2", "@sentry/tracing": "^7.44.2", @@ -167,9 +167,9 @@ } }, "node_modules/@appwrite.io/pink": { - "version": "0.0.6-rc.10", - "resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.0.6-rc.10.tgz", - "integrity": "sha512-mhpgjQVfQvghItgcCzsHN0Ynn4U9JNg8HlSJ+HVDUi/bNHxmlm7XdNJE6s65LMJ6LfepROn6zZMHquANvGfNDg==", + "version": "0.0.6-rc.15", + "resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.0.6-rc.15.tgz", + "integrity": "sha512-CLgN+2NLuypmcYEjAlB8sOQyvjloCTKvNHa/flIBOkZKIEH2YX5qWSM/O08GLUuMPWS4Y/+z1U4uIvGOATTiTg==", "dependencies": { "@appwrite.io/pink-icons": "*", "normalize.css": "^8.0.1", diff --git a/package.json b/package.json index 75250af25..39ca7c745 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "dependencies": { "@analytics/google-analytics": "^1.0.5", "@appwrite.io/console": "npm:matej-appwrite-console@7.1.102", - "@appwrite.io/pink": "0.0.6-rc.10", + "@appwrite.io/pink": "0.0.6-rc.15", "@popperjs/core": "^2.11.6", "@sentry/svelte": "^7.44.2", "@sentry/tracing": "^7.44.2", diff --git a/src/lib/layout/logs.svelte b/src/lib/layout/logs.svelte index 917b1fe6a..0199a0ee1 100644 --- a/src/lib/layout/logs.svelte +++ b/src/lib/layout/logs.svelte @@ -15,8 +15,6 @@ let selectedResponse = 'logs'; let rawData: string; - $: console.log($log.data); - function isExecution( data: Models.Deployment | Models.Execution ): data is Models.Execution { diff --git a/src/lib/layout/shell.svelte b/src/lib/layout/shell.svelte index f4f5fd0cf..c3cc62ae0 100644 --- a/src/lib/layout/shell.svelte +++ b/src/lib/layout/shell.svelte @@ -26,13 +26,17 @@ } }; + /** + * Cancel navigation when wizard is open and triggered by popstate + */ beforeNavigate((n) => { - /** - * Hide wizard when navigation is triggered by popstate. - */ - if (n.type === 'popstate' && $wizard.show) { - wizard.hide(); - n.cancel(); + if ($wizard.show || $wizard.cover) { + if (n.type === 'popstate') { + n.cancel(); + } + if (n.type !== 'leave') { + wizard.hide(); + } } }); @@ -42,7 +46,7 @@
+ class:u-hide={$wizard.show || $log.show || $wizard.cover}>
+ +
+ +
+ +
+ diff --git a/src/lib/pages/domains/create.svelte b/src/lib/pages/domains/create.svelte index 0ca97feb6..b1a17ec22 100644 --- a/src/lib/pages/domains/create.svelte +++ b/src/lib/pages/domains/create.svelte @@ -1,6 +1,6 @@ + +{#if hasInstallations} + {#await loadInstallations()} +
+
+
+ {:then installations} +
+
+ { + return { + label: entry.organization, + value: entry.$id + }; + })} + on:change={() => { + search = ''; + installation.set( + installations.find((entry) => entry.$id === selectedInstallation) + ); + }} + bind:value={selectedInstallation} /> +
+
+ +
+
+ {/await} + + {#if selectedInstallation} +

+ Manage organization configuration in your project settings. +

+ {#await loadRepositories(selectedInstallation, search)} +
+
+
+ Loading repositories... +
+
+ {:then response} + {#if response?.total} +
    + {#each response.repositories as repo} +
  • +
    +
    + {#if action === 'select'} + repository.set(repo)} + value={repo.id} /> + {/if} + {#await loadDetection(selectedInstallation, repo.id)} +
    +
    +
    + {:then detection} +
    + {#if detection.runtime} + {repo.name} + {/if} +
    + {/await} +
    + {repo.name} + {#if repo.private} +
    + {#if action === 'button'} +
    + +
    + {/if} +
    +
    +
  • + {/each} +
+ {:else if search} + +
+
+ Sorry we couldn't find "{search}" +

There are no repositories that match your search.

+
+
+ + +
+
+
+ {:else} + +
+
+

You have no repositories.

+

+ Need a hand? Learn more in our + documentation. +

+
+
+
+ {/if} + {/await} + {/if} +{:else} +
+ + + +
+{/if} diff --git a/src/lib/wizards/functions/connectExisting.svelte b/src/lib/wizards/functions/connectExisting.svelte index 9eca81990..01e74c7bd 100644 --- a/src/lib/wizards/functions/connectExisting.svelte +++ b/src/lib/wizards/functions/connectExisting.svelte @@ -7,7 +7,7 @@ import { func } from '$routes/console/project-[project]/functions/function-[function]/store'; import { choices, installation, repository } from './store'; import { wizard } from '$lib/stores/wizard'; - import { beforeNavigate, invalidate } from '$app/navigation'; + import { invalidate } from '$app/navigation'; import { Dependencies } from '$lib/constants'; async function createGitHubInstallation() { @@ -33,10 +33,6 @@ wizard.hide(); } - beforeNavigate(() => { - wizard.hide(); - }); - function resetState() { choices.set({ branch: null, diff --git a/src/lib/wizards/functions/cover.svelte b/src/lib/wizards/functions/cover.svelte new file mode 100644 index 000000000..866326c97 --- /dev/null +++ b/src/lib/wizards/functions/cover.svelte @@ -0,0 +1,163 @@ + + + + Create function +
+
+ Choose your source +

+ Connect your function to a Git repository or use a template to get started. You can + also create a function wizard.start(CreateManual)}>manually. +

+
+
+
+ Import Git repository +

+ Create and deploy a function with a connected git repository. +

+
+ +
+
+
+

Quick start

+

+ Use a starter templates to begin with the basics. +

+
    + {#each quickStarts as quickStart} +
  • + +
  • + {/each} +
+
+
+

Templates

+

+ Choose from a selection of templates to find the right one for your use + case. +

+ +
    + {#each templates as template} +
  • + +
  • + {/each} +
+
+
+
+
+ diff --git a/src/lib/wizards/functions/createGit.svelte b/src/lib/wizards/functions/createGit.svelte index 4d665d76a..40ac4745a 100644 --- a/src/lib/wizards/functions/createGit.svelte +++ b/src/lib/wizards/functions/createGit.svelte @@ -4,14 +4,13 @@ import type { WizardStepsType } from '$lib/layout/wizard.svelte'; import { sdk } from '$lib/stores/sdk'; import { wizard } from '$lib/stores/wizard'; - import { beforeNavigate, goto } from '$app/navigation'; + import { goto } from '$app/navigation'; import { choices, createFunction, installation, repository } from './store'; import { addNotification } from '$lib/stores/notifications'; import { Submit, trackEvent } from '$lib/actions/analytics'; import { base } from '$app/paths'; import { page } from '$app/stores'; import ExecuteAccess from './steps/executeAccess.svelte'; - import SelectRepository from './steps/selectRepository.svelte'; import GitConfiguration from './steps/gitConfiguration.svelte'; import FunctionConfiguration from './steps/functionConfiguration.svelte'; @@ -46,10 +45,6 @@ wizard.hide(); } - beforeNavigate(() => { - wizard.hide(); - }); - function resetState() { createFunction.set({ $id: null, @@ -62,18 +57,14 @@ const stepsComponents: WizardStepsType = new Map(); stepsComponents.set(1, { - label: 'Select Repository', - component: SelectRepository - }); - stepsComponents.set(2, { label: 'Git configuration', component: GitConfiguration }); - stepsComponents.set(3, { + stepsComponents.set(2, { label: 'Function configuration', component: FunctionConfiguration }); - stepsComponents.set(4, { + stepsComponents.set(3, { label: 'Execute access', component: ExecuteAccess, optional: true diff --git a/src/lib/wizards/functions/createManual.svelte b/src/lib/wizards/functions/createManual.svelte index 66075f2da..1122bc2ea 100644 --- a/src/lib/wizards/functions/createManual.svelte +++ b/src/lib/wizards/functions/createManual.svelte @@ -4,7 +4,7 @@ import type { WizardStepsType } from '$lib/layout/wizard.svelte'; import { sdk } from '$lib/stores/sdk'; import { wizard } from '$lib/stores/wizard'; - import { beforeNavigate, goto } from '$app/navigation'; + import { goto } from '$app/navigation'; import { choices, createFunction, @@ -36,7 +36,7 @@ ); await sdk.forProject.functions.createDeployment( response.$id, - $createFunctionDeployment.item[0], + $createFunctionDeployment[0], true ); goto(`${base}/console/project-${$page.params.project}/functions/function-${response.$id}`); @@ -51,10 +51,6 @@ wizard.hide(); } - beforeNavigate(() => { - wizard.hide(); - }); - function resetState() { createFunction.set({ $id: null, @@ -70,6 +66,7 @@ }); installation.set(null); repository.set(null); + createFunctionDeployment.set(null); } const stepsComponents: WizardStepsType = new Map(); diff --git a/src/lib/wizards/functions/createStarter.svelte b/src/lib/wizards/functions/createStarter.svelte index 4d665d76a..06e128cdd 100644 --- a/src/lib/wizards/functions/createStarter.svelte +++ b/src/lib/wizards/functions/createStarter.svelte @@ -4,7 +4,7 @@ import type { WizardStepsType } from '$lib/layout/wizard.svelte'; import { sdk } from '$lib/stores/sdk'; import { wizard } from '$lib/stores/wizard'; - import { beforeNavigate, goto } from '$app/navigation'; + import { goto } from '$app/navigation'; import { choices, createFunction, installation, repository } from './store'; import { addNotification } from '$lib/stores/notifications'; import { Submit, trackEvent } from '$lib/actions/analytics'; @@ -46,10 +46,6 @@ wizard.hide(); } - beforeNavigate(() => { - wizard.hide(); - }); - function resetState() { createFunction.set({ $id: null, diff --git a/src/lib/wizards/functions/steps/selectRepository.svelte b/src/lib/wizards/functions/steps/selectRepository.svelte index 2bd34a8bf..29f2615a5 100644 --- a/src/lib/wizards/functions/steps/selectRepository.svelte +++ b/src/lib/wizards/functions/steps/selectRepository.svelte @@ -1,48 +1,9 @@ @@ -64,144 +19,5 @@ Select a Git repository that will trigger your function deployments when updated. - {#if hasInstallations} - {#await loadInstallations()} -
-
-
- {:then installations} -
-
- { - return { - label: entry.organization, - value: entry.$id - }; - })} - on:change={() => { - search = ''; - installation.set( - installations.find((entry) => entry.$id === selectedInstallation) - ); - }} - bind:value={selectedInstallation} /> -
-
- -
-
- {/await} - - {#if selectedInstallation} -

- Manage organization configuration in your project settings. -

- {#await loadRepositories(selectedInstallation, search)} -
-
-
- Loading repositories... -
-
- {:then response} - {#if response?.total} -
    - {#each response.repositories as repo} -
  • -
  • - {/each} -
- {:else if search} - -
-
- Sorry we couldn't find "{search}" -

There are no repositories that match your search.

-
-
- - -
-
-
- {:else} - -
-
-

You have no repositories.

-

- Need a hand? Learn more in our - documentation. -

-
-
-
- {/if} - {/await} - {/if} - {:else} -
- - - -
- {/if} + diff --git a/src/routes/console/+layout.svelte b/src/routes/console/+layout.svelte index 870794b40..f74282bdd 100644 --- a/src/routes/console/+layout.svelte +++ b/src/routes/console/+layout.svelte @@ -59,6 +59,8 @@ {#if $wizard.show && $wizard.component} +{:else if $wizard.cover} + {/if} diff --git a/src/routes/console/+layout.ts b/src/routes/console/+layout.ts index 65de11ecd..3b0cff2ff 100644 --- a/src/routes/console/+layout.ts +++ b/src/routes/console/+layout.ts @@ -1,7 +1,7 @@ import { sdk } from '$lib/stores/sdk'; import type { LayoutLoad } from './$types'; -export const load: LayoutLoad = async () => { +export const load: LayoutLoad = async ({ fetch }) => { const response = await fetch(`${sdk.forConsole.client.config.endpoint}/health/version`); const data = await response.json(); diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/createDocument.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/createDocument.svelte index 520fcb113..68a63996f 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/createDocument.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/createDocument.svelte @@ -1,5 +1,5 @@
Functions - - - - - - wizard.start(CreateManual)}>Manual - wizard.start(CreateGit)}>Git - wizard.start(CreateStarter)} - >Starter template - - +
{#if data.functions.total} @@ -81,14 +66,14 @@
- {#if func.scheduleNext} + {#if func.schedule}
  • {/if} diff --git a/src/routes/console/project-[project]/overview/keys/wizard.svelte b/src/routes/console/project-[project]/overview/keys/wizard.svelte index f1df93a85..4cd6c7b80 100644 --- a/src/routes/console/project-[project]/overview/keys/wizard.svelte +++ b/src/routes/console/project-[project]/overview/keys/wizard.svelte @@ -1,7 +1,6 @@ diff --git a/src/routes/console/project-[project]/settings/updateInstallations.svelte b/src/routes/console/project-[project]/settings/updateInstallations.svelte index b1fd6529b..93d01ed27 100644 --- a/src/routes/console/project-[project]/settings/updateInstallations.svelte +++ b/src/routes/console/project-[project]/settings/updateInstallations.svelte @@ -60,8 +60,13 @@ function configureGitHub() { const redirect = new URL($page.url); - redirect.searchParams.set('alert', 'installation-updated'); - sdk.forProject.vcs.createGitHubInstallation(redirect.toString()); + redirect.searchParams.append('alert', 'installation-updated'); + const target = new URL( + `${sdk.forProject.client.config.endpoint}/v1/vcs/github/installations` + ); + target.searchParams.set('projectId', $page.params.project); + target.searchParams.set('redirect', redirect.toString()); + goto(target); } async function navigateInstallations() { diff --git a/src/routes/console/project-[project]/settings/webhooks/+page.svelte b/src/routes/console/project-[project]/settings/webhooks/+page.svelte index 1e22b243a..77d1009db 100644 --- a/src/routes/console/project-[project]/settings/webhooks/+page.svelte +++ b/src/routes/console/project-[project]/settings/webhooks/+page.svelte @@ -1,5 +1,4 @@ diff --git a/vite.config.ts b/vite.config.ts index e07273360..a721bbe6e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -7,7 +7,14 @@ const config = defineConfig({ include: ['echarts', 'prismjs'] }, ssr: { - noExternal: ['echarts', 'prismjs', '@analytics/google-analytics', 'analytics', 'dayjs'] + noExternal: [ + 'echarts', + 'prismjs', + '@analytics/google-analytics', + 'analytics', + 'dayjs', + 'dotenv' + ] }, define: { 'import.meta.env.VERCEL_ANALYTICS_ID': JSON.stringify(process.env.VERCEL_ANALYTICS_ID)