From 1d06e4ef01f428ec1f0c9a5af0f0bd8be4115b1f Mon Sep 17 00:00:00 2001 From: Darshan Date: Sat, 31 May 2025 16:27:48 +0530 Subject: [PATCH 1/2] fix: teams pagination; add: spinner while data is fetched. --- src/lib/components/paginationInline.svelte | 8 +++-- src/lib/components/permissions/team.svelte | 34 ++++++++++++++++------ src/lib/components/permissions/user.svelte | 32 ++++++++++++++++---- 3 files changed, 56 insertions(+), 18 deletions(-) diff --git a/src/lib/components/paginationInline.svelte b/src/lib/components/paginationInline.svelte index 8ad8ab7f7..2d1b8a26c 100644 --- a/src/lib/components/paginationInline.svelte +++ b/src/lib/components/paginationInline.svelte @@ -35,6 +35,8 @@ } } + const none = undefined as never; + // function pagination(page: number, total: number) { // const pagesShown = 5; // const start = Math.max( @@ -56,11 +58,11 @@ {#if !hidePages} + createLink={none} + page={currentPage} + on:page={handleOptionClick} /> {:else} >; - let selected: Set = new Set(); + let isLoading = false; let hasSelection = false; + let selected: Set = new Set(); + let results: Models.TeamList>; function reset() { offset = 0; @@ -41,9 +43,11 @@ async function request() { if (!show) return; + isLoading = true; results = await sdk .forProject(page.params.region, page.params.project) .teams.list([Query.limit(5), Query.offset(offset)], search || undefined); + isLoading = false; } function onSelection(role: string) { @@ -71,23 +75,24 @@ - Grant access to any member of a specific team. To grant access to team members with specific roles, you will need to set a dispatch('custom')} >custom permission. {#if results?.teams?.length} - + {#each results.teams as team (team.$id)} {@const role = `team:${team.$id}`} {@const exists = $groups.has(role)} onSelection(role)} disabled={exists}> + disabled={exists} + checked={exists || selected.has(role)} /> @@ -105,10 +110,16 @@ {/each} -
+ +

Total results: {results?.total}

- -
+ +
{:else if search} + {:else if isLoading} + +
+ +
{:else} diff --git a/src/lib/components/permissions/user.svelte b/src/lib/components/permissions/user.svelte index 2c4022b7c..ccec958c0 100644 --- a/src/lib/components/permissions/user.svelte +++ b/src/lib/components/permissions/user.svelte @@ -14,6 +14,7 @@ Layout, Link, Selector, + Spinner, Table, Typography } from '@appwrite.io/pink-svelte'; @@ -27,9 +28,10 @@ let search = ''; let offset = 0; - let results: Models.UserList>; - let selected: Set = new Set(); + let isLoading = false; let hasSelection = false; + let selected: Set = new Set(); + let results: Models.UserList>; function reset() { offset = 0; @@ -44,9 +46,14 @@ async function request() { if (!show) return; + + isLoading = true; + results = await sdk .forProject(page.params.region, page.params.project) .users.list([Query.limit(5), Query.offset(offset)], search || undefined); + + isLoading = false; } function onSelection(role: string) { @@ -74,8 +81,11 @@ - Grant access to any authenticated or anonymous user. + Grant access to any authenticated or anonymous user. + + {#if results?.users?.length} {#each results.users as user (user.$id)} @@ -86,8 +96,8 @@ + disabled={exists} + checked={exists || selected.has(role)} /> @@ -141,7 +151,12 @@

Total results: {results?.total}

- +
{:else if search} @@ -153,6 +168,11 @@ size="s">Documentation + {:else if isLoading} + +
+ +
{:else} From 6f455d6f6ca4f2ce0a413ee447e06c67fc1547a8 Mon Sep 17 00:00:00 2001 From: Darshan Date: Sat, 31 May 2025 16:29:40 +0530 Subject: [PATCH 2/2] misc. --- src/lib/components/permissions/user.svelte | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/lib/components/permissions/user.svelte b/src/lib/components/permissions/user.svelte index ccec958c0..8c30e7968 100644 --- a/src/lib/components/permissions/user.svelte +++ b/src/lib/components/permissions/user.svelte @@ -46,13 +46,10 @@ async function request() { if (!show) return; - isLoading = true; - results = await sdk .forProject(page.params.region, page.params.project) .users.list([Query.limit(5), Query.offset(offset)], search || undefined); - isLoading = false; }