Skip to content

Commit ccf429e

Browse files
used Modal in the delete project
1 parent e67e741 commit ccf429e

File tree

2 files changed

+70
-51
lines changed

2 files changed

+70
-51
lines changed

src/lib/components/confirm.svelte

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<script lang="ts">
2-
import { Button, InputCheckbox } from '$lib/elements/forms';
3-
import { Layout } from '@appwrite.io/pink-svelte';
4-
import { Modal } from '.';
2+
import { Button, Form, InputCheckbox } from '$lib/elements/forms';
3+
import { Alert, Dialog, Layout } from '@appwrite.io/pink-svelte';
4+
55
export let open: boolean;
66
export let title: string;
77
export let error: string = null;
88
export let action: string = 'Delete';
9+
export let canDelete: boolean = true;
910
export let disabled: boolean = false;
1011
export let submissionLoader = false;
1112
export let confirmDeletion: boolean = false;
@@ -22,34 +23,48 @@
2223
}
2324
</script>
2425

25-
<Modal size="s" bind:show={open} {title} {onSubmit} bind:error>
26-
<svelte:fragment slot="description">
27-
{#if confirmDeletion}
28-
This action is irreversible. Please confirm to proceed.
29-
{/if}
30-
</svelte:fragment>
26+
<Form isModal {onSubmit}>
27+
<Dialog {title} bind:open>
28+
<Layout.Stack gap="xl">
29+
{#if error}
30+
<Alert.Inline
31+
dismissible
32+
status="error"
33+
on:dismiss={() => {
34+
error = null;
35+
}}>
36+
{error}
37+
</Alert.Inline>
38+
{/if}
3139

32-
<Layout.Stack gap="l">
33-
<slot />
40+
<Layout.Stack gap="l">
41+
<slot />
3442

35-
{#if confirmDeletion}
36-
<InputCheckbox
37-
size="s"
38-
required
39-
id={checkboxId}
40-
bind:checked={confirm}
41-
label="I understand and confirm" />
42-
{/if}
43-
</Layout.Stack>
43+
{#if confirmDeletion}
44+
<InputCheckbox
45+
size="s"
46+
required
47+
id={checkboxId}
48+
bind:checked={confirm}
49+
label="I understand and confirm" />
50+
{/if}
51+
</Layout.Stack>
52+
</Layout.Stack>
4453

45-
<svelte:fragment slot="footer">
46-
<Button text on:click={() => (open = false)}>Cancel</Button>
47-
<Button
48-
danger
49-
submit
50-
{submissionLoader}
51-
disabled={disabled || (confirmDeletion ? !confirm : false)}>
52-
{action}
53-
</Button>
54-
</svelte:fragment>
55-
</Modal>
54+
<svelte:fragment slot="footer">
55+
<Layout.Stack direction="row" gap="s" justifyContent="flex-end">
56+
<slot name="footer">
57+
<Button text on:click={() => (open = false)}>Cancel</Button>
58+
{#if canDelete}
59+
<Button
60+
danger
61+
submit
62+
{submissionLoader}
63+
disabled={disabled || (confirmDeletion ? !confirm : false)}
64+
>{action}</Button>
65+
{/if}
66+
</slot>
67+
</Layout.Stack>
68+
</svelte:fragment>
69+
</Dialog>
70+
</Form>

src/routes/(console)/project-[region]-[project]/settings/deleteProject.svelte

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<script lang="ts">
22
import { goto, invalidate } from '$app/navigation';
33
import { base } from '$app/paths';
4+
import { Layout } from '@appwrite.io/pink-svelte';
45
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
5-
import { BoxAvatar, Confirm, CardGrid } from '$lib/components';
6+
import { BoxAvatar, CardGrid } from '$lib/components';
67
import { Button, InputText } from '$lib/elements/forms';
78
import { toLocaleDateTime } from '$lib/helpers/date';
89
import { addNotification } from '$lib/stores/notifications';
@@ -11,7 +12,7 @@
1112
import { project, projectRegion } from '../store';
1213
import { organization } from '$lib/stores/organization';
1314
import { Dependencies } from '$lib/constants';
14-
15+
import Modal from '$lib/components/modal.svelte';
1516
let error: string;
1617
let showDelete = false;
1718
let name: string = null;
@@ -62,21 +63,24 @@
6263
</svelte:fragment>
6364
</CardGrid>
6465

65-
<Confirm
66-
disabled={name !== $project.name}
67-
onSubmit={handleDelete}
68-
title="Delete project"
69-
bind:open={showDelete}
70-
bind:error>
71-
<p>
72-
<b>This project will be deleted</b>, along with all of its metadata, stats, and other
73-
resources. <b>This action is irreversible</b>.
74-
</p>
75-
<InputText
76-
label={`Enter "${$project.name}" to continue`}
77-
placeholder="Enter name"
78-
id="project-name"
79-
autofocus
80-
required
81-
bind:value={name} />
82-
</Confirm>
66+
<Modal size="s" bind:show={showDelete} title="Delete project" onSubmit={handleDelete} bind:error>
67+
<svelte:fragment slot="description">
68+
This project will be deleted along with all of its metadata, stats, and other resources.
69+
<b>This action is irreversible.</b>
70+
</svelte:fragment>
71+
72+
<Layout.Stack gap="l">
73+
<InputText
74+
label={`Enter "${$project.name}" to continue`}
75+
placeholder="Enter name"
76+
id="project-name"
77+
autofocus
78+
required
79+
bind:value={name} />
80+
</Layout.Stack>
81+
82+
<svelte:fragment slot="footer">
83+
<Button text on:click={() => (showDelete = false)}>Cancel</Button>
84+
<Button danger submit disabled={name !== $project.name}>Delete</Button>
85+
</svelte:fragment>
86+
</Modal>

0 commit comments

Comments
 (0)