From d15dbf77ffcd2c173e7889f18bf0db5a4e413e39 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Mon, 4 May 2026 11:13:59 +0530 Subject: [PATCH 1/4] Derive scope categories from backend data --- .../overview/api-keys/scopes.svelte | 51 ++++--------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte b/src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte index 7309623b52..aec5705c40 100644 --- a/src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte +++ b/src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte @@ -51,30 +51,6 @@ Database: 'Databases' }; - enum Category { - Project = 'Project', - Auth = 'Auth', - Databases = 'Databases', - Functions = 'Functions', - Messaging = 'Messaging', - Sites = 'Sites', - Storage = 'Storage', - Domains = 'Domains', - Other = 'Other' - } - - const categoryOrder = [ - Category.Project, - Category.Auth, - Category.Databases, - Category.Functions, - Category.Storage, - Category.Messaging, - Category.Sites, - Category.Domains, - Category.Other - ]; - function normalizeCategory(category: string): string { return categoryAliasMap[category] ?? category; } @@ -95,16 +71,9 @@ }); const categories = $derived.by(() => { - const availableCategories = new Set( - filteredScopes.map((scope) => normalizeCategory(scope.category)) + return Array.from( + new Set(filteredScopes.map((scope) => normalizeCategory(scope.category))) ); - - return [ - ...categoryOrder.filter((category) => availableCategories.has(category)), - ...Array.from(availableCategories).filter( - (category) => !categoryOrder.includes(category as Category) - ) - ]; }); const scopeCatalog = $derived( @@ -130,13 +99,6 @@ const result = await sdk.forConsole.console.listProjectScopes(); const scopesById = new Map(); - for (const scope of localScopes) { - scopesById.set(scope.scope, { - ...scope, - category: normalizeCategory(scope.category) - }); - } - for (const scope of result.scopes) { scopesById.set(scope.$id, { scope: scope.$id, @@ -147,6 +109,15 @@ }); } + for (const scope of localScopes) { + if (!scopesById.has(scope.scope)) { + scopesById.set(scope.scope, { + ...scope, + category: normalizeCategory(scope.category) + }); + } + } + allScopesList = Array.from(scopesById.values()); for (const s of filteredScopes) { From 62924e130d131ff38fdcc3708cd9b3c9abe028bb Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Mon, 4 May 2026 11:18:32 +0530 Subject: [PATCH 2/4] Fix repeated cloud scopes and deprecated badge copy --- .../overview/api-keys/scopes.svelte | 42 ++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte b/src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte index aec5705c40..826a37324c 100644 --- a/src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte +++ b/src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte @@ -56,15 +56,34 @@ } const filteredScopes = $derived.by(() => { + const scopesById = new Map(allScopesList.map((scope) => [scope.scope, scope])); + const databasesWriteIndex = allScopesList.findIndex((s) => s.scope === 'databases.write'); if (isCloud && databasesWriteIndex !== -1) { + const normalizedBackupScopes = cloudOnlyBackupScopes.map((scope) => ({ + ...scope, + category: normalizeCategory(scope.category) + })); + const backupScopeIds = new Set(normalizedBackupScopes.map((scope) => scope.scope)); + + for (const scope of normalizedBackupScopes) { + if (!scopesById.has(scope.scope)) { + scopesById.set(scope.scope, scope); + } + } + + const mergedScopes = Array.from(scopesById.values()); + const nonBackupScopes = mergedScopes.filter( + (scope) => !backupScopeIds.has(scope.scope) + ); + const mergedDatabasesWriteIndex = nonBackupScopes.findIndex( + (s) => s.scope === 'databases.write' + ); + return [ - ...allScopesList.slice(0, databasesWriteIndex + 1), - ...cloudOnlyBackupScopes.map((scope) => ({ - ...scope, - category: normalizeCategory(scope.category) - })), - ...allScopesList.slice(databasesWriteIndex + 1) + ...nonBackupScopes.slice(0, mergedDatabasesWriteIndex + 1), + ...normalizedBackupScopes.map((scope) => scopesById.get(scope.scope) ?? scope), + ...nonBackupScopes.slice(mergedDatabasesWriteIndex + 1) ]; } return allScopesList; @@ -76,12 +95,7 @@ ); }); - const scopeCatalog = $derived( - new Set([ - ...filteredScopes.map((s) => s.scope), - ...(isCloud ? cloudOnlyBackupScopes.map((s) => s.scope) : []) - ]) - ); + const scopeCatalog = $derived(new Set(filteredScopes.map((s) => s.scope))); let activeScopes: Record = $state({}); @@ -206,11 +220,11 @@ on:change={(event) => onCategoryChange(event, category)}> {#each filteredScopes.filter((s) => s.category === category) as scope} - + {#if scope.deprecated} From ce6fdc5a6aaec5d9fa5d2c1f95016decbb0ea3f6 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Mon, 4 May 2026 11:20:38 +0530 Subject: [PATCH 3/4] Align deprecated badge with scope name --- .../overview/api-keys/scopes.svelte | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte b/src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte index 826a37324c..045c8e7f92 100644 --- a/src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte +++ b/src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte @@ -37,7 +37,15 @@ type ScopeDefinition } from '$lib/constants'; import { sdk } from '$lib/stores/sdk'; - import { Accordion, Alert, Badge, Divider, Layout, Selector } from '@appwrite.io/pink-svelte'; + import { + Accordion, + Alert, + Badge, + Divider, + Layout, + Selector, + Typography + } from '@appwrite.io/pink-svelte'; import type { Scopes } from '@appwrite.io/console'; let { scopes = $bindable([]) }: { scopes: Scopes[] } = $props(); @@ -220,16 +228,25 @@ on:change={(event) => onCategoryChange(event, category)}> {#each filteredScopes.filter((s) => s.category === category) as scope} - + - {#if scope.deprecated} - - {/if} + + + + {#if scope.deprecated} + + {/if} + + + {scope.description} + + {/each} @@ -237,3 +254,9 @@ {/each} + + From 52eb56934a3d23965f6d432545a0ba2e2e2b57ed Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Mon, 4 May 2026 12:09:50 +0530 Subject: [PATCH 4/4] Make scope descriptions toggle checkboxes --- .../overview/api-keys/scopes.svelte | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte b/src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte index 045c8e7f92..1209581be0 100644 --- a/src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte +++ b/src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte @@ -234,18 +234,29 @@ id={scope.scope} bind:checked={activeScopes[scope.scope]} /> - - - {#if scope.deprecated} - - {/if} - - - {scope.description} - + {/each}