From c498ff04306a321dbeddda40dc3807d38345fbae Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 5 Aug 2024 15:08:34 +0200 Subject: [PATCH] feat: upgrade functions wizard --- src/lib/layout/wizard.svelte | 13 ++- src/lib/wizards/functions/createManual.svelte | 4 +- .../wizards/functions/createTemplate.svelte | 79 +++++++++++++------ ...tion.svelte => manualConfiguration.svelte} | 0 .../{details.svelte => manualDetails.svelte} | 0 .../steps/repositoryBehaviour.svelte | 41 ---------- .../functions/steps/templateDeployment.svelte | 53 +++++++++++++ .../functions/steps/templateScopes.svelte | 57 +++++++++++++ src/lib/wizards/functions/store.ts | 11 ++- 9 files changed, 184 insertions(+), 74 deletions(-) rename src/lib/wizards/functions/steps/{configuration.svelte => manualConfiguration.svelte} (100%) rename src/lib/wizards/functions/steps/{details.svelte => manualDetails.svelte} (100%) delete mode 100644 src/lib/wizards/functions/steps/repositoryBehaviour.svelte create mode 100644 src/lib/wizards/functions/steps/templateDeployment.svelte create mode 100644 src/lib/wizards/functions/steps/templateScopes.svelte diff --git a/src/lib/layout/wizard.svelte b/src/lib/layout/wizard.svelte index f62bd15d7..b260a67a1 100644 --- a/src/lib/layout/wizard.svelte +++ b/src/lib/layout/wizard.svelte @@ -139,7 +139,18 @@ } $: sortedSteps = [...steps].sort(([a], [b]) => (a > b ? 1 : -1)); - $: isLastStep = $wizard.step === steps.size; + $: isLastStep = (() => { + if ($wizard.step === steps.size) { + return true; + } + let lastStep = true; + steps.forEach((step, i) => { + if (i > $wizard.step && !step.disabled) { + lastStep = false; + } + }); + return lastStep; + })(); $: currentStep = steps.get($wizard.step); diff --git a/src/lib/wizards/functions/createManual.svelte b/src/lib/wizards/functions/createManual.svelte index f5ab83b3b..c774c3516 100644 --- a/src/lib/wizards/functions/createManual.svelte +++ b/src/lib/wizards/functions/createManual.svelte @@ -16,8 +16,8 @@ import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; import { base } from '$app/paths'; import { page } from '$app/stores'; - import Details from './steps/details.svelte'; - import Configuration from './steps/configuration.svelte'; + import Details from './steps/manualDetails.svelte'; + import Configuration from './steps/manualConfiguration.svelte'; import ExecuteAccess from './steps/executeAccess.svelte'; import { isValueOfStringEnum } from '$lib/helpers/types'; diff --git a/src/lib/wizards/functions/createTemplate.svelte b/src/lib/wizards/functions/createTemplate.svelte index 36d74abdd..03ba68fc5 100644 --- a/src/lib/wizards/functions/createTemplate.svelte +++ b/src/lib/wizards/functions/createTemplate.svelte @@ -1,22 +1,29 @@ - + diff --git a/src/lib/wizards/functions/steps/configuration.svelte b/src/lib/wizards/functions/steps/manualConfiguration.svelte similarity index 100% rename from src/lib/wizards/functions/steps/configuration.svelte rename to src/lib/wizards/functions/steps/manualConfiguration.svelte diff --git a/src/lib/wizards/functions/steps/details.svelte b/src/lib/wizards/functions/steps/manualDetails.svelte similarity index 100% rename from src/lib/wizards/functions/steps/details.svelte rename to src/lib/wizards/functions/steps/manualDetails.svelte diff --git a/src/lib/wizards/functions/steps/repositoryBehaviour.svelte b/src/lib/wizards/functions/steps/repositoryBehaviour.svelte deleted file mode 100644 index c55fcee6b..000000000 --- a/src/lib/wizards/functions/steps/repositoryBehaviour.svelte +++ /dev/null @@ -1,41 +0,0 @@ - - - - Connect - - Connect function to a new repository or to an existing one within a selected Git - organization. - - -
    - - Create a new repository - Clone the template and create a new repository in your selected organization. - - - Add to existing repository - Clone the template to an existing repository in your selected organization. - -
-
diff --git a/src/lib/wizards/functions/steps/templateDeployment.svelte b/src/lib/wizards/functions/steps/templateDeployment.svelte new file mode 100644 index 000000000..e55b47015 --- /dev/null +++ b/src/lib/wizards/functions/steps/templateDeployment.svelte @@ -0,0 +1,53 @@ + + + + Deployment + + Connect function to a new repository or to an existing one within a selected Git + organization. + + +

Automatic with Git Recommended

+ + + Create a new repository + Clone the template and create a new repository in your selected organization. + + + Add to existing repository + Clone the template to an existing repository in your selected organization. + + + +

Manual with CLI

+
    + + Create manually + Clone the template to an existing repository in your selected organization. + +
+
diff --git a/src/lib/wizards/functions/steps/templateScopes.svelte b/src/lib/wizards/functions/steps/templateScopes.svelte new file mode 100644 index 000000000..c5c07bd07 --- /dev/null +++ b/src/lib/wizards/functions/steps/templateScopes.svelte @@ -0,0 +1,57 @@ + + + + Details + Create and deploy your function manually. + + + + + + {#if !showCustomId} +
+ (showCustomId = !showCustomId)}> + +
+ {:else} + + {/if} +
+
diff --git a/src/lib/wizards/functions/store.ts b/src/lib/wizards/functions/store.ts index e607c113b..090d97117 100644 --- a/src/lib/wizards/functions/store.ts +++ b/src/lib/wizards/functions/store.ts @@ -1,7 +1,8 @@ import { page } from '$app/stores'; +import type { WizardStepsType } from '$lib/layout/wizard.svelte'; import type { MarketplaceTemplate } from '$lib/stores/marketplace'; import type { Models } from '@appwrite.io/console'; -import { derived, writable } from 'svelte/store'; +import { derived, writable, type Writable } from 'svelte/store'; export const template = writable(); export const templateConfig = writable<{ @@ -9,9 +10,9 @@ export const templateConfig = writable<{ name: string; runtime: string; variables: { [key: string]: unknown }; - repositoryBehaviour: 'new' | 'existing'; - repositoryName: string; - repositoryPrivate: boolean; + repositoryBehaviour: 'new' | 'existing' | 'manual'; + repositoryName?: string; + repositoryPrivate?: boolean; repositoryId: string; appwriteApiKey?: string; generateKey?: boolean; @@ -59,3 +60,5 @@ function createFunctionStore() { export const createFunction = createFunctionStore(); export const createFunctionDeployment = writable(); + +export const templateStepsComponents: Writable = writable(new Map());