mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
fix: edge case when wizard is auto closed due to modal close;
improved: projects invalidation.
This commit is contained in:
1 parent
63811f566e
commit
bbf51f3ace
7 files changed
+37
-11
No files matched your search
@@ -12,6 +12,7 @@
|
||||
export let state: 'success' | 'warning' | 'error' | 'info' = null;
|
||||
export let error: string = null;
|
||||
export let closable = true;
|
||||
export let closeByEscape = true;
|
||||
export let headerDivider = true;
|
||||
export let onSubmit: (e: SubmitEvent) => Promise<void> | void = function () {
|
||||
return;
|
||||
@@ -32,7 +33,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<ModalWrapper bind:show {size} {headerDivider} let:close>
|
||||
<ModalWrapper bind:show {size} {headerDivider} {closeByEscape} let:close>
|
||||
<Form isModal {onSubmit}>
|
||||
<header class="modal-header">
|
||||
<div class="u-flex u-main-space-between u-cross-center u-gap-16">
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
export let show = false;
|
||||
export let size: 'small' | 'big' | 'huge' = null;
|
||||
export let closable = true;
|
||||
export let closeByEscape = true;
|
||||
export let headerDivider = true;
|
||||
export let style = '';
|
||||
|
||||
@@ -48,7 +49,7 @@
|
||||
}
|
||||
|
||||
function handleKeydown(event: KeyboardEvent) {
|
||||
if (event.key === 'Escape') {
|
||||
if (event.key === 'Escape' && closeByEscape) {
|
||||
event.preventDefault();
|
||||
trackEvent('click_close_modal', {
|
||||
from: 'escape'
|
||||
|
||||
+3
@@ -7,6 +7,7 @@
|
||||
import { createPlatform } from '../store';
|
||||
import { Submit, trackEvent } from '$lib/actions/analytics';
|
||||
import { PlatformType } from '@appwrite.io/console';
|
||||
import { invalidateDependencies } from '../skipped.svelte';
|
||||
|
||||
let platform: PlatformType = PlatformType.Appleios;
|
||||
|
||||
@@ -32,6 +33,8 @@
|
||||
|
||||
$createPlatform.$id = response.$id;
|
||||
$createPlatform.type = platform;
|
||||
|
||||
await invalidateDependencies();
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
+3
@@ -8,6 +8,7 @@
|
||||
import { Submit, trackEvent } from '$lib/actions/analytics';
|
||||
import { PlatformType } from '@appwrite.io/console';
|
||||
import { isValueOfStringEnum } from '$lib/helpers/types';
|
||||
import { invalidateDependencies } from '../skipped.svelte';
|
||||
|
||||
// enum Platform {
|
||||
// Android = 'flutter-android',
|
||||
@@ -103,6 +104,8 @@
|
||||
|
||||
$createPlatform.$id = response.$id;
|
||||
$createPlatform.type = platform;
|
||||
|
||||
await invalidateDependencies();
|
||||
}
|
||||
|
||||
$: registee = {
|
||||
|
||||
+3
@@ -8,6 +8,7 @@
|
||||
import { Submit, trackEvent } from '$lib/actions/analytics';
|
||||
import { PlatformType } from '@appwrite.io/console';
|
||||
import { isValueOfStringEnum } from '$lib/helpers/types';
|
||||
import { invalidateDependencies } from '../skipped.svelte';
|
||||
|
||||
let platform: PlatformType = isValueOfStringEnum(PlatformType, $createPlatform.type)
|
||||
? $createPlatform.type
|
||||
@@ -61,6 +62,8 @@
|
||||
|
||||
$createPlatform.$id = response.$id;
|
||||
$createPlatform.type = platform;
|
||||
|
||||
await invalidateDependencies();
|
||||
}
|
||||
|
||||
$: registee = {
|
||||
|
||||
+21
-9
@@ -1,21 +1,32 @@
|
||||
<script context="module" lang="ts">
|
||||
import { createPlatform } from './store';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { get, writable } from 'svelte/store';
|
||||
import { writable } from 'svelte/store';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
|
||||
const showSkippedModal = writable(false);
|
||||
const skippedModalOnSubmit = () => wizard.hide();
|
||||
|
||||
async function closeWizard() {
|
||||
wizard.hide();
|
||||
createPlatform.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Previously, data was updated after the wizard was closed,
|
||||
* this sometimes caused outdated data to be visible for a brief moment.
|
||||
*/
|
||||
export async function invalidateDependencies(): Promise<void> {
|
||||
console.log('invalidateDependencies');
|
||||
await Promise.all([invalidate(Dependencies.PROJECT), invalidate(Dependencies.PLATFORMS)]);
|
||||
}
|
||||
|
||||
export async function onPlatformSetupFinish(event: CustomEvent): Promise<void> {
|
||||
showSkippedModal.set(event.detail?.skipped ?? false);
|
||||
const isSkipped = event.detail?.skipped ?? false;
|
||||
showSkippedModal.set(isSkipped);
|
||||
|
||||
createPlatform.reset();
|
||||
await Promise.all([invalidate(Dependencies.PROJECT), invalidate(Dependencies.PLATFORMS)]);
|
||||
|
||||
if (!get(showSkippedModal)) {
|
||||
wizard.hide();
|
||||
if (!isSkipped) {
|
||||
await closeWizard();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -31,9 +42,10 @@
|
||||
|
||||
<Modal
|
||||
closable={false}
|
||||
closeByEscape={false}
|
||||
headerDivider={false}
|
||||
onSubmit={closeWizard}
|
||||
bind:show={$showSkippedModal}
|
||||
onSubmit={skippedModalOnSubmit}
|
||||
title="Skipping optional steps">
|
||||
<FormList>
|
||||
<p>
|
||||
|
||||
+3
@@ -8,6 +8,7 @@
|
||||
import { createPlatform } from '../store';
|
||||
import { Submit, trackEvent } from '$lib/actions/analytics';
|
||||
import { PlatformType } from '@appwrite.io/console';
|
||||
import { invalidateDependencies } from '../skipped.svelte';
|
||||
|
||||
const projectId = $page.params.project;
|
||||
const suggestions = ['*.vercel.app', '*.netlify.app', '*.gitpod.io'];
|
||||
@@ -40,6 +41,8 @@
|
||||
});
|
||||
|
||||
$createPlatform.$id = platform.$id;
|
||||
|
||||
await invalidateDependencies();
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in new issue
Block a user