From 11dd905231cb9ae774ff1782a2dc363a9734ba16 Mon Sep 17 00:00:00 2001 From: tglide <26071571+TGlide@users.noreply.github.com> Date: Thu, 13 Jul 2023 15:59:29 +0100 Subject: [PATCH] migrations stuff --- src/lib/commandCenter/commandCenter.svelte | 2 +- src/lib/components/migrationBox.svelte | 71 ++++- src/lib/helpers/array.ts | 7 + src/lib/layout/wizard.svelte | 13 +- src/lib/layout/wizardStep.svelte | 8 + src/lib/stores/migration.ts | 50 +++- src/lib/stores/wizard.ts | 11 +- .../project-[project]/settings/+layout.svelte | 15 +- .../settings/migrations/(import)/index.ts | 46 ++- .../settings/migrations/(import)/step1.svelte | 9 +- .../settings/migrations/(import)/step2.svelte | 278 ++++++++++-------- .../migrations/(import)/wizard.svelte | 6 +- .../settings/migrations/+page.ts | 4 - 13 files changed, 344 insertions(+), 176 deletions(-) diff --git a/src/lib/commandCenter/commandCenter.svelte b/src/lib/commandCenter/commandCenter.svelte index 6096827b7..c40eb0844 100644 --- a/src/lib/commandCenter/commandCenter.svelte +++ b/src/lib/commandCenter/commandCenter.svelte @@ -86,7 +86,7 @@ const handleKeydown = (e) => { if (!$subPanels.length) { - keys = [...keys, e.key].slice(-5); + keys = [...keys, e.key].slice(-10); resetKeys(); } $commandCenterKeyDownHandler(e); diff --git a/src/lib/components/migrationBox.svelte b/src/lib/components/migrationBox.svelte index 0bb8db815..8fc6c47a3 100644 --- a/src/lib/components/migrationBox.svelte +++ b/src/lib/components/migrationBox.svelte @@ -1,8 +1,68 @@ - -{#if show} + + +{#if $showMigrationBox && migration}

@@ -11,15 +71,14 @@

- 60% - 2 mins left + {percentage}%
Importing users... diff --git a/src/lib/helpers/array.ts b/src/lib/helpers/array.ts index 096d65d6f..903cb40ab 100644 --- a/src/lib/helpers/array.ts +++ b/src/lib/helpers/array.ts @@ -76,3 +76,10 @@ export function last(array: readonly T[]): T; export function last(array: readonly T[]): T | undefined { return at(array, -1); } + +export function excludeArray( + array: readonly T[], + exclude: readonly E[] +): Exclude[] { + return array.filter((item) => !exclude.includes(item as E)) as Exclude[]; +} diff --git a/src/lib/layout/wizard.svelte b/src/lib/layout/wizard.svelte index 72321a84b..4a0baff21 100644 --- a/src/lib/layout/wizard.svelte +++ b/src/lib/layout/wizard.svelte @@ -135,22 +135,19 @@ Skip optional steps {/if} + {#if currentStep === 1} - - {:else if isLastStep} - - {:else} - {/if} + +
diff --git a/src/lib/layout/wizardStep.svelte b/src/lib/layout/wizardStep.svelte index 73e50eeac..4ed953608 100644 --- a/src/lib/layout/wizardStep.svelte +++ b/src/lib/layout/wizardStep.svelte @@ -1,11 +1,19 @@ - + Select data
@@ -113,7 +139,7 @@

Transfer is free of charge

-

You won’t be charged for Appwrite bandwidth usage for importing data

+

You won't be charged for Appwrite bandwidth usage for importing data

@@ -130,124 +156,134 @@
    -
  • - -
    - Users - {#if report} - {report.user} - {/if} -
    -
    - Import all users + {#if resources.includes('user')} +
  • + +
    + Users -
      -
    • - -
      - Include teams - {#if report} - {report.team} - {/if} -
      -
      - Import all teams and the team memberships of your users -
    • -
    -
  • -
  • - -
    - Databases - {#if report} - {report.database} - {/if} -
    -
    - Import all databases, including collections, indexes and attributes + {report?.user ?? '...'} +
    +
    + Import all users -
      -
    • - -
      - Include documents - {#if report} - {report.document} - {/if} -
      -
      - Import all of your documents -
    • -
    -
  • -
  • - -
    - Functions - {#if report} - {report.function} + {#if resources.includes('team')} +
      +
    • + +
      + Include teams + {report?.team ?? '...'} +
      +
      + Import all teams and the team memberships of your users +
    • +
    {/if} -
    -
    - Import all functions and their active deployment -
      -
    • - -
      - Include environment variables -
      -
      - Import all environment variables -
    • -
    • - -
      - Include inactive deployments -
      -
      - Import all deployments that are not currently active -
    • -
    -
  • -
  • - -
    - Storage - {#if report} - {report.size.toFixed(2)}MB +
  • + {/if} + + {#if resources.includes('database')} +
  • + +
    + Databases + {report?.database ?? '...'} +
    +
    + Import all databases, including collections, indexes and attributes + + {#if resources.includes('document')} +
      +
    • + +
      + Include documents + {report?.document ?? '...'} +
      +
      + Import all of your documents +
    • +
    {/if} -
    -
    - {#if report} - Import all buckets ({report.bucket}) and files ({report.file}) - {:else} - Import all buckets and files - {/if} -
  • + + {/if} + + {#if resources.includes('function')} +
  • + +
    + Functions + {report?.function ?? '...'} +
    +
    + Import all functions and their active deployment +
      + {#if resources.includes('envVar')} +
    • + +
      + Include environment variables +
      +
      + Import all environment variables +
    • + {/if} + {#if resources.includes('deployment')} +
    • + +
      + Include inactive deployments +
      +
      + Import all deployments that are not currently active +
    • + {/if} +
    +
  • + {/if} + {#if resources.includes('bucket') && resources.includes('file')} +
  • + +
    + Storage + + {report?.size ? `${report.size.toFixed(2)}MB` : '...'} + +
    +
    + + + Import all buckets {report?.bucket ?? '...'} and + files + {report?.file ?? '...'} + +
  • + {/if}
diff --git a/src/routes/console/project-[project]/settings/migrations/(import)/wizard.svelte b/src/routes/console/project-[project]/settings/migrations/(import)/wizard.svelte index 60e7a1d36..804a17e0c 100644 --- a/src/routes/console/project-[project]/settings/migrations/(import)/wizard.svelte +++ b/src/routes/console/project-[project]/settings/migrations/(import)/wizard.svelte @@ -11,6 +11,7 @@ import { Dependencies } from '$lib/constants'; import { migrationFormToResources } from '$lib/stores/migration'; import { started } from '../stores'; + import { showMigrationBox } from '$lib/components/migrationBox.svelte'; const onExit = () => { resetImportStores(); @@ -61,8 +62,7 @@ $provider.adminSecret, $provider.database, $provider.username, - $provider.password, - $provider.port + $provider.password ); console.log('nhost', res); invalidate(Dependencies.MIGRATIONS); @@ -72,6 +72,8 @@ resetImportStores(); wizard.hide(); started.set(performance.now()); + + showMigrationBox.set(true); }; onDestroy(onExit); diff --git a/src/routes/console/project-[project]/settings/migrations/+page.ts b/src/routes/console/project-[project]/settings/migrations/+page.ts index 7ac0a5e33..175b12dc6 100644 --- a/src/routes/console/project-[project]/settings/migrations/+page.ts +++ b/src/routes/console/project-[project]/settings/migrations/+page.ts @@ -1,15 +1,11 @@ import { Dependencies } from '$lib/constants.js'; import { sdk } from '$lib/stores/sdk'; -import { get } from 'svelte/store'; -import { started } from './stores.js'; export async function load({ depends }) { depends(Dependencies.MIGRATIONS); const { migrations } = await sdk.forProject.migrations.list(); - console.log(migrations, (performance.now() - get(started)) / 1000); - return { migrations };