|
1 | 1 | <script lang="ts"> |
2 | 2 | import { base } from '$app/paths'; |
3 | 3 | import { page } from '$app/state'; |
| 4 | + import Modal from '$lib/components/modal.svelte'; |
| 5 | + import { Secret } from '$lib/components'; |
4 | 6 | import { Wizard } from '$lib/layout'; |
5 | | - import { Layout } from '@appwrite.io/pink-svelte'; |
| 7 | + import { Layout, Typography } from '@appwrite.io/pink-svelte'; |
6 | 8 | import Form from '$lib/elements/forms/form.svelte'; |
7 | 9 | import { goto } from '$app/navigation'; |
8 | 10 | import { ID } from '@appwrite.io/console'; |
|
15 | 17 | import Button from '$lib/elements/forms/button.svelte'; |
16 | 18 |
|
17 | 19 | let showExitModal = false; |
| 20 | + let showSecretModal = false; |
| 21 | + let createdWebhookId = ''; |
| 22 | + let createdSecret = ''; |
18 | 23 |
|
19 | 24 | let name = '', |
20 | 25 | events: string[] = [], |
|
24 | 29 | authPassword = ''; |
25 | 30 |
|
26 | 31 | export let data; |
| 32 | +
|
| 33 | + async function openWebhook() { |
| 34 | + showSecretModal = false; |
| 35 | + if (!createdWebhookId) return; |
| 36 | +
|
| 37 | + await goto( |
| 38 | + `${base}/project-${page.params.region}-${page.params.project}/settings/webhooks/${createdWebhookId}` |
| 39 | + ); |
| 40 | + } |
| 41 | +
|
27 | 42 | async function create() { |
28 | 43 | try { |
29 | 44 | const webhook = await sdk |
|
45 | 60 | trackEvent(Submit.WebhookCreate, { |
46 | 61 | events: events |
47 | 62 | }); |
48 | | - goto( |
49 | | - `${base}/project-${page.params.region}-${page.params.project}/settings/webhooks/${webhook.$id}` |
50 | | - ); |
| 63 | +
|
| 64 | + createdWebhookId = webhook.$id; |
| 65 | + createdSecret = webhook.secret; |
| 66 | +
|
| 67 | + if (createdSecret) { |
| 68 | + showSecretModal = true; |
| 69 | + return; |
| 70 | + } |
| 71 | +
|
| 72 | + await openWebhook(); |
51 | 73 | } catch (error) { |
52 | 74 | addNotification({ |
53 | 75 | type: 'error', |
|
76 | 98 | </svelte:fragment> |
77 | 99 | </Wizard> |
78 | 100 | </Form> |
| 101 | + |
| 102 | +<Modal title="Webhook Created" bind:show={showSecretModal} onSubmit={openWebhook}> |
| 103 | + <Layout.Stack gap="l"> |
| 104 | + <Typography.Text> |
| 105 | + Copy this signing secret now. For security reasons, you will not be able to view it |
| 106 | + again after closing this dialog. |
| 107 | + </Typography.Text> |
| 108 | + <Secret label="Secret" copyEvent="signature" bind:value={createdSecret} /> |
| 109 | + </Layout.Stack> |
| 110 | + |
| 111 | + <svelte:fragment slot="footer"> |
| 112 | + <Button submit>Continue</Button> |
| 113 | + </svelte:fragment> |
| 114 | +</Modal> |
0 commit comments