From 62924e130d131ff38fdcc3708cd9b3c9abe028bb Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Mon, 4 May 2026 11:18:32 +0530 Subject: [PATCH] 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 aec5705c4..826a37324 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}