Skip to content

Commit 56a5901

Browse files
committed
done some ui changes and addressed comments
1 parent 35808ed commit 56a5901

File tree

3 files changed

+81
-28
lines changed

3 files changed

+81
-28
lines changed

src/lib/stores/project-services.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ function projectServiceRows(project: Models.Project | null): Service[] {
5959
method: ServiceId.Project,
6060
value: project?.serviceStatusForProject ?? null
6161
},
62-
{
63-
label: 'Proxy',
64-
method: ServiceId.Proxy,
65-
value: project?.serviceStatusForProxy ?? null
66-
},
62+
// @todo Re-enable when Proxy is ready for public release.
63+
// {
64+
// label: 'Proxy',
65+
// method: ServiceId.Proxy,
66+
// value: project?.serviceStatusForProxy ?? null
67+
// },
6768
{
6869
label: 'Sites',
6970
method: ServiceId.Sites,
@@ -75,7 +76,7 @@ function projectServiceRows(project: Models.Project | null): Service[] {
7576
value: project?.serviceStatusForStorage ?? null
7677
},
7778
{
78-
label: 'Tables',
79+
label: 'TablesDB',
7980
method: ServiceId.Tablesdb,
8081
value: project?.serviceStatusForTablesdb ?? null
8182
},
@@ -88,12 +89,13 @@ function projectServiceRows(project: Models.Project | null): Service[] {
8889
label: 'Users',
8990
method: ServiceId.Users,
9091
value: project?.serviceStatusForUsers ?? null
91-
},
92-
{
93-
label: 'VCS',
94-
method: ServiceId.Vcs,
95-
value: project?.serviceStatusForVcs ?? null
9692
}
93+
// @todo Re-enable when VCS is ready for public release.
94+
// {
95+
// label: 'VCS',
96+
// method: ServiceId.Vcs,
97+
// value: project?.serviceStatusForVcs ?? null
98+
// }
9799
];
98100

99101
return rows.sort((a, b) => a.label.localeCompare(b.label));

src/routes/(console)/project-[region]-[project]/settings/webhooks/[webhook]/regenerate.svelte

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,47 @@
22
import { invalidate } from '$app/navigation';
33
import { page } from '$app/state';
44
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
5-
import Confirm from '$lib/components/confirm.svelte';
5+
import Modal from '$lib/components/modal.svelte';
6+
import { Secret } from '$lib/components';
67
import { Dependencies } from '$lib/constants';
8+
import { Button, InputPassword } from '$lib/elements/forms';
79
import { addNotification } from '$lib/stores/notifications';
810
import { sdk } from '$lib/stores/sdk';
9-
import { webhook } from './store';
11+
import { Layout, Typography } from '@appwrite.io/pink-svelte';
12+
import type { Models } from '@appwrite.io/console';
13+
import { get } from 'svelte/store';
14+
import { webhook as webhookStore } from './store';
15+
16+
type WebhooksWithCustomSecret = {
17+
updateSecret(params: { webhookId: string; secret?: string }): Promise<Models.Webhook>;
18+
};
1019
1120
export let show = false;
21+
1222
const projectId = page.params.project;
23+
let secret = '';
24+
let revealedSecret = '';
25+
26+
$: if (!show) {
27+
secret = '';
28+
revealedSecret = '';
29+
}
1330
1431
async function regenerate() {
1532
try {
16-
await sdk.forProject(page.params.region, projectId).webhooks.updateSecret({
17-
webhookId: $webhook.$id
33+
const currentWebhook = get(webhookStore);
34+
const customSecret = secret.trim();
35+
const updatedWebhook = await (
36+
sdk.forProject(page.params.region, projectId).webhooks as WebhooksWithCustomSecret
37+
).updateSecret({
38+
webhookId: currentWebhook.$id,
39+
secret: customSecret || undefined
1840
});
1941
await invalidate(Dependencies.WEBHOOK);
20-
show = false;
42+
revealedSecret = customSecret || updatedWebhook.secret;
2143
addNotification({
2244
type: 'success',
23-
message: 'Key has been regenerated'
45+
message: customSecret ? 'Key has been updated' : 'Key has been regenerated'
2446
});
2547
trackEvent(Submit.WebhookUpdateSignature);
2648
} catch (error) {
@@ -33,7 +55,37 @@
3355
}
3456
</script>
3557

36-
<Confirm title="Regenerate Key" bind:open={show} onSubmit={regenerate} action="Regenerate">
37-
Are you sure you want to generate a new Signature key?
38-
<b>You will not be able to recover the current key.</b>
39-
</Confirm>
58+
<Modal title="Update Key" bind:show onSubmit={regenerate}>
59+
<Layout.Stack gap="l">
60+
{#if revealedSecret}
61+
<Typography.Text>
62+
Copy this signature key now. For security reasons, you will not be able to view it
63+
again after closing this dialog.
64+
</Typography.Text>
65+
<Secret label="Key" copyEvent="signature" bind:value={revealedSecret} />
66+
{:else}
67+
<Typography.Text>
68+
Enter a custom signing key, or leave the field empty to generate a new one.
69+
</Typography.Text>
70+
<Typography.Text variant="m-400">
71+
You will not be able to recover the current key after this change.
72+
</Typography.Text>
73+
<InputPassword
74+
id="webhook-secret"
75+
label="Custom key"
76+
placeholder="Leave empty to auto-generate"
77+
minlength={0}
78+
autocomplete
79+
bind:value={secret} />
80+
{/if}
81+
</Layout.Stack>
82+
83+
<svelte:fragment slot="footer">
84+
{#if revealedSecret}
85+
<Button on:click={() => (show = false)}>Done</Button>
86+
{:else}
87+
<Button text on:click={() => (show = false)}>Cancel</Button>
88+
<Button submit>{secret.trim() ? 'Update key' : 'Regenerate key'}</Button>
89+
{/if}
90+
</svelte:fragment>
91+
</Modal>

src/routes/(console)/project-[region]-[project]/settings/webhooks/[webhook]/updateSignature.svelte

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<script lang="ts">
2-
import { CardGrid, Secret } from '$lib/components';
2+
import { CardGrid } from '$lib/components';
33
import { Button } from '$lib/elements/forms';
4-
import { Link } from '@appwrite.io/pink-svelte';
4+
import { Alert, Link } from '@appwrite.io/pink-svelte';
55
import Regenerate from './regenerate.svelte';
6-
import { webhook } from './store';
76
import { Click, trackEvent } from '$lib/actions/analytics';
87
98
let showRegenerate = false;
@@ -18,9 +17,9 @@
1817
rel="noopener noreferrer"
1918
class="link">Learn more</Link.Anchor>
2019
<svelte:fragment slot="aside">
21-
<div>
22-
<Secret label="Key" copyEvent="signature" bind:value={$webhook.secret} />
23-
</div>
20+
<Alert.Inline status="info">
21+
The signature key is only shown once after it is created or updated.
22+
</Alert.Inline>
2423
</svelte:fragment>
2524
<svelte:fragment slot="actions">
2625
<Button
@@ -29,7 +28,7 @@
2928
trackEvent(Click.SettingsWebhookUpdateSignatureClick);
3029
}}
3130
secondary
32-
submit>Regenerate key</Button>
31+
submit>Update key</Button>
3332
</svelte:fragment>
3433
</CardGrid>
3534

0 commit comments

Comments
 (0)