From 11b85049e092b0390d41c6d3b6e07421515ff651 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 24 Aug 2023 13:59:26 +0200 Subject: [PATCH] fix: function template design --- src/lib/components/labelCard.svelte | 8 +- src/lib/layout/navigation.svelte | 5 -- src/lib/layout/shell.svelte | 4 +- src/lib/layout/wizard.svelte | 2 - .../functions/components/repositories.svelte | 8 +- src/lib/wizards/functions/cover.svelte | 14 +++- .../functions/steps/createRepository.svelte | 77 +++++++++++-------- .../steps/repositoryBehaviour.svelte | 11 ++- .../steps/templateConfiguration.svelte | 5 +- .../project-[project]/functions/+page.svelte | 26 ++++++- .../functions/createFunction.svelte | 2 +- .../project-[project]/functions/header.svelte | 10 +-- .../functions/templates/+page.svelte | 35 ++++++++- .../functions/templates/+page.ts | 1 - .../template-[template]/+page.svelte | 7 +- .../settings/migrations/(import)/step1.svelte | 2 - .../settings/migrations/+page.ts | 1 - static/logos/appwrite-full.svg | 7 ++ 18 files changed, 152 insertions(+), 73 deletions(-) create mode 100644 static/logos/appwrite-full.svg diff --git a/src/lib/components/labelCard.svelte b/src/lib/components/labelCard.svelte index bf77dbacb..5565b392e 100644 --- a/src/lib/components/labelCard.svelte +++ b/src/lib/components/labelCard.svelte @@ -7,6 +7,8 @@ export let icon: string = null; export let fullHeight = true; export let borderRadius: 'xsmall' | 'small' | 'medium' | 'large' = 'small'; + export let backgroundColor: string = null; + export let backgroundColorHover: string = null; enum Radius { xsmall = '--border-radius-xsmall', @@ -20,8 +22,10 @@ class="card is-allow-focus u-cursor-pointer" class:u-height-100-percent={fullHeight} style:--card-padding={`${padding}rem`} - style:--card-border-radius={`var(${Radius[borderRadius]})`}> -
+ style:--card-border-radius={`var(${Radius[borderRadius]})`} + style:--p-card-bg-color-default={backgroundColor} + style:--p-card-bg-color-hover={backgroundColorHover}> +
- import { beforeNavigate } from '$app/navigation'; import { base } from '$app/paths'; import { page } from '$app/stores'; import { trackEvent } from '$lib/actions/analytics'; @@ -37,10 +36,6 @@ isOpen = false; wizard.start(Create); } - - beforeNavigate(() => { - wizard.hide(); - }); diff --git a/src/lib/layout/shell.svelte b/src/lib/layout/shell.svelte index 132f458e8..5a5535296 100644 --- a/src/lib/layout/shell.svelte +++ b/src/lib/layout/shell.svelte @@ -30,7 +30,9 @@ * Cancel navigation when wizard is open and triggered by popstate */ beforeNavigate((n) => { - if (!$wizard.show || !$wizard.cover) return; + const external = n.to.url.hostname !== globalThis.location.hostname; + if (external) return; + if (!($wizard.show || $wizard.cover)) return; if (n.type === 'popstate') { n.cancel(); } diff --git a/src/lib/layout/wizard.svelte b/src/lib/layout/wizard.svelte index a30b3c71d..25067cf9d 100644 --- a/src/lib/layout/wizard.svelte +++ b/src/lib/layout/wizard.svelte @@ -84,8 +84,6 @@ $: sortedSteps = [...steps].sort(([a], [b]) => (a > b ? 1 : -1)); $: isLastStep = $wizard.step === steps.size; - - $: console.log({ sortedSteps, current: $wizard.step }); diff --git a/src/lib/wizards/functions/components/repositories.svelte b/src/lib/wizards/functions/components/repositories.svelte index 3caae80c2..9d3564186 100644 --- a/src/lib/wizards/functions/components/repositories.svelte +++ b/src/lib/wizards/functions/components/repositories.svelte @@ -12,9 +12,11 @@ const dispatch = createEventDispatcher(); + export let callbackState: Record = null; export let selectedRepository: string = null; export let hasInstallations = false; export let action: 'button' | 'select' = 'select'; + let offset = 0; const limit = 5; @@ -57,7 +59,11 @@ function connectGitHub() { const redirect = new URL($page.url); - redirect.searchParams.append('github-installed', 'true'); + if (callbackState) { + Object.keys(callbackState).forEach((key) => { + redirect.searchParams.append(key, callbackState[key]); + }); + } const target = new URL(`${sdk.forProject.client.config.endpoint}/vcs/github/authorize`); target.searchParams.set('projectId', $page.params.project); target.searchParams.set('success', redirect.toString()); diff --git a/src/lib/wizards/functions/cover.svelte b/src/lib/wizards/functions/cover.svelte index b4f55245c..46a9cdf79 100644 --- a/src/lib/wizards/functions/cover.svelte +++ b/src/lib/wizards/functions/cover.svelte @@ -19,7 +19,7 @@ variables, repositoryBehaviour: 'new', repositoryName: template.id, - repositoryPrivate: false, + repositoryPrivate: true, repositoryId: null }); wizard.start(CreateTemplate); @@ -46,7 +46,7 @@ let selectedRepository: string; const quickStart = marketplace.find((template) => template.id === 'starter'); - const templates = marketplace.filter((template) => template.id !== 'starter').slice(0, 3); + const templates = marketplace.filter((template) => template.id !== 'starter').slice(0, 2); function connect(event: CustomEvent) { repository.set(event.detail); @@ -60,7 +60,7 @@ - Create function + Create Function
@@ -74,6 +74,10 @@ bind:hasInstallations bind:selectedRepository action="button" + callbackState={{ + from: 'github', + to: 'cover' + }} on:connect={connect} />
@@ -125,7 +129,9 @@ }.svg`} alt={runtime.name} />
-
{runtimeDetail.name}
+
+ {runtimeDetail.name} +
{/each} diff --git a/src/lib/wizards/functions/steps/createRepository.svelte b/src/lib/wizards/functions/steps/createRepository.svelte index ae8562963..753773242 100644 --- a/src/lib/wizards/functions/steps/createRepository.svelte +++ b/src/lib/wizards/functions/steps/createRepository.svelte @@ -9,7 +9,7 @@ import { addNotification } from '$lib/stores/notifications'; import { sdk } from '$lib/stores/sdk'; import Repositories from '../components/repositories.svelte'; - import { installation, repository, templateConfig } from '../store'; + import { installation, repository, template, templateConfig } from '../store'; let selectedInstallationId: string; let hasInstallations: boolean; @@ -41,7 +41,19 @@ function connectGitHub() { const redirect = new URL($page.url); - redirect.searchParams.append('github-installed', 'true'); + const callbackState = { + from: 'github', + to: 'template', + step: '4', + template: $template.id, + templateConfig: JSON.stringify($templateConfig) + }; + + if (callbackState) { + Object.keys(callbackState).forEach((key) => { + redirect.searchParams.append(key, callbackState[key]); + }); + } const target = new URL(`${sdk.forProject.client.config.endpoint}/vcs/github/authorize`); target.searchParams.set('projectId', $page.params.project); target.searchParams.set('success', redirect.toString()); @@ -107,7 +119,7 @@
{/if} + {#if $installation} +
+
+
+ +
+
+
+ {$installation.organization}/{$templateConfig.repositoryName} +
+
+
+
+ + + + +
+
+ {/if} {/await} - - {#if $installation} -
-
-
- -
-
-
- {$installation.organization}/{$templateConfig.repositoryName} -
-
-
-
- - - - -
-
- {/if} {/if} diff --git a/src/lib/wizards/functions/steps/repositoryBehaviour.svelte b/src/lib/wizards/functions/steps/repositoryBehaviour.svelte index 3ae6bfabb..6b08f7682 100644 --- a/src/lib/wizards/functions/steps/repositoryBehaviour.svelte +++ b/src/lib/wizards/functions/steps/repositoryBehaviour.svelte @@ -17,14 +17,21 @@ 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/templateConfiguration.svelte b/src/lib/wizards/functions/steps/templateConfiguration.svelte index 56b8efb37..10e7406a9 100644 --- a/src/lib/wizards/functions/steps/templateConfiguration.svelte +++ b/src/lib/wizards/functions/steps/templateConfiguration.svelte @@ -51,9 +51,10 @@ label="Runtime" id="runtime" placeholder="Select runtime" - bind:value={$templateConfig.runtime} + required + disabled={options.length <= 1} {options} - required /> + bind:value={$templateConfig.runtime} /> {/await} diff --git a/src/routes/console/project-[project]/functions/+page.svelte b/src/routes/console/project-[project]/functions/+page.svelte index 23ff4f0d1..ff87b6f2c 100644 --- a/src/routes/console/project-[project]/functions/+page.svelte +++ b/src/routes/console/project-[project]/functions/+page.svelte @@ -18,6 +18,12 @@ import { onMount } from 'svelte'; import Initial from '$lib/wizards/functions/cover.svelte'; import { registerCommands } from '$lib/commandCenter'; + import CreateTemplate from '$lib/wizards/functions/createTemplate.svelte'; + import { + templateConfig as templateConfigStore, + template as templateStore + } from '$lib/wizards/functions/store.js'; + import { marketplace } from '$lib/stores/marketplace.js'; export let data; @@ -26,8 +32,24 @@ const project = $page.params.project; onMount(() => { - if ($page.url.searchParams.has('github-installed')) { - openWizard(); + const from = $page.url.searchParams.get('from'); + if (from === 'github') { + const to = $page.url.searchParams.get('to'); + switch (to) { + case 'template': + const step = $page.url.searchParams.get('step'); + const template = $page.url.searchParams.get('template'); + const templateConfig = $page.url.searchParams.get('templateConfig'); + templateStore.set(marketplace.find((item) => item.id === template)); + templateConfigStore.set(JSON.parse(templateConfig)); + wizard.start(CreateTemplate); + wizard.setStep(Number(step)); + break; + + case 'cover': + openWizard(); + break; + } } }); diff --git a/src/routes/console/project-[project]/functions/createFunction.svelte b/src/routes/console/project-[project]/functions/createFunction.svelte index 72daa6200..f748facf6 100644 --- a/src/routes/console/project-[project]/functions/createFunction.svelte +++ b/src/routes/console/project-[project]/functions/createFunction.svelte @@ -103,4 +103,4 @@ }); - + diff --git a/src/routes/console/project-[project]/functions/header.svelte b/src/routes/console/project-[project]/functions/header.svelte index 27c744031..8674ef158 100644 --- a/src/routes/console/project-[project]/functions/header.svelte +++ b/src/routes/console/project-[project]/functions/header.svelte @@ -16,8 +16,7 @@ { href: `${path}/templates`, title: 'Templates', - event: 'templates', - experimental: true + event: 'templates' } ]; @@ -35,13 +34,6 @@ event={tab.event}> {tab.title} - {#if tab.experimental} -
      -
      - Experimental -
      -
      - {/if} {/each} diff --git a/src/routes/console/project-[project]/functions/templates/+page.svelte b/src/routes/console/project-[project]/functions/templates/+page.svelte index 29d9730e6..e2fa3bb64 100644 --- a/src/routes/console/project-[project]/functions/templates/+page.svelte +++ b/src/routes/console/project-[project]/functions/templates/+page.svelte @@ -2,7 +2,14 @@ import { goto } from '$app/navigation'; import { base } from '$app/paths'; import { page } from '$app/stores'; - import { Collapsible, CollapsibleItem, EmptySearch, Pagination } from '$lib/components'; + import { tooltip } from '$lib/actions/tooltip.js'; + import { + Collapsible, + CollapsibleItem, + EmptySearch, + Heading, + Pagination + } from '$lib/components'; import { Button } from '$lib/elements/forms'; import { debounce } from '$lib/helpers/debounce'; import { Container } from '$lib/layout'; @@ -67,9 +74,14 @@ -
      +
      + Templates +
      + Experimental +
      +
      +
      -

      Filter templates

      @@ -155,6 +167,8 @@ class="grid-box" style="--grid-item-size:22rem; --grid-item-size-small-screens:19rem"> {#each data.templates as template} + {@const displayed = template.runtimes.slice(0, 2)} + {@const hidden = template.runtimes.slice(2, -1)}
    • @@ -164,7 +178,7 @@ {template.name}
        - {#each template.runtimes as runtime} + {#each displayed as runtime} {@const icon = getIconFromRuntime(runtime.name)} {#if icon}
      • @@ -179,6 +193,19 @@
      • {/if} {/each} + {#if hidden.length} +
      • + +
      • + {/if}
      diff --git a/src/routes/console/project-[project]/functions/templates/+page.ts b/src/routes/console/project-[project]/functions/templates/+page.ts index f344e2627..b4ae67288 100644 --- a/src/routes/console/project-[project]/functions/templates/+page.ts +++ b/src/routes/console/project-[project]/functions/templates/+page.ts @@ -40,7 +40,6 @@ export const load: PageLoad = async ({ url, route }) => { if (search) { return template.name.toLowerCase().includes(search.toLowerCase()); } else { - console.log(template.name); return true; } }); diff --git a/src/routes/console/project-[project]/functions/templates/template-[template]/+page.svelte b/src/routes/console/project-[project]/functions/templates/template-[template]/+page.svelte index 2d69a85dd..6fef4aa20 100644 --- a/src/routes/console/project-[project]/functions/templates/template-[template]/+page.svelte +++ b/src/routes/console/project-[project]/functions/templates/template-[template]/+page.svelte @@ -1,4 +1,5 @@ diff --git a/src/routes/console/project-[project]/settings/migrations/+page.ts b/src/routes/console/project-[project]/settings/migrations/+page.ts index 89af9aa91..66744827d 100644 --- a/src/routes/console/project-[project]/settings/migrations/+page.ts +++ b/src/routes/console/project-[project]/settings/migrations/+page.ts @@ -20,7 +20,6 @@ export async function load({ depends }) { try { const { migrations } = await sdk.forProject.migrations.list(); - console.log('migrations', migrations); return { migrations, firebaseProjects: getFirebaseProjects() diff --git a/static/logos/appwrite-full.svg b/static/logos/appwrite-full.svg new file mode 100644 index 000000000..aa591c949 --- /dev/null +++ b/static/logos/appwrite-full.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file