Skip to content

Commit bf89736

Browse files
committed
System / Bank / Both
1 parent 07844ac commit bf89736

File tree

3 files changed

+84
-47
lines changed

3 files changed

+84
-47
lines changed

src/lib/config/navigation.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,20 @@ export function getActiveBanksMenuItem(pathname: string) {
341341
function buildDynamicEntitiesItems(): NavigationItem[] {
342342
const items: NavigationItem[] = [
343343
{
344-
href: "/dynamic-entities/system",
344+
href: "/dynamic-entities/system?level=system",
345345
label: "System",
346346
iconComponent: Settings,
347347
},
348+
{
349+
href: "/dynamic-entities/system?level=bank",
350+
label: "Bank",
351+
iconComponent: Building2,
352+
},
353+
{
354+
href: "/dynamic-entities/system?level=both",
355+
label: "System + Bank",
356+
iconComponent: Box,
357+
},
348358
{
349359
href: "/dynamic-entities/personal",
350360
label: "Personal",

src/routes/(protected)/dynamic-entities/system/+page.svelte

Lines changed: 69 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313
1414
let { data }: { data: PageData } = $props();
1515
16+
// Read level from query param: system, bank, or both (default)
17+
let level = $derived<"system" | "bank" | "both">(
18+
(() => {
19+
const param = $page.url.searchParams.get("level");
20+
if (param === "system" || param === "bank") return param;
21+
return "both";
22+
})()
23+
);
24+
25+
let showSystem = $derived(level === "system" || level === "both");
26+
let showBank = $derived(level === "bank" || level === "both");
27+
1628
let userEntitlements = $derived(data.userEntitlements || []);
1729
1830
let hasSystemReadRole = $derived(
@@ -83,10 +95,10 @@
8395
return entity.schema || null;
8496
}
8597
86-
// Combine system and bank entities with a level marker
98+
// Combine system and bank entities with a level marker, filtered by query param
8799
const allEntities = $derived([
88-
...(data.entities || []).map((e: any) => ({ ...e, _level: "System" })),
89-
...bankEntities.map((e: any) => ({ ...e, _level: "Bank" })),
100+
...(showSystem ? (data.entities || []).map((e: any) => ({ ...e, _level: "System" })) : []),
101+
...(showBank ? bankEntities.map((e: any) => ({ ...e, _level: "Bank" })) : []),
90102
]);
91103
92104
const filteredEntities = $derived(
@@ -195,18 +207,24 @@
195207
</script>
196208

197209
<svelte:head>
198-
<title>System Dynamic Entities - API Manager</title>
210+
<title>{level === "system" ? "System" : level === "bank" ? "Bank" : ""} Dynamic Entities - API Manager</title>
199211
</svelte:head>
200212

201213
<div class="container mx-auto px-4 py-8">
202214
<!-- Header -->
203215
<div class="mb-6 flex items-center justify-between">
204216
<div>
205217
<h1 class="text-3xl font-bold text-gray-900 dark:text-gray-100">
206-
Dynamic Entities
218+
{level === "system" ? "System" : level === "bank" ? "Bank" : ""} Dynamic Entities
207219
</h1>
208220
<p class="mt-1 text-gray-600 dark:text-gray-400">
209-
System-wide and bank-level dynamic data entities
221+
{#if level === "system"}
222+
System-wide dynamic data entities
223+
{:else if level === "bank"}
224+
Bank-level dynamic data entities{#if currentBank.bank} for {currentBank.bank.full_name || currentBank.bankId}{/if}
225+
{:else}
226+
System-wide and bank-level dynamic data entities
227+
{/if}
210228
</p>
211229
</div>
212230
<a
@@ -232,30 +250,34 @@
232250

233251
<!-- Stats -->
234252
<div class="mb-6 flex items-center gap-4">
235-
<div
236-
class="rounded-lg border border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-800"
237-
>
238-
<div class="text-sm text-gray-600 dark:text-gray-400">System</div>
239-
<div class="mt-1 text-2xl font-bold text-gray-900 dark:text-gray-100">
240-
{data.entities?.length || 0}
241-
</div>
242-
</div>
243-
<div
244-
class="rounded-lg border border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-800"
245-
>
246-
<div class="text-sm text-gray-600 dark:text-gray-400">
247-
Bank {#if currentBank.bank}({currentBank.bank.full_name || currentBank.bank.short_name || currentBank.bankId}){/if}
253+
{#if showSystem}
254+
<div
255+
class="rounded-lg border border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-800"
256+
>
257+
<div class="text-sm text-gray-600 dark:text-gray-400">System</div>
258+
<div class="mt-1 text-2xl font-bold text-gray-900 dark:text-gray-100">
259+
{data.entities?.length || 0}
260+
</div>
248261
</div>
249-
<div class="mt-1 text-2xl font-bold text-gray-900 dark:text-gray-100">
250-
{#if bankEntitiesLoading}
251-
<span class="text-sm text-gray-400">...</span>
252-
{:else if currentBank.bankId}
253-
{bankEntities.length}
254-
{:else}
255-
<span class="text-sm text-gray-400">-</span>
256-
{/if}
262+
{/if}
263+
{#if showBank}
264+
<div
265+
class="rounded-lg border border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-800"
266+
>
267+
<div class="text-sm text-gray-600 dark:text-gray-400">
268+
Bank {#if currentBank.bank}({currentBank.bank.full_name || currentBank.bank.short_name || currentBank.bankId}){/if}
269+
</div>
270+
<div class="mt-1 text-2xl font-bold text-gray-900 dark:text-gray-100">
271+
{#if bankEntitiesLoading}
272+
<span class="text-sm text-gray-400">...</span>
273+
{:else if currentBank.bankId}
274+
{bankEntities.length}
275+
{:else}
276+
<span class="text-sm text-gray-400">-</span>
277+
{/if}
278+
</div>
257279
</div>
258-
</div>
280+
{/if}
259281
<div class="flex gap-2">
260282
<a
261283
href={apiExplorerDynamicEntityUrl}
@@ -377,7 +399,7 @@
377399
</div>
378400
{/if}
379401

380-
{#if bankEntitiesError}
402+
{#if showBank && bankEntitiesError}
381403
<div
382404
class="mb-6 rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-800 dark:bg-amber-900/20"
383405
>
@@ -388,13 +410,13 @@
388410
{/if}
389411

390412
<!-- Role Checks -->
391-
{#if !hasSystemReadRole}
413+
{#if showSystem && !hasSystemReadRole}
392414
<MissingRoleAlert
393415
roles={["CanGetSystemLevelDynamicEntities"]}
394416
message="You need this role to list system-level dynamic entities"
395417
/>
396418
{/if}
397-
{#if currentBank.bankId && !hasBankReadRole}
419+
{#if showBank && currentBank.bankId && !hasBankReadRole}
398420
<MissingRoleAlert
399421
roles={["CanGetBankLevelDynamicEntities"]}
400422
bankId={currentBank.bankId}
@@ -484,11 +506,13 @@
484506
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
485507
<thead class="bg-gray-50 dark:bg-gray-900">
486508
<tr>
487-
<th
488-
class="px-3 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-400"
489-
>
490-
Level
491-
</th>
509+
{#if level === "both"}
510+
<th
511+
class="px-3 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-400"
512+
>
513+
Level
514+
</th>
515+
{/if}
492516
<th
493517
class="px-3 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-400"
494518
>
@@ -527,13 +551,15 @@
527551
{#each filteredEntities as entity}
528552
{@const schema = getSchema(entity)}
529553
<tr class="hover:bg-gray-50 dark:hover:bg-gray-700/50">
530-
<td class="whitespace-nowrap px-3 py-3 text-sm">
531-
{#if entity._level === "System"}
532-
<span class="inline-flex items-center rounded-full bg-purple-100 px-2 py-0.5 text-xs font-medium text-purple-800 dark:bg-purple-900/30 dark:text-purple-300">System</span>
533-
{:else}
534-
<span class="inline-flex items-center rounded-full bg-blue-100 px-2 py-0.5 text-xs font-medium text-blue-800 dark:bg-blue-900/30 dark:text-blue-300">Bank</span>
535-
{/if}
536-
</td>
554+
{#if level === "both"}
555+
<td class="whitespace-nowrap px-3 py-3 text-sm">
556+
{#if entity._level === "System"}
557+
<span class="inline-flex items-center rounded-full bg-purple-100 px-2 py-0.5 text-xs font-medium text-purple-800 dark:bg-purple-900/30 dark:text-purple-300">System</span>
558+
{:else}
559+
<span class="inline-flex items-center rounded-full bg-blue-100 px-2 py-0.5 text-xs font-medium text-blue-800 dark:bg-blue-900/30 dark:text-blue-300">Bank</span>
560+
{/if}
561+
</td>
562+
{/if}
537563
<td class="whitespace-nowrap px-3 py-3 text-sm font-medium">
538564
<a
539565
href="/dynamic-entities/system/{entity.dynamic_entity_id}"

src/routes/+layout.svelte

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,13 +455,14 @@
455455
<Navigation.Menu class="mt-1 ml-4 flex flex-col gap-1 px-2">
456456
{#each section.items as subItem}
457457
{@const SubIcon = subItem.iconComponent}
458+
{@const currentUrl = page.url.pathname + page.url.search}
458459
<a
459460
href={subItem.href}
460461
class="btn w-full justify-start gap-3 px-2 pl-6 text-sm hover:preset-tonal"
461-
class:preset-filled-secondary-50-950={page.url.pathname ===
462+
class:preset-filled-secondary-50-950={currentUrl ===
462463
subItem.href}
463-
class:border-l-2={page.url.pathname === subItem.href}
464-
class:border-primary-500={page.url.pathname ===
464+
class:border-l-2={currentUrl === subItem.href}
465+
class:border-primary-500={currentUrl ===
465466
subItem.href}
466467
title={subItem.label}
467468
aria-label={subItem.label}

0 commit comments

Comments
 (0)