Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: secondary wizards headers, fix execution modal not closing #1203

Merged
merged 3 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
run: pnpm exec playwright install --with-deps chromium
- name: E2E Tests
run: npm run e2e
run: pnpm run e2e
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
Expand Down
1 change: 0 additions & 1 deletion src/lib/layout/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ export { default as HeaderAlert } from './headerAlert.svelte';
export { default as ContainerButton } from './containerButton.svelte';
export { default as WizardSecondaryContainer } from './wizardSecondaryContainer.svelte';
export { default as WizardSecondaryContent } from './wizardSecondaryContent.svelte';
export { default as WizardSecondaryHeader } from './wizardSecondaryHeader.svelte';
export { default as WizardSecondaryFooter } from './wizardSecondaryFooter.svelte';
61 changes: 59 additions & 2 deletions src/lib/layout/wizardSecondaryContainer.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,70 @@
<script lang="ts">
import { trackEvent } from '$lib/actions/analytics';
import { Heading } from '$lib/components';
import { Button } from '$lib/elements/forms';
import WizardExitModal from './wizardExitModal.svelte';
import { goto } from '$app/navigation';

export let showExitModal = false;
export let href = '';
type $$Props =
| {
confirmExit: boolean;
showExitModal: boolean;
href?: string;
}
| {
confirmExit?: boolean;
showExitModal?: boolean;
href: string;
};

export let confirmExit: $$Props['confirmExit'] = false;
export let href: $$Props['href'] = '';
export let showExitModal: $$Props['showExitModal'] = false;

function handleKeydown(event: KeyboardEvent) {
if (event.key === 'Escape') {
event.preventDefault();
if (confirmExit) {
showExitModal = true;
} else {
goto(href);
trackEvent('wizard_exit', {
from: 'escape'
});
}
}
}
</script>

<svelte:window on:keydown={handleKeydown} />

<section class="wizard-secondary c-wizard-position">
<div class="wizard-secondary-container">
<header class="wizard-secondary-header">
<div class="u-flex u-main-space-between u-gap-32 u-cross-center">
<Heading size={5} tag="h1"><slot name="title" /></Heading>
<Button
text
round
ariaLabel="close modal"
href={confirmExit ? null : href}
on:click={() => {
if (confirmExit) {
showExitModal = true;
} else {
trackEvent('wizard_exit', {
from: 'button'
});
}
}}>
<span class="icon-x u-font-size-20" aria-hidden="true"></span>
</Button>
</div>
{#if $$slots.description}
<p class="body-text-2"><slot name="description" /></p>
{/if}
</header>

<slot />
</div>
</section>
Expand Down
61 changes: 0 additions & 61 deletions src/lib/layout/wizardSecondaryHeader.svelte

This file was deleted.

9 changes: 3 additions & 6 deletions src/routes/(console)/apply-credit/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import {
WizardSecondaryContainer,
WizardSecondaryContent,
WizardSecondaryFooter,
WizardSecondaryHeader
WizardSecondaryFooter
} from '$lib/layout';
import { type PaymentList } from '$lib/sdk/billing';
import { app } from '$lib/stores/app';
Expand Down Expand Up @@ -195,10 +194,8 @@
<title>Apply credits - Appwrite</title>
</svelte:head>

<WizardSecondaryContainer href={previousPage} bind:showExitModal>
<WizardSecondaryHeader confirmExit on:exit={() => (showExitModal = true)}>
Apply credits
</WizardSecondaryHeader>
<WizardSecondaryContainer href={previousPage} bind:showExitModal confirmExit>
<svelte:fragment slot="title">Apply credits</svelte:fragment>
<WizardSecondaryContent>
<Form bind:this={formComponent} onSubmit={handleSubmit} bind:isSubmitting>
<FormList>
Expand Down
9 changes: 3 additions & 6 deletions src/routes/(console)/create-organization/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
import {
WizardSecondaryContainer,
WizardSecondaryContent,
WizardSecondaryFooter,
WizardSecondaryHeader
WizardSecondaryFooter
} from '$lib/layout';
import type { Coupon, PaymentList } from '$lib/sdk/billing';
import { plansInfo, tierFree, tierPro, tierToPlan } from '$lib/stores/billing';
Expand Down Expand Up @@ -186,10 +185,8 @@
<title>Create organization - Appwrite</title>
</svelte:head>

<WizardSecondaryContainer bind:showExitModal href={previousPage}>
<WizardSecondaryHeader confirmExit on:exit={() => (showExitModal = true)}>
Create organization
</WizardSecondaryHeader>
<WizardSecondaryContainer bind:showExitModal href={previousPage} confirmExit>
<svelte:fragment slot="title">Create organization</svelte:fragment>
<WizardSecondaryContent>
<Form bind:this={formComponent} onSubmit={create} bind:isSubmitting>
<FormList>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
import {
WizardSecondaryContainer,
WizardSecondaryContent,
WizardSecondaryFooter,
WizardSecondaryHeader
WizardSecondaryFooter
} from '$lib/layout';
import { type Coupon, type PaymentList } from '$lib/sdk/billing';
import { plansInfo, tierFree, tierPro, tierToPlan, type Tier } from '$lib/stores/billing';
Expand Down Expand Up @@ -250,10 +249,8 @@
<title>Change plan - Appwrite</title>
</svelte:head>

<WizardSecondaryContainer bind:showExitModal href={previousPage}>
<WizardSecondaryHeader confirmExit on:exit={() => (showExitModal = true)}>
Change plan
</WizardSecondaryHeader>
<WizardSecondaryContainer bind:showExitModal href={previousPage} confirmExit>
<svelte:fragment slot="title">Change plan</svelte:fragment>
<WizardSecondaryContent>
<Form bind:this={formComponent} onSubmit={handleSubmit} bind:isSubmitting>
<Label class="label u-margin-block-start-16">Select plan</Label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
import {
WizardSecondaryContainer,
WizardSecondaryContent,
WizardSecondaryFooter,
WizardSecondaryHeader
WizardSecondaryFooter
} from '$lib/layout';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
Expand Down Expand Up @@ -145,8 +144,8 @@
<title>Execute function - Appwrite</title>
</svelte:head>

<WizardSecondaryContainer>
<WizardSecondaryHeader href={previousPage}>Execute function</WizardSecondaryHeader>
<WizardSecondaryContainer href={previousPage}>
<svelte:fragment slot="title">Execute Function</svelte:fragment>
<WizardSecondaryContent>
<Form bind:this={formComponent} onSubmit={handleSubmit} bind:isSubmitting>
<FormList>
Expand Down
Loading