From 0d87c7c2f54a2ca41ba7ba4b7f39e2273582817c Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 3 Oct 2022 15:39:17 +0200 Subject: [PATCH 01/22] feat: anonymous users --- src/lib/layout/shell.svelte | 2 +- .../authentication/+page.svelte | 44 ++++++++++++++++--- .../authentication/_createUser.svelte | 22 +++++----- .../authentication/teams/+page.svelte | 16 +++++-- .../authentication/user/[user]/+page.svelte | 20 +++++---- 5 files changed, 74 insertions(+), 30 deletions(-) diff --git a/src/lib/layout/shell.svelte b/src/lib/layout/shell.svelte index 181e3aade..7eb4e1f36 100644 --- a/src/lib/layout/shell.svelte +++ b/src/lib/layout/shell.svelte @@ -180,7 +180,7 @@ {:else}

- {$title} + {$title ? $title : '-'}

{/if} {#if $page.url.pathname.includes('/console/account')} diff --git a/src/routes/console/project-[project]/authentication/+page.svelte b/src/routes/console/project-[project]/authentication/+page.svelte index b7e097375..0ad3fbba2 100644 --- a/src/routes/console/project-[project]/authentication/+page.svelte +++ b/src/routes/console/project-[project]/authentication/+page.svelte @@ -34,7 +34,10 @@ }; $: if (search) offset = 0; - $: usersList.load([Query.limit($pageLimit), Query.offset(offset)], search); + $: usersList.load( + [Query.limit($pageLimit), Query.offset(offset), Query.orderDesc('$createdAt')], + search + ); @@ -56,7 +59,7 @@ Name - Email + Identifier Status ID Joined @@ -67,11 +70,31 @@ href={`${base}/console/project-${project}/authentication/user/${user.$id}`}>
- - {user.name ? user.name : 'n/a'} + {#if user.email || user.phone} + {#if user.name} + + {user.name} + {:else} +
+
+ {/if} + {:else} +
+
+ {user.name} + {/if}
- {user.email} + + {user.email && user.phone + ? [user.email, user.phone].join(',') + : user.email || user.phone} + {#if user.status} @@ -102,7 +125,7 @@ {:else if search} - +
Sorry, we couldn’t find ‘{search}’
@@ -128,7 +151,14 @@ type: 'user' } }}> -

Add Your First User To Get Started

+
+

Create your first User to get started.

+

Need a hand? Check out our documentation.

+
+
+ + +
{/if} diff --git a/src/routes/console/project-[project]/authentication/_createUser.svelte b/src/routes/console/project-[project]/authentication/_createUser.svelte index 8f33df69f..d91508898 100644 --- a/src/routes/console/project-[project]/authentication/_createUser.svelte +++ b/src/routes/console/project-[project]/authentication/_createUser.svelte @@ -6,6 +6,7 @@ InputPassword, InputEmail, InputText, + InputPhone, Form, FormList } from '$lib/elements/forms'; @@ -18,18 +19,24 @@ const dispatch = createEventDispatcher(); let showDropdown = false; - let name: string, mail: string, pass: string, id: string; + let name: string, mail: string, pass: string, id: string, phone: string; let error: string; const create = async () => { try { - const user = await sdkForProject.users.create(id ?? 'unique()', mail, pass, name); + const user = await sdkForProject.users.create( + id ?? 'unique()', + mail, + phone, + pass, + name + ); mail = pass = name = ''; showCreate = false; showDropdown = false; addNotification({ type: 'success', - message: `${user.name} has been created` + message: `${user.name ?? 'User'} has been created` }); dispatch('created', user); } catch ({ message }) { @@ -56,17 +63,12 @@ placeholder="Enter name" autofocus={true} bind:value={name} /> - + + diff --git a/src/routes/console/project-[project]/authentication/teams/+page.svelte b/src/routes/console/project-[project]/authentication/teams/+page.svelte index 00936a441..ef22133bc 100644 --- a/src/routes/console/project-[project]/authentication/teams/+page.svelte +++ b/src/routes/console/project-[project]/authentication/teams/+page.svelte @@ -33,7 +33,10 @@ }; $: if (search) offset = 0; - $: teamsList.load([Query.limit(limit), Query.offset(offset)], search); + $: teamsList.load( + [Query.limit(limit), Query.offset(offset), Query.orderDesc('$createdAt')], + search + ); @@ -81,7 +84,7 @@
{:else if search} - +
Sorry, we couldn’t find ‘{search}’
@@ -107,7 +110,14 @@ type: 'team' } }}> -

Create your first team to get started

+
+

Create your first Tser to get started.

+

Need a hand? Check out our documentation.

+
+
+ + +
{/if} 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 a43453202..8b3fa2c54 100644 --- a/src/routes/console/project-[project]/authentication/user/[user]/+page.svelte +++ b/src/routes/console/project-[project]/authentication/user/[user]/+page.svelte @@ -292,7 +292,7 @@ - + @@ -312,9 +312,7 @@ - + @@ -334,9 +332,7 @@ - + @@ -459,9 +455,15 @@ -
{$user.name}
+
+ {$user.email || $user.phone || $user.name ? $user.name : 'Anonymous'} +
-

{$user.email}

+

+ {$user.email && $user.phone + ? [$user.email, $user.phone].join(',') + : $user.email || $user.phone} +

From 95eb63b7fac76bbede3ff82a0beb43ccb9075bac Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 3 Oct 2022 15:41:05 +0200 Subject: [PATCH 02/22] fix: memberships not loading --- src/routes/console/organization-[organization]/+layout.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/organization-[organization]/+layout.svelte b/src/routes/console/organization-[organization]/+layout.svelte index ba490c381..dbc5bb5c6 100644 --- a/src/routes/console/organization-[organization]/+layout.svelte +++ b/src/routes/console/organization-[organization]/+layout.svelte @@ -23,8 +23,8 @@ async function handle(event = null) { if ($organization?.$id !== organizationId) { await organization.load(organizationId); - await memberList.load(organizationId, [Query.limit(12)]); } + await memberList.load(organizationId, [Query.limit(12)]); updateLayout({ navigate: event, title: $organization?.name, From 35293f10b5cf0a8cfb415a6f37a474fc61fafbda Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 3 Oct 2022 17:07:44 +0200 Subject: [PATCH 03/22] feat: storage screens fixes --- .../overview/platforms/+page.svelte | 2 +- .../console/project-[project]/storage/+page.svelte | 12 ++++++------ .../storage/bucket/[bucket]/+page.svelte | 14 ++++++++------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/routes/console/project-[project]/overview/platforms/+page.svelte b/src/routes/console/project-[project]/overview/platforms/+page.svelte index b679ee92e..34eafdce0 100644 --- a/src/routes/console/project-[project]/overview/platforms/+page.svelte +++ b/src/routes/console/project-[project]/overview/platforms/+page.svelte @@ -21,7 +21,7 @@ -
+
{#each $project.platforms as platform} {platform.name} diff --git a/src/routes/console/project-[project]/storage/+page.svelte b/src/routes/console/project-[project]/storage/+page.svelte index 9de1c4927..a5a4a4a90 100644 --- a/src/routes/console/project-[project]/storage/+page.svelte +++ b/src/routes/console/project-[project]/storage/+page.svelte @@ -10,7 +10,7 @@ import { base } from '$app/paths'; import { bucketList } from './store'; import { tooltip } from '$lib/actions/tooltip'; - import { pageLimit } from '$lib/stores/layout'; + import { cardLimit } from '$lib/stores/layout'; let showCreate = false; let search = ''; @@ -22,7 +22,7 @@ await goto(`${base}/console/project-${project}/storage/bucket/${event.detail.$id}`); }; - $: bucketList.load([Query.limit($pageLimit), Query.offset(offset)], search); + $: bucketList.load([Query.limit($cardLimit), Query.offset(offset)], search); $: if (search) offset = 0; @@ -38,7 +38,7 @@ {#if $bucketList?.total}
    3 ? '22rem' : '25rem' };`}> {#each $bucketList.buckets as bucket} @@ -81,7 +81,7 @@ {/each} - {#if $bucketList.total % 2 !== 0} + {#if $bucketList?.total < $cardLimit + offset && ($bucketList?.total % 2 !== 0 || $bucketList?.total % 4 === 0)} (showCreate = true)}>

    Add a new bucket

    @@ -90,7 +90,7 @@

    Total results: {$bucketList.total}

    - +
    {:else if search} @@ -106,7 +106,7 @@

    Total results: {$bucketList?.total}

    - +
    {:else} (showCreate = true)}> diff --git a/src/routes/console/project-[project]/storage/bucket/[bucket]/+page.svelte b/src/routes/console/project-[project]/storage/bucket/[bucket]/+page.svelte index f07504900..0d5893820 100644 --- a/src/routes/console/project-[project]/storage/bucket/[bucket]/+page.svelte +++ b/src/routes/console/project-[project]/storage/bucket/[bucket]/+page.svelte @@ -85,9 +85,9 @@
Filename - Type - Size - Date Created + Type + Size + Date Created @@ -95,11 +95,13 @@ {#if file.chunksTotal / file.chunksUploaded !== 1} -
-
+
+ {file.name} - Pending +
+ Pending +
{file.mimeType} From 49ff69cdcfe9c1d608264a444a5f4f8d1fc15949 Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 3 Oct 2022 17:15:02 +0200 Subject: [PATCH 04/22] feat: replace hard coded limits with store limit --- src/lib/stores/layout.ts | 1 + .../console/account/organizations/+page.svelte | 10 +++++----- .../organization-[organization]/+layout.svelte | 4 ++-- .../console/organization-[organization]/+page.svelte | 12 ++++++------ .../authentication/teams/+page.svelte | 8 ++++---- .../user/[user]/memberships/+page.svelte | 5 ++--- .../console/project-[project]/databases/+page.svelte | 8 ++++---- .../databases/database/[database]/+page.svelte | 10 +++++----- .../[database]/collection/[collection]/+page.svelte | 4 ++-- .../collection/[collection]/indexes/+page.svelte | 7 +++---- 10 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/lib/stores/layout.ts b/src/lib/stores/layout.ts index 04c054867..87cb2c946 100644 --- a/src/lib/stores/layout.ts +++ b/src/lib/stores/layout.ts @@ -75,3 +75,4 @@ export function updateLayout(args: updateLayoutArguments) { } export const pageLimit = readable(12); // default page limit +export const cardLimit = readable(6); // default page limit diff --git a/src/routes/console/account/organizations/+page.svelte b/src/routes/console/account/organizations/+page.svelte index 998111b0f..1c1d09aef 100644 --- a/src/routes/console/account/organizations/+page.svelte +++ b/src/routes/console/account/organizations/+page.svelte @@ -7,6 +7,7 @@ import { organizationList } from '$lib/stores/organization'; import { onMount } from 'svelte'; import { sdkForConsole } from '$lib/stores/sdk'; + import { cardLimit } from '$lib/stores/layout'; onMount(async () => { await organizationList.load(); @@ -28,7 +29,6 @@ let addOrganization = false; let offset = 0; - const limit = 6; @@ -52,7 +52,7 @@ };`}> {#each $organizationList.teams as organization, index} {@const avatarList = getMemberships(organization.$id)} - {#if index >= offset && index < limit + offset} + {#if index >= offset && index < $cardLimit + offset} {organization?.total ? organization?.total : 'No'} projects @@ -67,7 +67,7 @@ {/if} {/each} - {#if $organizationList?.total < limit + offset && ($organizationList?.total % 2 !== 0 || $organizationList?.total % 4 === 0)} + {#if $organizationList?.total < $cardLimit + offset && ($organizationList?.total % 2 !== 0 || $organizationList?.total % 4 === 0)} (addOrganization = true)}>

Create a new organization

@@ -76,7 +76,7 @@

Total results: {$organizationList?.total}

- +
{:else} (addOrganization = true)}> @@ -84,7 +84,7 @@

Total results: {$organizationList?.total}

- +
{/if}
diff --git a/src/routes/console/organization-[organization]/+layout.svelte b/src/routes/console/organization-[organization]/+layout.svelte index dbc5bb5c6..39b8a02c0 100644 --- a/src/routes/console/organization-[organization]/+layout.svelte +++ b/src/routes/console/organization-[organization]/+layout.svelte @@ -1,5 +1,5 @@ @@ -81,7 +81,7 @@

Total results: {$teamsList.total}

- +
{:else if search} @@ -97,7 +97,7 @@

Total results: {$teamsList.total}

- +
{:else} (showCreate = true)}> diff --git a/src/routes/console/project-[project]/authentication/user/[user]/memberships/+page.svelte b/src/routes/console/project-[project]/authentication/user/[user]/memberships/+page.svelte index 52de8964c..0072d3e91 100644 --- a/src/routes/console/project-[project]/authentication/user/[user]/memberships/+page.svelte +++ b/src/routes/console/project-[project]/authentication/user/[user]/memberships/+page.svelte @@ -17,6 +17,7 @@ import DeleteMembership from '../_deleteMembership.svelte'; import DeleteAllMemberships from '../_deleteAllMemberships.svelte'; import type { Models } from '@aw-labs/appwrite-console'; + import { pageLimit } from '$lib/stores/layout'; const getAvatar = (name: string) => sdkForProject.avatars.getInitials(name, 32, 32).toString(); const deleted = () => (request = sdkForProject.users.listMemberships($page.params.user)); @@ -27,8 +28,6 @@ let showDelete = false; let showDeleteAll = false; - const limit = 25; - $: request = sdkForProject.users.listMemberships($page.params.user); @@ -97,7 +96,7 @@ class="u-flex u-margin-block-start-32 u-main-space-between">

Total results: {response.total}

- + {/await}
diff --git a/src/routes/console/project-[project]/databases/+page.svelte b/src/routes/console/project-[project]/databases/+page.svelte index 98e51b371..940a2fcce 100644 --- a/src/routes/console/project-[project]/databases/+page.svelte +++ b/src/routes/console/project-[project]/databases/+page.svelte @@ -9,19 +9,19 @@ import { Container } from '$lib/layout'; import { base } from '$app/paths'; import { databaseList } from './store'; + import { cardLimit } from '$lib/stores/layout'; let showCreate = false; let search = ''; let offset = 0; - const limit = 6; const project = $page.params.project; const handleCreate = async (event: CustomEvent) => { showCreate = false; await goto(`${base}/console/project-${project}/databases/database/${event.detail.$id}`); }; - $: databaseList.load([Query.limit(limit), Query.offset(offset)], search); + $: databaseList.load([Query.limit($cardLimit), Query.offset(offset)], search); @@ -48,7 +48,7 @@ {/each} - {#if ($databaseList.total % 2 !== 0 || $databaseList.total % 4 === 0) && $databaseList.total - offset <= limit} + {#if ($databaseList.total % 2 !== 0 || $databaseList.total % 4 === 0) && $databaseList.total - offset <= $cardLimit} (showCreate = true)}>

Create a new database

@@ -57,7 +57,7 @@

Total results: {$databaseList.total}

- +
{:else} (showCreate = true)}> diff --git a/src/routes/console/project-[project]/databases/database/[database]/+page.svelte b/src/routes/console/project-[project]/databases/database/[database]/+page.svelte index 7e10fbbb8..109598432 100644 --- a/src/routes/console/project-[project]/databases/database/[database]/+page.svelte +++ b/src/routes/console/project-[project]/databases/database/[database]/+page.svelte @@ -9,12 +9,12 @@ import { Container } from '$lib/layout'; import { base } from '$app/paths'; import { collections } from './store'; + import { cardLimit } from '$lib/stores/layout'; let showCreate = false; let search = ''; let offset = 0; - const limit = 6; const project = $page.params.project; const databaseId = $page.params.database; const handleCreate = async (event: CustomEvent) => { @@ -24,7 +24,7 @@ ); }; - $: collections.load(databaseId, [Query.limit(limit), Query.offset(offset)], search); + $: collections.load(databaseId, [Query.limit($cardLimit), Query.offset(offset)], search); $: if (search) offset = 0; @@ -62,7 +62,7 @@ {/each} - {#if ($collections.total % 2 !== 0 || $collections.total % 4 === 0) && $collections.total - offset <= limit} + {#if ($collections.total % 2 !== 0 || $collections.total % 4 === 0) && $collections.total - offset <= $cardLimit} (showCreate = true)}>

Create a new collection

@@ -71,7 +71,7 @@

Total results: {$collections.total}

- +
{:else if search} @@ -87,7 +87,7 @@

Total results: {$collections?.total}

- +
{:else} (showCreate = true)}> diff --git a/src/routes/console/project-[project]/databases/database/[database]/collection/[collection]/+page.svelte b/src/routes/console/project-[project]/databases/database/[database]/collection/[collection]/+page.svelte index df33d2a5e..1b5aab7c1 100644 --- a/src/routes/console/project-[project]/databases/database/[database]/collection/[collection]/+page.svelte +++ b/src/routes/console/project-[project]/databases/database/[database]/collection/[collection]/+page.svelte @@ -17,10 +17,10 @@ import { wizard } from '$lib/stores/wizard'; import Create from './createDocument.svelte'; import { Query } from '@aw-labs/appwrite-console'; + import { pageLimit } from '$lib/stores/layout'; let offset = 0; - const limit = 5; const projectId = $page.params.project; const databaseId = $page.params.database; @@ -79,7 +79,7 @@

Total results: {$documentList.total}

- +
{:else} diff --git a/src/routes/console/project-[project]/databases/database/[database]/collection/[collection]/indexes/+page.svelte b/src/routes/console/project-[project]/databases/database/[database]/collection/[collection]/indexes/+page.svelte index 33a3bf604..d538d15f2 100644 --- a/src/routes/console/project-[project]/databases/database/[database]/collection/[collection]/indexes/+page.svelte +++ b/src/routes/console/project-[project]/databases/database/[database]/collection/[collection]/indexes/+page.svelte @@ -19,6 +19,7 @@ import Create from './createIndex.svelte'; import Overview from './overviewIndex.svelte'; import type { Models } from '@aw-labs/appwrite-console'; + import { pageLimit } from '$lib/stores/layout'; let showDropdown = []; let selectedIndex: Models.Index = null; @@ -27,8 +28,6 @@ let showDelete = false; let search = ''; let offset: number = null; - - const limit = 5; const collectionId = $page.params.collection; const databaseId = $page.params.database; @@ -138,7 +137,7 @@

Total results: {$indexList?.total}

- +
{:else if search} @@ -154,7 +153,7 @@

Total results: {$indexList?.total}

- +
{:else if $collection.indexes?.length} (showCreateIndex = true)}> From f0e98b666807161e3d4080666b033dd805a62738 Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 3 Oct 2022 17:33:18 +0200 Subject: [PATCH 05/22] fix: remove extra variable --- .../collection/[collection]/attributes/+page.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/console/project-[project]/databases/database/[database]/collection/[collection]/attributes/+page.svelte b/src/routes/console/project-[project]/databases/database/[database]/collection/[collection]/attributes/+page.svelte index e99c9e8b8..24210e796 100644 --- a/src/routes/console/project-[project]/databases/database/[database]/collection/[collection]/attributes/+page.svelte +++ b/src/routes/console/project-[project]/databases/database/[database]/collection/[collection]/attributes/+page.svelte @@ -18,9 +18,9 @@ import CreateIndex from '../indexes/createIndex.svelte'; import Delete from './deleteAttribute.svelte'; import Overview from './overview.svelte'; + import { pageLimit } from '$lib/stores/layout'; let offset = 0; - const limit = 5; let showDropdown = []; let selectedAttribute: Attributes = null; let showCreate = false; @@ -112,7 +112,7 @@

Total results: {$collection?.attributes?.length}

- +
{:else} (showCreate = true)}> From 1770a39c413825d6bce4af17de96fe685e9a2f03 Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 3 Oct 2022 17:54:39 +0200 Subject: [PATCH 06/22] feat: verification tag and messages --- .../console/project-[project]/authentication/+page.svelte | 8 ++++++-- .../authentication/user/[user]/+page.svelte | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/routes/console/project-[project]/authentication/+page.svelte b/src/routes/console/project-[project]/authentication/+page.svelte index 0ad3fbba2..cd2d8efbf 100644 --- a/src/routes/console/project-[project]/authentication/+page.svelte +++ b/src/routes/console/project-[project]/authentication/+page.svelte @@ -60,7 +60,7 @@ Name Identifier - Status + Status ID Joined @@ -98,8 +98,12 @@ {#if user.status} - {user.emailVerification || user.phoneVerification + {user.emailVerification && user.phoneVerification ? 'verified' + : user.emailVerification + ? 'verified email' + : user.phoneVerification + ? 'verified phone' : 'unverified'} {:else} 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 8b3fa2c54..e8e14f53d 100644 --- a/src/routes/console/project-[project]/authentication/user/[user]/+page.svelte +++ b/src/routes/console/project-[project]/authentication/user/[user]/+page.svelte @@ -57,7 +57,7 @@ await sdkForProject.users.updateEmailVerification($user.$id, !$user.emailVerification); $user.emailVerification = !$user.emailVerification; addNotification({ - message: `The account has been ${ + message: `${$user.name || $user.email || $user.phone || 'The account'} has been ${ $user.emailVerification ? 'verified' : 'unverified' }`, type: 'success' @@ -75,7 +75,7 @@ await sdkForProject.users.updatePhoneVerification($user.$id, !$user.phoneVerification); $user.phoneVerification = !$user.phoneVerification; addNotification({ - message: `The account has been ${ + message: `${$user.name || $user.email || $user.phone || 'The account'} has been ${ $user.phoneVerification ? 'verified' : 'unverified' }`, type: 'success' @@ -92,7 +92,9 @@ await sdkForProject.users.updateStatus($user.$id, !$user.status); $user.status = !$user.status; addNotification({ - message: `The account has been ${$user.status ? 'unblocked' : 'blocked'}`, + message: `${$user.name || $user.email || $user.phone || 'The account'} has been ${ + $user.status ? 'unblocked' : 'blocked' + }`, type: 'success' }); } catch (error) { From ecebfc45cbda502ecf78a0ee58df27cddcd9f2e9 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 4 Oct 2022 11:07:55 +0200 Subject: [PATCH 07/22] chore: bump css to 0.0.0-57 --- package-lock.json | 28 ++++++++++++++-------------- package.json | 4 ++-- src/lib/components/gridItem1.svelte | 7 +++++++ 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index b05e71318..2d5431b41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "0.0.1", "dependencies": { "@aw-labs/appwrite-console": "^6.0.0", - "@aw-labs/icons": "0.0.0-55", - "@aw-labs/ui": "0.0.0-55", + "@aw-labs/icons": "0.0.0-57", + "@aw-labs/ui": "0.0.0-57", "echarts": "^5.3.3", "tippy.js": "^6.3.7", "web-vitals": "^2.1.4" @@ -77,14 +77,14 @@ } }, "node_modules/@aw-labs/icons": { - "version": "0.0.0-55", - "resolved": "https://registry.npmjs.org/@aw-labs/icons/-/icons-0.0.0-55.tgz", - "integrity": "sha512-d0SkIdojCodV9Amu4l63DzVw6AH3pjyhGSfwS3jWb9KMztVOgMHnJ1tXooFUjvglALToSNHH/C9ATAN5HsqpDQ==" + "version": "0.0.0-57", + "resolved": "https://registry.npmjs.org/@aw-labs/icons/-/icons-0.0.0-57.tgz", + "integrity": "sha512-HmXSTSP3GEBi5awFk0APTTNdM10DDIBCTnxi3BJGlsXo+SXnpVikoMk6RZltNLH7MRfPQNx+VfJ2bOC+hlW8ZQ==" }, "node_modules/@aw-labs/ui": { - "version": "0.0.0-55", - "resolved": "https://registry.npmjs.org/@aw-labs/ui/-/ui-0.0.0-55.tgz", - "integrity": "sha512-sEWRRwX3Omx7P/q9e52xYFdmSpHlTRPDpVU6ulBVwNcWOO9wduHQeuQyE0wqtGffvd51Fq27I5NWukWu5tkFlw==", + "version": "0.0.0-57", + "resolved": "https://registry.npmjs.org/@aw-labs/ui/-/ui-0.0.0-57.tgz", + "integrity": "sha512-a/nKqu9nHysTF7bIOLo+ZN1zKpCHfv+jHGixU0SGXchTNAmj2OXClZNk3XfMmwnPD6CiF4cG6YRdbmpx+TTXgA==", "dependencies": { "@aw-labs/icons": "*" } @@ -8201,14 +8201,14 @@ } }, "@aw-labs/icons": { - "version": "0.0.0-55", - "resolved": "https://registry.npmjs.org/@aw-labs/icons/-/icons-0.0.0-55.tgz", - "integrity": "sha512-d0SkIdojCodV9Amu4l63DzVw6AH3pjyhGSfwS3jWb9KMztVOgMHnJ1tXooFUjvglALToSNHH/C9ATAN5HsqpDQ==" + "version": "0.0.0-57", + "resolved": "https://registry.npmjs.org/@aw-labs/icons/-/icons-0.0.0-57.tgz", + "integrity": "sha512-HmXSTSP3GEBi5awFk0APTTNdM10DDIBCTnxi3BJGlsXo+SXnpVikoMk6RZltNLH7MRfPQNx+VfJ2bOC+hlW8ZQ==" }, "@aw-labs/ui": { - "version": "0.0.0-55", - "resolved": "https://registry.npmjs.org/@aw-labs/ui/-/ui-0.0.0-55.tgz", - "integrity": "sha512-sEWRRwX3Omx7P/q9e52xYFdmSpHlTRPDpVU6ulBVwNcWOO9wduHQeuQyE0wqtGffvd51Fq27I5NWukWu5tkFlw==", + "version": "0.0.0-57", + "resolved": "https://registry.npmjs.org/@aw-labs/ui/-/ui-0.0.0-57.tgz", + "integrity": "sha512-a/nKqu9nHysTF7bIOLo+ZN1zKpCHfv+jHGixU0SGXchTNAmj2OXClZNk3XfMmwnPD6CiF4cG6YRdbmpx+TTXgA==", "requires": { "@aw-labs/icons": "*" } diff --git a/package.json b/package.json index 2409815ef..7520a9a59 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ }, "dependencies": { "@aw-labs/appwrite-console": "^6.0.0", - "@aw-labs/icons": "0.0.0-55", - "@aw-labs/ui": "0.0.0-55", + "@aw-labs/icons": "0.0.0-57", + "@aw-labs/ui": "0.0.0-57", "echarts": "^5.3.3", "tippy.js": "^6.3.7", "web-vitals": "^2.1.4" diff --git a/src/lib/components/gridItem1.svelte b/src/lib/components/gridItem1.svelte index a826e5663..8220f6429 100644 --- a/src/lib/components/gridItem1.svelte +++ b/src/lib/components/gridItem1.svelte @@ -24,3 +24,10 @@ + + From 1c986eb05ad5177ffe6743e7346ca441cd589ba1 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 4 Oct 2022 11:08:30 +0200 Subject: [PATCH 08/22] feat: avatar fix --- .../authentication/user/[user]/+page.svelte | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) 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 e8e14f53d..f4486eb1e 100644 --- a/src/routes/console/project-[project]/authentication/user/[user]/+page.svelte +++ b/src/routes/console/project-[project]/authentication/user/[user]/+page.svelte @@ -194,7 +194,20 @@
- + {#if $user.email || $user.phone} + {#if $user.name} + + {$user.name} + {:else} +
+
+ {/if} + {:else} +
+
+ {/if}
{$user.name}
@@ -454,11 +467,24 @@ - + {#if $user.email || $user.phone} + {#if $user.name} + + {$user.name} + {:else} +
+
+ {/if} + {:else} +
+
+ {/if}
- {$user.email || $user.phone || $user.name ? $user.name : 'Anonymous'} + {$user.name || $user.email || $user.phone || 'Anonymous'}

From f93ec0b6b361bae838b46e114d56d4450748d233 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 4 Oct 2022 11:53:00 +0200 Subject: [PATCH 09/22] small fixes --- .../authentication/user/[user]/_deleteAllMemberships.svelte | 6 ++++++ .../authentication/user/[user]/_deleteMembership.svelte | 4 ++++ .../authentication/user/[user]/_deleteUser.svelte | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/routes/console/project-[project]/authentication/user/[user]/_deleteAllMemberships.svelte b/src/routes/console/project-[project]/authentication/user/[user]/_deleteAllMemberships.svelte index fd892d46d..0a853040b 100644 --- a/src/routes/console/project-[project]/authentication/user/[user]/_deleteAllMemberships.svelte +++ b/src/routes/console/project-[project]/authentication/user/[user]/_deleteAllMemberships.svelte @@ -14,6 +14,10 @@ try { await sdkForProject.teams.deleteMembership('tmpstring', 'tmpstring2'); showDeleteAll = false; + addNotification({ + type: 'success', + message: `All memberships have been deleted` + }); await goto( `${base}/console/project-${$page.params.project}/authentication/${$user.$id}/membeships` ); @@ -24,6 +28,8 @@ }); } }; + + //TODO: implelment delete all memberships

diff --git a/src/routes/console/project-[project]/authentication/user/[user]/_deleteMembership.svelte b/src/routes/console/project-[project]/authentication/user/[user]/_deleteMembership.svelte index 8bf5f78f2..154f9c869 100644 --- a/src/routes/console/project-[project]/authentication/user/[user]/_deleteMembership.svelte +++ b/src/routes/console/project-[project]/authentication/user/[user]/_deleteMembership.svelte @@ -22,6 +22,10 @@ ); showDelete = false; dispatch('deleted'); + addNotification({ + type: 'success', + message: `Membership has been deleted` + }); await goto( `${base}/console/project-${$page.params.project}/authentication/user/${selectedMembership.userId}/memberships` ); diff --git a/src/routes/console/project-[project]/authentication/user/[user]/_deleteUser.svelte b/src/routes/console/project-[project]/authentication/user/[user]/_deleteUser.svelte index 6704ae17e..cf8fa6ec0 100644 --- a/src/routes/console/project-[project]/authentication/user/[user]/_deleteUser.svelte +++ b/src/routes/console/project-[project]/authentication/user/[user]/_deleteUser.svelte @@ -17,7 +17,7 @@ showDelete = false; addNotification({ type: 'success', - message: `${$user.name} has been deleted` + message: `${$user.name ?? 'User'} has been deleted` }); await goto(`${base}/console/project-${$page.params.project}/authentication`); } catch (error) { From e4542cd3955062fb558302c5b0c077bd879c433e Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 4 Oct 2022 11:55:25 +0200 Subject: [PATCH 10/22] fix?: set id to null when is empty string --- .../project-[project]/authentication/_createUser.svelte | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/routes/console/project-[project]/authentication/_createUser.svelte b/src/routes/console/project-[project]/authentication/_createUser.svelte index d91508898..7eecca4f3 100644 --- a/src/routes/console/project-[project]/authentication/_createUser.svelte +++ b/src/routes/console/project-[project]/authentication/_createUser.svelte @@ -47,6 +47,9 @@ $: if (!showDropdown) { id = null; } + $: if (!id?.length) { + id = null; + } $: if (!showCreate) { showDropdown = false; error = null; From 69174fd37988419c87aac752d54cf1dbed086153 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 4 Oct 2022 16:02:05 +0200 Subject: [PATCH 11/22] feat: create customId component --- src/lib/components/customId.svelte | 43 +++++++++++++++++++ src/lib/components/index.ts | 1 + .../authentication/_createUser.svelte | 35 ++------------- .../user/[user]/_deleteUser.svelte | 2 +- 4 files changed, 48 insertions(+), 33 deletions(-) create mode 100644 src/lib/components/customId.svelte diff --git a/src/lib/components/customId.svelte b/src/lib/components/customId.svelte new file mode 100644 index 000000000..91164f4e9 --- /dev/null +++ b/src/lib/components/customId.svelte @@ -0,0 +1,43 @@ + + + + {name} ID + + Enter a custom {name} ID. Leave blank for a randomly generated one. + + +
+ + +
+
+
+
+
diff --git a/src/lib/components/index.ts b/src/lib/components/index.ts index b6f4ffb8b..9bfb631fb 100644 --- a/src/lib/components/index.ts +++ b/src/lib/components/index.ts @@ -26,3 +26,4 @@ export { default as Search } from './search.svelte'; export { default as GridItem1 } from './gridItem1.svelte'; export { default as Steps } from './steps.svelte'; export { default as Step } from './step.svelte'; +export { default as CustomId } from './customId.svelte'; diff --git a/src/routes/console/project-[project]/authentication/_createUser.svelte b/src/routes/console/project-[project]/authentication/_createUser.svelte index 7eecca4f3..f4c6858f4 100644 --- a/src/routes/console/project-[project]/authentication/_createUser.svelte +++ b/src/routes/console/project-[project]/authentication/_createUser.svelte @@ -1,5 +1,5 @@ @@ -48,39 +48,15 @@ placeholder="Enter name" autofocus={true} bind:value={name} /> - {#if !showDropdown} + {#if !showCustomId}
- (showDropdown = !showDropdown)} + (showCustomId = !showCustomId)} >
{:else} - - Team ID - - Enter a custom team ID. Leave blank for a randomly generated one. - - -
- -
-
-
-
-
+ {/if} diff --git a/src/routes/console/project-[project]/databases/_create.svelte b/src/routes/console/project-[project]/databases/_create.svelte index cbbb66367..864baecc4 100644 --- a/src/routes/console/project-[project]/databases/_create.svelte +++ b/src/routes/console/project-[project]/databases/_create.svelte @@ -1,5 +1,5 @@ @@ -46,41 +46,15 @@ autofocus required /> - {#if !showDropdown} + {#if !showCustomId}
- (showDropdown = !showDropdown)}> + (showCustomId = !showCustomId)}>
{:else} - - Bucket ID - - Enter a custom bucket ID. Leave blank for a randomly generated one. - - -
- - -
-
-
-
-
+ {/if} diff --git a/src/routes/console/project-[project]/storage/bucket/[bucket]/_create.svelte b/src/routes/console/project-[project]/storage/bucket/[bucket]/_create.svelte index fe94f6e7f..e97631c06 100644 --- a/src/routes/console/project-[project]/storage/bucket/[bucket]/_create.svelte +++ b/src/routes/console/project-[project]/storage/bucket/[bucket]/_create.svelte @@ -1,7 +1,7 @@ @@ -111,41 +111,16 @@

Max file size: {calculateSize($bucket.maximumFileSize)}

- {#if !showDropdown} + {#if !showCustomId}
- (showDropdown = !showDropdown)}> + (showCustomId = !showCustomId)}>
{:else} - - File ID - - Enter a custom file ID. Leave blank for a randomly generated one. - - -
- - -
-
-
-
-
+ {/if}

Permissions

From 3bcf53b19a82cc9c072c17f84d353b302b2e1abf Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 4 Oct 2022 17:52:58 +0200 Subject: [PATCH 13/22] chore: add svg for empty states --- src/lib/images/empty-dark.svg | 2 +- src/lib/images/search-dark.svg | 1 + src/lib/images/search-light.svg | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 src/lib/images/search-dark.svg create mode 100644 src/lib/images/search-light.svg diff --git a/src/lib/images/empty-dark.svg b/src/lib/images/empty-dark.svg index 9babf164b..2d68c7adc 100644 --- a/src/lib/images/empty-dark.svg +++ b/src/lib/images/empty-dark.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/lib/images/search-dark.svg b/src/lib/images/search-dark.svg new file mode 100644 index 000000000..50e36cb7c --- /dev/null +++ b/src/lib/images/search-dark.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/lib/images/search-light.svg b/src/lib/images/search-light.svg new file mode 100644 index 000000000..b24dc18ce --- /dev/null +++ b/src/lib/images/search-light.svg @@ -0,0 +1 @@ + \ No newline at end of file From e7420969c23b7c0a4147f0f81735b735e484cc2c Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 5 Oct 2022 15:03:05 +0200 Subject: [PATCH 14/22] feat: api keys detail --- package-lock.json | 28 +-- package.json | 4 +- src/lib/components/collapsible.svelte | 20 +- src/lib/components/collapsibleItem.svelte | 14 ++ src/lib/components/index.ts | 1 + src/lib/constants.ts | 206 +++++++++++------- src/lib/elements/forms/index.ts | 1 + src/lib/elements/forms/inputDateTime.svelte | 58 +++++ .../project-[project]/keys/+layout.svelte | 22 -- .../project-[project]/keys/+page.svelte | 62 ------ .../project-[project]/keys/_create.svelte | 69 ------ .../keys/key/[key]/+page.svelte | 35 --- .../keys/[key]/+page@project-[project].svelte | 68 ++++-- 13 files changed, 267 insertions(+), 321 deletions(-) create mode 100644 src/lib/components/collapsibleItem.svelte create mode 100644 src/lib/elements/forms/inputDateTime.svelte delete mode 100644 src/routes/console/project-[project]/keys/+layout.svelte delete mode 100644 src/routes/console/project-[project]/keys/+page.svelte delete mode 100644 src/routes/console/project-[project]/keys/_create.svelte delete mode 100644 src/routes/console/project-[project]/keys/key/[key]/+page.svelte diff --git a/package-lock.json b/package-lock.json index 058515466..8154711ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "0.0.1", "dependencies": { "@aw-labs/appwrite-console": "^6.0.0", - "@aw-labs/icons": "0.0.0-57", - "@aw-labs/ui": "0.0.0-57", + "@aw-labs/icons": "0.0.0-58", + "@aw-labs/ui": "0.0.0-58", "echarts": "^5.4.0", "tippy.js": "^6.3.7", "web-vitals": "^2.1.4" @@ -77,14 +77,14 @@ } }, "node_modules/@aw-labs/icons": { - "version": "0.0.0-57", - "resolved": "https://registry.npmjs.org/@aw-labs/icons/-/icons-0.0.0-57.tgz", - "integrity": "sha512-HmXSTSP3GEBi5awFk0APTTNdM10DDIBCTnxi3BJGlsXo+SXnpVikoMk6RZltNLH7MRfPQNx+VfJ2bOC+hlW8ZQ==" + "version": "0.0.0-58", + "resolved": "https://registry.npmjs.org/@aw-labs/icons/-/icons-0.0.0-58.tgz", + "integrity": "sha512-xUD5DQcYVNiKhDSpxMO24G/4l7txgAdwochK01tJA6wXhuPAcp5Yjuofjm2bGkMzCuze4Vs+SVvhsBxzVXRPrA==" }, "node_modules/@aw-labs/ui": { - "version": "0.0.0-57", - "resolved": "https://registry.npmjs.org/@aw-labs/ui/-/ui-0.0.0-57.tgz", - "integrity": "sha512-a/nKqu9nHysTF7bIOLo+ZN1zKpCHfv+jHGixU0SGXchTNAmj2OXClZNk3XfMmwnPD6CiF4cG6YRdbmpx+TTXgA==", + "version": "0.0.0-58", + "resolved": "https://registry.npmjs.org/@aw-labs/ui/-/ui-0.0.0-58.tgz", + "integrity": "sha512-W3bTvAPX4ig5qLBvGn/VpNaDk62RqO4oDa0poube2WuElkVvaGwFAR0wCwmisdi2NeXyGJqt20g3Y/Mz4K2yMA==", "dependencies": { "@aw-labs/icons": "*" } @@ -8134,14 +8134,14 @@ } }, "@aw-labs/icons": { - "version": "0.0.0-57", - "resolved": "https://registry.npmjs.org/@aw-labs/icons/-/icons-0.0.0-57.tgz", - "integrity": "sha512-HmXSTSP3GEBi5awFk0APTTNdM10DDIBCTnxi3BJGlsXo+SXnpVikoMk6RZltNLH7MRfPQNx+VfJ2bOC+hlW8ZQ==" + "version": "0.0.0-58", + "resolved": "https://registry.npmjs.org/@aw-labs/icons/-/icons-0.0.0-58.tgz", + "integrity": "sha512-xUD5DQcYVNiKhDSpxMO24G/4l7txgAdwochK01tJA6wXhuPAcp5Yjuofjm2bGkMzCuze4Vs+SVvhsBxzVXRPrA==" }, "@aw-labs/ui": { - "version": "0.0.0-57", - "resolved": "https://registry.npmjs.org/@aw-labs/ui/-/ui-0.0.0-57.tgz", - "integrity": "sha512-a/nKqu9nHysTF7bIOLo+ZN1zKpCHfv+jHGixU0SGXchTNAmj2OXClZNk3XfMmwnPD6CiF4cG6YRdbmpx+TTXgA==", + "version": "0.0.0-58", + "resolved": "https://registry.npmjs.org/@aw-labs/ui/-/ui-0.0.0-58.tgz", + "integrity": "sha512-W3bTvAPX4ig5qLBvGn/VpNaDk62RqO4oDa0poube2WuElkVvaGwFAR0wCwmisdi2NeXyGJqt20g3Y/Mz4K2yMA==", "requires": { "@aw-labs/icons": "*" } diff --git a/package.json b/package.json index 9ae2f78f9..d7c3234f5 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ }, "dependencies": { "@aw-labs/appwrite-console": "^6.0.0", - "@aw-labs/icons": "0.0.0-57", - "@aw-labs/ui": "0.0.0-57", + "@aw-labs/icons": "0.0.0-58", + "@aw-labs/ui": "0.0.0-58", "echarts": "^5.4.0", "tippy.js": "^6.3.7", "web-vitals": "^2.1.4" diff --git a/src/lib/components/collapsible.svelte b/src/lib/components/collapsible.svelte index 3647c2ec8..245eec781 100644 --- a/src/lib/components/collapsible.svelte +++ b/src/lib/components/collapsible.svelte @@ -1,21 +1,3 @@
    -
  • -
    - - - - - - - -
    -
    -
    -

    - -

    -
    -
  • +
diff --git a/src/lib/components/collapsibleItem.svelte b/src/lib/components/collapsibleItem.svelte new file mode 100644 index 000000000..5caa6caf3 --- /dev/null +++ b/src/lib/components/collapsibleItem.svelte @@ -0,0 +1,14 @@ +
  • +
    + + + +
    +
    +
    +
    + +
    +
    +
  • diff --git a/src/lib/components/index.ts b/src/lib/components/index.ts index b6f4ffb8b..bd3ebd58e 100644 --- a/src/lib/components/index.ts +++ b/src/lib/components/index.ts @@ -16,6 +16,7 @@ export { default as DropList } from './dropList.svelte'; export { default as DropListItem } from './dropListItem.svelte'; export { default as DropListLink } from './dropListLink.svelte'; export { default as Collapsible } from './collapsible.svelte'; +export { default as CollapsibleItem } from './collapsibleItem.svelte'; export { default as DropTabs } from './dropTabs.svelte'; export { default as DropTabsItem } from './dropTabsItem.svelte'; export { default as Avatar } from './avatar.svelte'; diff --git a/src/lib/constants.ts b/src/lib/constants.ts index aeaa77c21..08fad97b4 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -1,80 +1,130 @@ export const scopes = [ - 'users.read', - 'users.write', - 'teams.read', - 'teams.write', - 'collections.read', - 'collections.write', - 'attributes.read', - 'attributes.write', - 'indexes.read', - 'indexes.write', - 'documents.read', - 'documents.write', - 'files.read', - 'files.write', - 'buckets.read', - 'buckets.write', - 'functions.read', - 'functions.write', - 'execution.read', - 'execution.write', - 'locale.read', - 'avatars.read', - 'health.read' -]; - -export const events = [ - 'account.create', - 'account.update.email', - 'account.update.name', - 'account.update.password', - 'users.update.email', - 'users.update.name', - 'users.update.password', - 'account.update.prefs', - 'account.recovery.create', - 'account.recovery.update', - 'account.verification.create', - 'account.verification.update', - 'account.delete', - 'account.sessions.create', - 'account.sessions.delete', - 'account.sessions.update', - 'database.collections.create', - 'database.collections.update', - 'database.collections.delete', - 'database.attributes.create', - 'database.attributes.delete', - 'database.indexes.create', - 'database.indexes.delete', - 'database.documents.create', - 'database.documents.update', - 'database.documents.delete', - 'functions.create', - 'functions.update', - 'functions.delete', - 'functions.deployments.create', - 'functions.deployments.update', - 'functions.deployments.delete', - 'functions.executions.create', - 'functions.executions.update', - 'storage.files.create', - 'storage.files.update', - 'storage.files.delete', - 'storage.buckets.create', - 'storage.buckets.update', - 'storage.buckets.delete', - 'users.create', - 'users.update.prefs', - 'users.update.status', - 'users.delete', - 'users.sessions.delete', - 'teams.create', - 'teams.update', - 'teams.delete', - 'teams.memberships.create', - 'teams.memberships.update', - 'teams.memberships.update.status', - 'teams.memberships.delete' + { + scope: 'users.read', + description: "Access to read your project's users", + category: 'Authentication' + }, + { + scope: 'users.write', + description: "Access to create, update, and delete your project's users", + category: 'Authentication' + }, + { + scope: 'teams.read', + description: "Access to read your project's teams", + category: 'Authentication' + }, + { + scope: 'teams.write', + description: "Access to create, update, and delete your project's teams", + category: 'Authentication' + }, + { + scope: 'databases.read', + description: "Access to read your project's databases", + category: 'Database' + }, + { + scope: 'databases.write', + description: "Access to create, update, and delete your project's databases", + category: 'Database' + }, + { + scope: 'collections.read', + description: "Access to read your project's database collections", + category: 'Database' + }, + { + scope: 'collections.write', + description: "Access to create, update, and delete your project's database collections", + category: 'Database' + }, + { + scope: 'attributes.read', + description: "Access to read your project's database collection's attributes", + category: 'Database' + }, + { + scope: 'attributes.write', + description: + "Access to create, update, and delete your project's database collection's attributes", + category: 'Database' + }, + { + scope: 'indexes.read', + description: "Access to read your project's database collection's indexes", + category: 'Database' + }, + { + scope: 'indexes.write', + description: + "Access to create, update, and delete your project's database collection's indexes", + category: 'Database' + }, + { + scope: 'documents.read', + description: "Access to read your project's database documents", + category: 'Database' + }, + { + scope: 'documents.write', + description: "Access to create, update, and delete your project's database documents", + category: 'Database' + }, + { + scope: 'files.read', + description: "Access to read your project's storage files and preview images", + category: 'Storage' + }, + { + scope: 'files.write', + description: "Access to create, update, and delete your project's storage files", + category: 'Storage' + }, + { + scope: 'buckets.read', + description: "Access to read your project's storage buckets", + category: 'Storage' + }, + { + scope: 'buckets.write', + description: "Access to create, update, and delete your project's storage buckets", + category: 'Storage' + }, + { + scope: 'functions.read', + description: "Access to read your project's functions and code deployments", + category: 'Functions' + }, + { + scope: 'functions.write', + description: + "Access to create, update, and delete your project's functions and code deployments", + category: 'Functions' + }, + { + scope: 'execution.read', + description: "Access to read your project's execution logs", + category: 'Functions' + }, + { + scope: 'execution.write', + description: "Access to execute your project's functions", + category: 'Functions' + }, + { + scope: 'locale.read', + description: "Access to access your project's Locale service", + category: 'Other' + }, + { + scope: 'avatars.read', + description: "Access to access your project's Avatars service", + category: 'Other' + }, + { + scope: 'health.read', + description: "Access to read your project's health status", + category: 'Other' + } ]; diff --git a/src/lib/elements/forms/index.ts b/src/lib/elements/forms/index.ts index 7ed7d656f..b0b7b47b7 100644 --- a/src/lib/elements/forms/index.ts +++ b/src/lib/elements/forms/index.ts @@ -11,6 +11,7 @@ export { default as InputSwitch } from './inputSwitch.svelte'; export { default as InputTags } from './inputTags.svelte'; export { default as InputFile } from './inputFile.svelte'; export { default as InputCustomId } from './inputCustomId.svelte'; +export { default as InputDateTime } from './inputDateTime.svelte'; export { default as InputSearch } from './inputSearch.svelte'; export { default as InputRadio } from './inputRadio.svelte'; export { default as InputSelect } from './inputSelect.svelte'; diff --git a/src/lib/elements/forms/inputDateTime.svelte b/src/lib/elements/forms/inputDateTime.svelte new file mode 100644 index 000000000..3869f498b --- /dev/null +++ b/src/lib/elements/forms/inputDateTime.svelte @@ -0,0 +1,58 @@ + + + + +
    + +
    + {#if error} + {error} + {/if} +
    diff --git a/src/routes/console/project-[project]/keys/+layout.svelte b/src/routes/console/project-[project]/keys/+layout.svelte deleted file mode 100644 index 29247c421..000000000 --- a/src/routes/console/project-[project]/keys/+layout.svelte +++ /dev/null @@ -1,22 +0,0 @@ - - - diff --git a/src/routes/console/project-[project]/keys/+page.svelte b/src/routes/console/project-[project]/keys/+page.svelte deleted file mode 100644 index 05f59eee2..000000000 --- a/src/routes/console/project-[project]/keys/+page.svelte +++ /dev/null @@ -1,62 +0,0 @@ - - - - Appwrite - API Keys - - - {#if $project} - {#if $project.keys} - - - Name - Scopes - - - {#each $project.keys as key} - - - {key.name} - - {key.scopes.length} - - {/each} - -
    - {:else} - -
    -
    No API Keys Found
    -
    - You haven't created any API keys for your project yet. -
    -
    -
    - {/if} - - {/if} -
    - diff --git a/src/routes/console/project-[project]/keys/_create.svelte b/src/routes/console/project-[project]/keys/_create.svelte deleted file mode 100644 index 055b5349c..000000000 --- a/src/routes/console/project-[project]/keys/_create.svelte +++ /dev/null @@ -1,69 +0,0 @@ - - - - - Add API Key -

    - Select AllUnselect All -

    - - {#each scopes as scope} - - {/each} - - - - -
    - diff --git a/src/routes/console/project-[project]/keys/key/[key]/+page.svelte b/src/routes/console/project-[project]/keys/key/[key]/+page.svelte deleted file mode 100644 index 691763677..000000000 --- a/src/routes/console/project-[project]/keys/key/[key]/+page.svelte +++ /dev/null @@ -1,35 +0,0 @@ - - - - - {#await request} - loading - {:then response} -

    {response.name}

    - - {/await} -
    -
    diff --git a/src/routes/console/project-[project]/overview/keys/[key]/+page@project-[project].svelte b/src/routes/console/project-[project]/overview/keys/[key]/+page@project-[project].svelte index a36510ad3..a168fd26f 100644 --- a/src/routes/console/project-[project]/overview/keys/[key]/+page@project-[project].svelte +++ b/src/routes/console/project-[project]/overview/keys/[key]/+page@project-[project].svelte @@ -2,16 +2,18 @@ import { afterNavigate } from '$app/navigation'; import { base } from '$app/paths'; import { page } from '$app/stores'; - import { CardGrid } from '$lib/components'; + import { CardGrid, Collapsible, CollapsibleItem } from '$lib/components'; import { scopes } from '$lib/constants'; import { Button, Form, FormList, - InputCheckbox, + InputChoice, InputPassword, InputText } from '$lib/elements/forms'; + import InputDateTime from '$lib/elements/forms/inputDateTime.svelte'; + import { difference } from '$lib/helpers/array'; import { toLocaleDateTime } from '$lib/helpers/date'; import { Container } from '$lib/layout'; import { updateLayout } from '$lib/stores/layout'; @@ -25,7 +27,7 @@ const projectId = $page.params.project; const keyId = $page.params.key; const activeScopes = scopes.reduce((prev, next) => { - prev[next] = false; + prev[next.scope] = false; return prev; }, {}); @@ -40,8 +42,9 @@ afterNavigate(handle); async function handle(event = null) { + const promise = key.load(projectId, keyId); if ($key?.$id !== keyId) { - await key.load(projectId, keyId); + await promise; } name ??= $key.name; @@ -121,8 +124,9 @@ $project.$id, $key.$id, $key.name, - scopes.filter((scope) => activeScopes[scope]) + selectedScoped ); + $key.scopes = selectedScoped; addNotification({ type: 'success', message: 'API Key scopes has been updated' @@ -135,11 +139,21 @@ } } + function selectAll() { + for (const scope in activeScopes) { + activeScopes[scope] = true; + } + } + function unselectAll() { for (const scope in activeScopes) { activeScopes[scope] = false; } } + + $: selectedScoped = scopes + .filter((scope) => activeScopes[scope.scope]) + .map(({ scope }) => scope); @@ -154,7 +168,7 @@

    - Last accessed: {toLocaleDateTime($key.$updatedAt)}
    + Last accessed: {toLocaleDateTime($key.accessedAt)}
    Scopes granted: {$key.scopes.length}

    @@ -206,18 +220,36 @@ practice to allow only the permissions you need to meet your project goals.

    - - {#each scopes as scope} - +
    + + +
    + + {#each ['Authentication', 'Database', 'Functions', 'Storage', 'Other'] as category} + + {category} + + {#each scopes.filter((s) => s.category === category) as scope} + + {scope.description} + + {/each} + + {/each} -
    +
    - +
    @@ -227,11 +259,7 @@

    Choose any name that will help you distinguish between API keys.

    - + @@ -250,7 +278,7 @@
    {$key.name}
    -

    Last accessed: {toLocaleDateTime($key.$updatedAt)}

    +

    Last accessed: {toLocaleDateTime($key.accessedAt)}

    From f802afb98e0d87800de6ebd3ffdf055e17776ee6 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 5 Oct 2022 17:40:55 +0200 Subject: [PATCH 15/22] fix: re-usable scopes and secret --- src/lib/components/index.ts | 1 + src/lib/components/secret.svelte | 28 ++++++ .../overview/keys/+page.svelte | 2 +- .../keys/[key]/+page@project-[project].svelte | 96 +++---------------- .../overview/keys/create.svelte | 27 ++---- .../overview/keys/scopes.svelte | 72 ++++++++++++++ 6 files changed, 124 insertions(+), 102 deletions(-) create mode 100644 src/lib/components/secret.svelte create mode 100644 src/routes/console/project-[project]/overview/keys/scopes.svelte diff --git a/src/lib/components/index.ts b/src/lib/components/index.ts index bd3ebd58e..96e13637b 100644 --- a/src/lib/components/index.ts +++ b/src/lib/components/index.ts @@ -27,3 +27,4 @@ export { default as Search } from './search.svelte'; export { default as GridItem1 } from './gridItem1.svelte'; export { default as Steps } from './steps.svelte'; export { default as Step } from './step.svelte'; +export { default as Secret } from './secret.svelte'; diff --git a/src/lib/components/secret.svelte b/src/lib/components/secret.svelte new file mode 100644 index 000000000..458005a93 --- /dev/null +++ b/src/lib/components/secret.svelte @@ -0,0 +1,28 @@ + + +
    + {#if show} + {value} + {:else} + •••••• + {/if} +
    + + + + +
    +
    diff --git a/src/routes/console/project-[project]/overview/keys/+page.svelte b/src/routes/console/project-[project]/overview/keys/+page.svelte index ebe4a4379..5f611048c 100644 --- a/src/routes/console/project-[project]/overview/keys/+page.svelte +++ b/src/routes/console/project-[project]/overview/keys/+page.svelte @@ -39,7 +39,7 @@ {key.name} - {toLocaleDateTime(key.$createdAt)} + {key.accessedAt ? toLocaleDateTime(key.accessedAt) : 'never'} {toLocaleDateTime(key.$updatedAt)} diff --git a/src/routes/console/project-[project]/overview/keys/[key]/+page@project-[project].svelte b/src/routes/console/project-[project]/overview/keys/[key]/+page@project-[project].svelte index a168fd26f..e84332823 100644 --- a/src/routes/console/project-[project]/overview/keys/[key]/+page@project-[project].svelte +++ b/src/routes/console/project-[project]/overview/keys/[key]/+page@project-[project].svelte @@ -2,16 +2,8 @@ import { afterNavigate } from '$app/navigation'; import { base } from '$app/paths'; import { page } from '$app/stores'; - import { CardGrid, Collapsible, CollapsibleItem } from '$lib/components'; - import { scopes } from '$lib/constants'; - import { - Button, - Form, - FormList, - InputChoice, - InputPassword, - InputText - } from '$lib/elements/forms'; + import { CardGrid, Secret } from '$lib/components'; + import { Button, Form, FormList, InputText } from '$lib/elements/forms'; import InputDateTime from '$lib/elements/forms/inputDateTime.svelte'; import { difference } from '$lib/helpers/array'; import { toLocaleDateTime } from '$lib/helpers/date'; @@ -21,39 +13,30 @@ import { sdkForConsole } from '$lib/stores/sdk'; import { onMount } from 'svelte'; import { project } from '../../../store'; + import Scopes from '../scopes.svelte'; import Delete from './delete.svelte'; import { key } from './store'; const projectId = $page.params.project; const keyId = $page.params.key; - const activeScopes = scopes.reduce((prev, next) => { - prev[next.scope] = false; - - return prev; - }, {}); let loaded = false; let showDelete = false; let name: string = null; let secret: string = null; let expire: string = null; + let scopes: string[] = null; onMount(handle); afterNavigate(handle); async function handle(event = null) { - const promise = key.load(projectId, keyId); - if ($key?.$id !== keyId) { - await promise; - } + await key.load(projectId, keyId); name ??= $key.name; secret ??= $key.secret; expire ??= $key.expire; - unselectAll(); - $key.scopes.forEach((scope) => { - activeScopes[scope] = true; - }); + scopes ??= $key.scopes; updateLayout({ navigate: event, @@ -120,13 +103,8 @@ async function updateScopes() { try { - await sdkForConsole.projects.updateKey( - $project.$id, - $key.$id, - $key.name, - selectedScoped - ); - $key.scopes = selectedScoped; + await sdkForConsole.projects.updateKey($project.$id, $key.$id, $key.name, scopes); + $key.scopes = scopes; addNotification({ type: 'success', message: 'API Key scopes has been updated' @@ -138,22 +116,6 @@ }); } } - - function selectAll() { - for (const scope in activeScopes) { - activeScopes[scope] = true; - } - } - - function unselectAll() { - for (const scope in activeScopes) { - activeScopes[scope] = false; - } - } - - $: selectedScoped = scopes - .filter((scope) => activeScopes[scope.scope]) - .map(({ scope }) => scope); @@ -162,13 +124,14 @@ {#if loaded} + {@const accessedAt = $key.accessedAt ? toLocaleDateTime($key.accessedAt) : 'never'}
    {$key.name}

    - Last accessed: {toLocaleDateTime($key.accessedAt)}
    + Last accessed: {accessedAt}
    Scopes granted: {$key.scopes.length}

    @@ -178,18 +141,9 @@
    API Key Secret
    - + - - - -
    @@ -220,35 +174,15 @@ practice to allow only the permissions you need to meet your project goals.

    -
    - - -
    - - {#each ['Authentication', 'Database', 'Functions', 'Storage', 'Other'] as category} - - {category} - - {#each scopes.filter((s) => s.category === category) as scope} - - {scope.description} - - {/each} - - - {/each} - +
    @@ -278,7 +212,7 @@
    {$key.name}
    -

    Last accessed: {toLocaleDateTime($key.accessedAt)}

    +

    Last accessed: {accessedAt}

    diff --git a/src/routes/console/project-[project]/overview/keys/create.svelte b/src/routes/console/project-[project]/overview/keys/create.svelte index 80765d20c..043cae7cb 100644 --- a/src/routes/console/project-[project]/overview/keys/create.svelte +++ b/src/routes/console/project-[project]/overview/keys/create.svelte @@ -1,32 +1,21 @@ - + Create API Key - {#each scopes as scope} - - {/each} + diff --git a/src/routes/console/project-[project]/overview/keys/scopes.svelte b/src/routes/console/project-[project]/overview/keys/scopes.svelte new file mode 100644 index 000000000..d60f14730 --- /dev/null +++ b/src/routes/console/project-[project]/overview/keys/scopes.svelte @@ -0,0 +1,72 @@ + + +
    + + +
    + + {#each ['Authentication', 'Database', 'Functions', 'Storage', 'Other'] as category} + + {category} + + {#each allScopes.filter((s) => s.category === category) as scope} + + {scope.description} + + {/each} + + + {/each} + From aa098beb91ee3a860a225d8175cba2909cdb710c Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 5 Oct 2022 17:58:52 +0200 Subject: [PATCH 16/22] add: tests --- tests/unit/components/secret.test.ts | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/unit/components/secret.test.ts diff --git a/tests/unit/components/secret.test.ts b/tests/unit/components/secret.test.ts new file mode 100644 index 000000000..5980bf226 --- /dev/null +++ b/tests/unit/components/secret.test.ts @@ -0,0 +1,46 @@ +import '@testing-library/jest-dom'; +import { vi } from 'vitest'; +import { render, fireEvent } from '@testing-library/svelte'; +import { Secret } from '../../../src/lib/components'; +import { tick } from 'svelte'; + +const value = 'This is a secret'; + +test('shows Secret component', () => { + const { container } = render(Secret, { value }); + const secret = container.querySelector('span.text'); + const toggle = container.querySelector('[aria-label="show hidden text"]'); + const copy = container.querySelector('[aria-label="copy text"]'); + + expect(secret).toBeInTheDocument(); + expect(toggle).toBeInTheDocument(); + expect(copy).toBeInTheDocument(); +}); + +test('toggle secret', async () => { + const { container } = render(Secret, { value }); + const toggle = container.querySelector('[aria-label="show hidden text"]'); + let secret = container.querySelector('span.text'); + expect(secret).not.toContainEqual(value); + await fireEvent.click(toggle); + secret = container.querySelector('span.text'); + expect(secret.textContent).toEqual(value); + await fireEvent.click(toggle); + secret = container.querySelector('span.text'); + expect(secret.textContent).not.toEqual(value); +}); + +test('copy to clipboard on click', async () => { + const { container } = render(Secret, { value }); + const copy = container.querySelector('[aria-label="copy text"]'); + + Object.assign(window.navigator, { + clipboard: { + writeText: vi.fn().mockImplementation(() => Promise.resolve()) + } + }); + + await fireEvent.click(copy); + + expect(window.navigator.clipboard.writeText).toHaveBeenCalledWith(value); +}); From 5e3f571c7aaab554edd4cccba1c1a7a330b2438b Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 5 Oct 2022 17:59:20 +0200 Subject: [PATCH 17/22] cleanup test file --- tests/unit/components/secret.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unit/components/secret.test.ts b/tests/unit/components/secret.test.ts index 5980bf226..7225ede9a 100644 --- a/tests/unit/components/secret.test.ts +++ b/tests/unit/components/secret.test.ts @@ -2,7 +2,6 @@ import '@testing-library/jest-dom'; import { vi } from 'vitest'; import { render, fireEvent } from '@testing-library/svelte'; import { Secret } from '../../../src/lib/components'; -import { tick } from 'svelte'; const value = 'This is a secret'; @@ -20,12 +19,15 @@ test('shows Secret component', () => { test('toggle secret', async () => { const { container } = render(Secret, { value }); const toggle = container.querySelector('[aria-label="show hidden text"]'); + let secret = container.querySelector('span.text'); expect(secret).not.toContainEqual(value); await fireEvent.click(toggle); + secret = container.querySelector('span.text'); expect(secret.textContent).toEqual(value); await fireEvent.click(toggle); + secret = container.querySelector('span.text'); expect(secret.textContent).not.toEqual(value); }); From e6f5d00d60f4e829f05bdb862c7b069a6f5e7d7b Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 5 Oct 2022 18:00:47 +0200 Subject: [PATCH 18/22] fix: increase default secret --- src/lib/components/secret.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/secret.svelte b/src/lib/components/secret.svelte index 458005a93..e44499b89 100644 --- a/src/lib/components/secret.svelte +++ b/src/lib/components/secret.svelte @@ -9,7 +9,7 @@ {#if show} {value} {:else} - •••••• + •••••••••••• {/if}