From a5762f432da38a6ce2846fd783ab93484543cdae Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 31 Oct 2022 11:27:10 +0100 Subject: [PATCH 01/12] miscellaneous fixes --- src/lib/components/cardContainer.svelte | 2 +- src/lib/components/emptySearch.svelte | 4 +- src/lib/components/permissions/actions.svelte | 6 +- src/lib/components/permissions/index.ts | 1 + .../components/permissions/permissions.svelte | 138 ++++++++-------- src/lib/components/permissions/roles.svelte | 97 +++++++---- src/lib/components/permissions/team.svelte | 134 +++++++++------ src/lib/components/permissions/user.svelte | 154 ++++++++++++------ src/lib/elements/forms/inputCron.svelte | 3 + src/lib/elements/table/rowButton.svelte | 10 +- src/lib/layout/logs.svelte | 9 + .../authentication/user-[user]/+page.svelte | 1 + .../database-[database]/settings/+page.svelte | 2 +- .../functions/createFunction.svelte | 9 +- .../function-[function]/[[page]]/+page.svelte | 2 +- .../function-[function]/settings/+page.svelte | 6 +- .../functions/wizard/step2.svelte | 6 +- .../functions/wizard/step3.svelte | 2 +- .../functions/wizard/step4.svelte | 2 +- .../functions/wizard/step5.svelte | 2 +- .../project-[project]/overview/+layout.svelte | 27 ++- .../overview/platforms/+page.svelte | 29 +++- .../settings/webhooks/wizard/step3.svelte | 2 +- static/icons/dark/grayscale/code.svg | 1 + static/icons/light/grayscale/code.svg | 1 + 25 files changed, 422 insertions(+), 228 deletions(-) create mode 100644 static/icons/dark/grayscale/code.svg create mode 100644 static/icons/light/grayscale/code.svg diff --git a/src/lib/components/cardContainer.svelte b/src/lib/components/cardContainer.svelte index 5ba3ee68b..835ced4d6 100644 --- a/src/lib/components/cardContainer.svelte +++ b/src/lib/components/cardContainer.svelte @@ -12,7 +12,7 @@ style={`--grid-gap:1.5rem; --grid-item-size:${total > 3 ? '22rem' : '25rem'};`}> - {#if limit + offset > total && (total % 2 !== 0 || total % 4 === 0)} + {#if total > 3 ? total < limit + offset : total % 2 !== 0} diff --git a/src/lib/components/emptySearch.svelte b/src/lib/components/emptySearch.svelte index 8034da844..b0c54e647 100644 --- a/src/lib/components/emptySearch.svelte +++ b/src/lib/components/emptySearch.svelte @@ -3,6 +3,8 @@ import Light from '$lib/images/search-light.svg'; import Dark from '$lib/images/search-dark.svg'; import PaginationInline from './paginationInline.svelte'; + + export let hidePages = false;
@@ -18,5 +20,5 @@

Total results: 0

- +
diff --git a/src/lib/components/permissions/actions.svelte b/src/lib/components/permissions/actions.svelte index 9f2022e80..d97edeffd 100644 --- a/src/lib/components/permissions/actions.svelte +++ b/src/lib/components/permissions/actions.svelte @@ -1,6 +1,5 @@ - + dispatch('create', ['any'])}> Any diff --git a/src/lib/components/permissions/index.ts b/src/lib/components/permissions/index.ts index 01de280d9..cd32ba0ea 100644 --- a/src/lib/components/permissions/index.ts +++ b/src/lib/components/permissions/index.ts @@ -1,3 +1,4 @@ export { default as Permissions } from './permissions.svelte'; +export { default as Roles } from './roles.svelte'; export { default as Team } from './team.svelte'; export { default as User } from './user.svelte'; diff --git a/src/lib/components/permissions/permissions.svelte b/src/lib/components/permissions/permissions.svelte index 67d7c7c63..b9d9ea7f6 100644 --- a/src/lib/components/permissions/permissions.svelte +++ b/src/lib/components/permissions/permissions.svelte @@ -10,26 +10,23 @@ {#if [...$groups]?.length} Role - {#if withCrud} - {#if withCreate} - Create - {/if} - Read - Update - Delete + {#if withCreate} + Create {/if} + Read + Update + Delete {#each [...$groups].sort(sortRoles) as [role, permission]} - + - + - {#if withCrud} - {#if withCreate} - - togglePermission(role, 'create')} /> - - {/if} - + {#if withCreate} + togglePermission(role, 'read')} /> - - - togglePermission(role, 'update')} /> - - - togglePermission(role, 'delete')} /> + aria-label="Create" + checked={permission.create} + on:change={() => togglePermission(role, 'create')} /> {/if} + + togglePermission(role, 'read')} /> + + + togglePermission(role, 'update')} /> + + + togglePermission(role, 'delete')} /> +
@@ -231,18 +213,38 @@ {/each}
+ + + + {:else} - ROLE - - (showDropdown = !showDropdown)}> - Add a role to get started - +
+
+
+ + + +
+
+ Add a role to get started +
+
+
{/if} - - diff --git a/src/lib/components/permissions/roles.svelte b/src/lib/components/permissions/roles.svelte index 81fe38ced..62f5aeed2 100644 --- a/src/lib/components/permissions/roles.svelte +++ b/src/lib/components/permissions/roles.svelte @@ -1,7 +1,9 @@ - - - Role - - - - {#each [...$groups.keys()] as role} - - - - - -
- -
-
-
- {/each} -
-
- - +{#if roles?.length} + + + Role + + + + {#each [...$groups.keys()] as role} + + + + + +
+ +
+
+
+ {/each} +
+
+ + + +{:else} +
+
+
+ + + +
+
+ Add a role to get started +
+
+
+{/if} diff --git a/src/lib/components/permissions/team.svelte b/src/lib/components/permissions/team.svelte index 073acd082..79434e101 100644 --- a/src/lib/components/permissions/team.svelte +++ b/src/lib/components/permissions/team.svelte @@ -1,9 +1,9 @@ - - Select teams - - {#if results?.teams} -
- - - {#each results.teams as team (team.$id)} - {@const role = `team:${team.$id}`} - {@const exists = $groups.has(role)} - - - - - {/each} - -
- onSelection(event, role)} /> - - -
-
- {/if} -
-

Total results: {results?.total}

- -
- - - -
+{#if show} +
+ + Select teams + + {#if results?.teams?.length} +
+ + + {#each results.teams as team (team.$id)} + {@const role = `team:${team.$id}`} + {@const exists = $groups.has(role)} + + + + + {/each} + +
+ onSelection(event, role)} /> + + +
+
+
+

Total results: {results?.total}

+ +
+ {:else if search} + +
+
+ Sorry we couldn't find "{search}" +

There are no Teams that match your search.

+
+
+ + +
+
+
+ {:else} + +
+
+ Sorry we couldn't find "{search}" + +

You have no Teams. Create a user to see them here.

+

+ Need a hand? Check out our + documentation. +

+
+
+
+ {/if} + + + + +
+
+{/if} diff --git a/src/lib/components/permissions/user.svelte b/src/lib/components/permissions/user.svelte index 30a83fcb3..fd7c43670 100644 --- a/src/lib/components/permissions/user.svelte +++ b/src/lib/components/permissions/user.svelte @@ -1,7 +1,7 @@ - - Select users - - {#if results?.users} -
- - - {#each results.users as user (user.$id)} - {@const role = `user:${user.$id}`} - {@const exists = $groups.has(role)} - - - - - {/each} - -
- onSelection(event, role)} /> - - -
-
- {/if} -
-

Total results: {results?.total}

- -
- - - -
+
+ + Select users + + {#if results?.users?.length} +
+ + + {#each results.users as user (user.$id)} + {@const role = `user:${user.$id}`} + {@const exists = $groups.has(role)} + + + + + {/each} + +
+ onSelection(event, role)} /> + + +
+
+
+

Total results: {results?.total}

+ +
+ {:else if search} + +
+
+ Sorry we couldn't find "{search}" +

There are no Users that match your search.

+
+
+ + +
+
+
+ {:else} + +
+
+ Sorry we couldn't find "{search}" + +

You have no Users. Create a user to see them here.

+

+ Need a hand? Check out our + documentation. +

+
+
+
+ {/if} + + + + +
+
diff --git a/src/lib/elements/forms/inputCron.svelte b/src/lib/elements/forms/inputCron.svelte index b7a2e7c1d..d11e07c0b 100644 --- a/src/lib/elements/forms/inputCron.svelte +++ b/src/lib/elements/forms/inputCron.svelte @@ -18,6 +18,8 @@ let element: HTMLInputElement; let error: string; + const pattern = String.raw`^[^]+\s+[^]+\s+[^]+\s+[^]+\s+[^]`; + onMount(() => { if (element && autofocus) { element.focus(); @@ -57,6 +59,7 @@ {maxlength} {readonly} {step} + {pattern} type="text" class="input-text" bind:value diff --git a/src/lib/elements/table/rowButton.svelte b/src/lib/elements/table/rowButton.svelte index f7b75a96a..63617b5aa 100644 --- a/src/lib/elements/table/rowButton.svelte +++ b/src/lib/elements/table/rowButton.svelte @@ -2,6 +2,12 @@ import { clickOnEnter } from '$lib/helpers/a11y'; -
+ + -
+ diff --git a/src/lib/layout/logs.svelte b/src/lib/layout/logs.svelte index 70a71c273..7b9c14fa5 100644 --- a/src/lib/layout/logs.svelte +++ b/src/lib/layout/logs.svelte @@ -35,8 +35,17 @@ .getElementsByClassName('code-panel-content')[0] .scrollTo({ top: 0, left: 0, behavior: 'smooth' }); } + + function handleKeydown(event: KeyboardEvent) { + if (event.key === 'Escape') { + event.preventDefault(); + $log.show = false; + } + } + + {#if $log.data}
diff --git a/src/routes/console/project-[project]/authentication/user-[user]/+page.svelte b/src/routes/console/project-[project]/authentication/user-[user]/+page.svelte index 11a18313d..89e53cee1 100644 --- a/src/routes/console/project-[project]/authentication/user-[user]/+page.svelte +++ b/src/routes/console/project-[project]/authentication/user-[user]/+page.svelte @@ -420,6 +420,7 @@ {/if} + - {:else if search} - -
-
- Sorry we couldn't find "{search}" -

There are no Teams that match your search.

-
-
- - -
-
-
- {:else} - -
-
- Sorry we couldn't find "{search}" +
+ + {:else} + +
+
+ Sorry we couldn't find "{search}" -

You have no Teams. Create a user to see them here.

-

- Need a hand? Check out our - documentation. -

-
-
-
- {/if} +

You have no Teams. Create a user to see them here.

+

+ Need a hand? Check out our + documentation. +

+
+ +
+ {/if} - - - - - -{/if} + + + + diff --git a/src/lib/components/permissions/user.svelte b/src/lib/components/permissions/user.svelte index fd7c43670..a01e85f1e 100644 --- a/src/lib/components/permissions/user.svelte +++ b/src/lib/components/permissions/user.svelte @@ -1,5 +1,5 @@ -
- - Select users - - {#if results?.users?.length} -
- - - {#each results.users as user (user.$id)} - {@const role = `user:${user.$id}`} - {@const exists = $groups.has(role)} - - - + + {/each} + +
- onSelection(event, role)} /> - -
+
+
+

Total results: {results?.total}

+ +
+ {:else if search} + +
+
+ Sorry we couldn't find "{search}" +

There are no Users that match your search.

- - {:else} - -
-
- Sorry we couldn't find "{search}" - -

You have no Users. Create a user to see them here.

-

- Need a hand? Check out our - documentation. -

-
+
+ +
- - {/if} +
+
+ {:else} + +
+
+ Sorry we couldn't find "{search}" - - - - - +

You have no Users. Create a user to see them here.

+

+ Need a hand? Check out our + documentation. +

+
+
+
+ {/if} + + + + + diff --git a/src/lib/layout/wizard.svelte b/src/lib/layout/wizard.svelte index 40871db40..c805a6d01 100644 --- a/src/lib/layout/wizard.svelte +++ b/src/lib/layout/wizard.svelte @@ -28,13 +28,8 @@ let showExitModal = false; function handleKeydown(event: KeyboardEvent) { - const dialogArray = document.getElementsByTagName['dialog']; - let isModalOpen = false; - dialogArray?.forEach((dialog: HTMLDialogElement) => { - if (dialog.open) { - isModalOpen = true; - } - }); + const isModalOpen = document.querySelectorAll('dialog[open]'); + if (event.key === 'Escape' && !showExitModal && isModalOpen) { event.preventDefault(); dispatch('exit'); diff --git a/src/routes/console/project-[project]/functions/createFunction.svelte b/src/routes/console/project-[project]/functions/createFunction.svelte index 07f00c7fb..9030bb5c2 100644 --- a/src/routes/console/project-[project]/functions/createFunction.svelte +++ b/src/routes/console/project-[project]/functions/createFunction.svelte @@ -37,7 +37,7 @@ await sdkForProject.functions.createVariable(response.$id, v.key, v.value) ); await invalidate(Dependencies.FUNCTIONS); - await goto(`${base}/console/project-${projectId}/functions/function/${response.$id}`); + goto(`${base}/console/project-${projectId}/functions/function-${response.$id}`); addNotification({ message: 'Function has been created', diff --git a/src/routes/console/project-[project]/functions/wizard/step1.svelte b/src/routes/console/project-[project]/functions/wizard/step1.svelte index 93ac297e8..2701dadec 100644 --- a/src/routes/console/project-[project]/functions/wizard/step1.svelte +++ b/src/routes/console/project-[project]/functions/wizard/step1.svelte @@ -14,7 +14,7 @@ onMount(async () => { let runtimes = await sdkForProject.functions.listRuntimes(); options = runtimes.runtimes.map((runtime) => ({ - label: runtime.name, + label: `${runtime.name} - ${runtime.version}`, value: runtime.$id })); }); From 84fd57e7e68b86deac93aa440185735be0aaeb2c Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 31 Oct 2022 15:28:08 +0100 Subject: [PATCH 04/12] fix: small fix to dialog --- src/lib/layout/wizard.svelte | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lib/layout/wizard.svelte b/src/lib/layout/wizard.svelte index c805a6d01..6ca867e00 100644 --- a/src/lib/layout/wizard.svelte +++ b/src/lib/layout/wizard.svelte @@ -28,9 +28,8 @@ let showExitModal = false; function handleKeydown(event: KeyboardEvent) { - const isModalOpen = document.querySelectorAll('dialog[open]'); - - if (event.key === 'Escape' && !showExitModal && isModalOpen) { + const openDialog = document.querySelectorAll('dialog[open]'); + if (event.key === 'Escape' && !showExitModal && !openDialog?.length) { event.preventDefault(); dispatch('exit'); wizard.hide(); From 694a8cff84199e0460c028dca05228c8ab47b67d Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 2 Nov 2022 10:50:34 +0100 Subject: [PATCH 05/12] fix: inner modal --- src/lib/components/innerModal.svelte | 48 +++++++++++-------- .../functions/wizard/step1.svelte | 24 +++++----- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/src/lib/components/innerModal.svelte b/src/lib/components/innerModal.svelte index 384880389..96b170423 100644 --- a/src/lib/components/innerModal.svelte +++ b/src/lib/components/innerModal.svelte @@ -1,27 +1,33 @@ {#if show} - + + + {/if} diff --git a/src/routes/console/project-[project]/functions/wizard/step1.svelte b/src/routes/console/project-[project]/functions/wizard/step1.svelte index 2701dadec..6067d9af7 100644 --- a/src/routes/console/project-[project]/functions/wizard/step1.svelte +++ b/src/routes/console/project-[project]/functions/wizard/step1.svelte @@ -39,18 +39,16 @@ {options} required /> -
    - {#if !showCustomId} -
    - (showCustomId = !showCustomId)}> - -
    - {:else} - - {/if} -
+ {#if !showCustomId} +
+ (showCustomId = !showCustomId)}> + +
+ {:else} + + {/if} From a4611b78b8817c810c8cf456076d72f3acff713c Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 2 Nov 2022 11:09:58 +0100 Subject: [PATCH 06/12] fix: can't add vars with same key name --- .../project-[project]/functions/wizard/step5.svelte | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/routes/console/project-[project]/functions/wizard/step5.svelte b/src/routes/console/project-[project]/functions/wizard/step5.svelte index 4b791b433..2bf16ebda 100644 --- a/src/routes/console/project-[project]/functions/wizard/step5.svelte +++ b/src/routes/console/project-[project]/functions/wizard/step5.svelte @@ -22,7 +22,16 @@ function handleCreated(dispatchEvent: CustomEvent) { createFunction.update((n) => { - n.vars.push(dispatchEvent.detail); + if (n.vars.length) { + n.vars.map((v) => { + if (v.key !== dispatchEvent.detail.key) { + n.vars.push(dispatchEvent.detail); + } + }); + } else { + n.vars.push(dispatchEvent.detail); + } + return n; }); } From 3c9af3d88b0db1420da894cac2810ac08585e223 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 2 Nov 2022 11:25:06 +0100 Subject: [PATCH 07/12] fix: event for webhoobks --- .../settings/webhooks/[webhook]/+page.svelte | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/routes/console/project-[project]/settings/webhooks/[webhook]/+page.svelte b/src/routes/console/project-[project]/settings/webhooks/[webhook]/+page.svelte index a71badf95..e399f46a3 100644 --- a/src/routes/console/project-[project]/settings/webhooks/[webhook]/+page.svelte +++ b/src/routes/console/project-[project]/settings/webhooks/[webhook]/+page.svelte @@ -21,11 +21,15 @@ import { difference } from '$lib/helpers/array'; import { invalidate } from '$app/navigation'; import { Dependencies } from '$lib/constants'; + import { writable, type Writable } from 'svelte/store'; const projectId = $page.params.project; let name: string = null; let url: string = null; let events = []; + + const eventSet: Writable> = writable(new Set()); + let httpUser: string = null; let httpPass: string = null; let security = false; @@ -93,7 +97,7 @@ projectId, $webhook.$id, $webhook.name, - events, + Array.from($eventSet), $webhook.url, $webhook.security ); @@ -110,6 +114,7 @@ }); } } + async function updateSecurity() { try { await sdkForConsole.projects.updateWebhook( @@ -135,6 +140,10 @@ } } + function handleEvent(event: CustomEvent) { + eventSet.set($eventSet.add(event.detail)); + } + $: if (difference(events, $webhook.events).length > 0) { areEventsDisabled = false; } @@ -200,24 +209,25 @@
- Update Events + Update Events

Set the events that will trigger your webhook. Maximum 100 events allowed.

- {#if events?.length} + {#if $eventSet.size} - {#each events as id} + {#each Array.from($eventSet) as event}
  • - {id} + {event} @@ -226,14 +236,17 @@ {/each} {:else} - (showCreateEvent = !showCreateEvent)} - >Add a event to get started + (showCreateEvent = true)}> + Add a event to get started + {/if} - +
    + +
    @@ -313,9 +326,5 @@ - { - events.push(e.detail[0]); - events = events; - }} /> + + From 9c894454b69422a47114a8e33055cee7640304a6 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 2 Nov 2022 11:44:05 +0100 Subject: [PATCH 08/12] fix: webhooks events --- .../settings/webhooks/[webhook]/+page.svelte | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/routes/console/project-[project]/settings/webhooks/[webhook]/+page.svelte b/src/routes/console/project-[project]/settings/webhooks/[webhook]/+page.svelte index e399f46a3..021190570 100644 --- a/src/routes/console/project-[project]/settings/webhooks/[webhook]/+page.svelte +++ b/src/routes/console/project-[project]/settings/webhooks/[webhook]/+page.svelte @@ -26,7 +26,6 @@ const projectId = $page.params.project; let name: string = null; let url: string = null; - let events = []; const eventSet: Writable> = writable(new Set()); @@ -41,7 +40,7 @@ onMount(async () => { name ??= $webhook.name; url ??= $webhook.url; - events = $webhook.events; + $eventSet = new Set($webhook.events); httpUser ??= $webhook.httpUser; httpPass ??= $webhook.httpPass; security = $webhook.security; @@ -144,8 +143,13 @@ eventSet.set($eventSet.add(event.detail)); } - $: if (difference(events, $webhook.events).length > 0) { - areEventsDisabled = false; + $: if ($eventSet) { + if ( + difference(Array.from($eventSet), $webhook.events).length || + difference($webhook.events, Array.from($eventSet)).length + ) { + areEventsDisabled = false; + } else areEventsDisabled = true; } From ee64398092a486009f5ab11fc346ccd4cc54e631 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 2 Nov 2022 12:15:58 +0100 Subject: [PATCH 09/12] feat: update copy input design --- src/lib/components/copyInput.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/components/copyInput.svelte b/src/lib/components/copyInput.svelte index 782e89c80..38e63c34c 100644 --- a/src/lib/components/copyInput.svelte +++ b/src/lib/components/copyInput.svelte @@ -22,10 +22,10 @@ }; -
    +
    -
    - + +