Skip to content

Commit ade4ad6

Browse files
committed
Moving debug to help, adding Banks drop down
1 parent 86150ca commit ade4ad6

3 files changed

Lines changed: 63 additions & 20 deletions

File tree

src/components/HeaderNav.vue

Lines changed: 55 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<script setup lang="ts">
2929
import { ref, inject, watchEffect, onMounted, onUnmounted, computed } from 'vue'
3030
import { useRoute, useRouter } from 'vue-router'
31-
import { OBP_API_DEFAULT_RESOURCE_DOC_VERSION, getCurrentUser } from '../obp'
31+
import { OBP_API_DEFAULT_RESOURCE_DOC_VERSION, getCurrentUser, getOBPBanks } from '../obp'
3232
import { getOBPAPIVersions } from '../obp/api-version'
3333
import {
3434
LOGO_URL as logoSource,
@@ -60,8 +60,20 @@ const combinedMessageDocs = computed(() => {
6060
return [...regularDocs, ...jsonSchemaDocs]
6161
})
6262
63-
// Debug menu items
64-
const debugMenuItems = ref(['/debug/providers-status', '/debug/oidc'])
63+
// Help menu items (includes debug pages)
64+
const helpMenuItems = ref(['/help', '/debug/providers-status', '/debug/oidc'])
65+
66+
// Banks state
67+
const banks = ref<Array<{ id: string; short_name: string; full_name: string }>>([])
68+
const bankItems = computed(() => banks.value.map(b => b.short_name || b.id))
69+
const selectedBankId = ref(localStorage.getItem('obp-selected-bank-id') || '')
70+
const banksDropdownLabel = computed(() => {
71+
if (selectedBankId.value) {
72+
const bank = banks.value.find(b => b.id === selectedBankId.value)
73+
return bank ? (bank.short_name || bank.id) : 'Banks'
74+
}
75+
return 'Banks'
76+
})
6577
6678
// Split versions into main and other
6779
const mainVersions = ['BGv1.3', 'OBPv5.1.0', 'OBPv6.0.0', 'UKv3.1', 'dynamic-endpoints', 'dynamic-entities', 'OBPdynamic-endpoint', 'OBPdynamic-entity']
@@ -227,6 +239,9 @@ const handleMore = (command: string, source?: string) => {
227239
// Regular message docs (connector names contain underscores)
228240
console.log('Navigating to message docs:', command)
229241
router.push({ name: 'message-docs', params: { id: command } })
242+
} else if (command === '/help') {
243+
console.log('Navigating to help page')
244+
router.push('/help')
230245
} else if (command.startsWith('/debug/')) {
231246
console.log('Navigating to debug page:', command)
232247
router.push(command)
@@ -238,7 +253,24 @@ const handleMore = (command: string, source?: string) => {
238253
}
239254
}
240255
256+
const handleBankSelect = (shortName: string) => {
257+
const bank = banks.value.find(b => (b.short_name || b.id) === shortName)
258+
if (bank) {
259+
selectedBankId.value = bank.id
260+
localStorage.setItem('obp-selected-bank-id', bank.id)
261+
}
262+
}
263+
241264
onMounted(async () => {
265+
// Fetch banks
266+
getOBPBanks().then((data) => {
267+
if (data && data.banks && Array.isArray(data.banks)) {
268+
banks.value = data.banks
269+
}
270+
}).catch((error) => {
271+
console.error('Failed to fetch banks:', error)
272+
})
273+
242274
// Fetch available providers
243275
await fetchAvailableProviders()
244276
@@ -292,9 +324,24 @@ const getCurrentPath = () => {
292324
<RouterLink class="router-link" id="header-nav-glossary" to="/glossary">{{
293325
$t('header.glossary')
294326
}}</RouterLink>
295-
<RouterLink class="router-link" id="header-nav-help" to="/help">{{
296-
$t('header.help')
297-
}}</RouterLink>
327+
<SvelteDropdown
328+
class="menu-right"
329+
id="header-nav-help"
330+
label="Help"
331+
:items="helpMenuItems"
332+
:hover-color="headerLinksHoverColor"
333+
:background-color="headerLinksBackgroundColor"
334+
@select="handleMore"
335+
/>
336+
<SvelteDropdown
337+
class="menu-right"
338+
id="header-nav-banks"
339+
:label="banksDropdownLabel"
340+
:items="bankItems"
341+
:hover-color="headerLinksHoverColor"
342+
:background-color="headerLinksBackgroundColor"
343+
@select="handleBankSelect"
344+
/>
298345
<a v-if="showObpApiManagerButton && hasObpApiManagerHost" v-bind:href="obpApiManagerHost" class="router-link" id="header-nav-api-manager">
299346
{{ $t('header.api_manager') }}
300347
</a>
@@ -316,15 +363,6 @@ const getCurrentPath = () => {
316363
:background-color="headerLinksBackgroundColor"
317364
@select="handleMore"
318365
/>
319-
<SvelteDropdown
320-
class="menu-right"
321-
id="header-nav-debug"
322-
label="Debug"
323-
:items="debugMenuItems"
324-
:hover-color="headerLinksHoverColor"
325-
:background-color="headerLinksBackgroundColor"
326-
@select="handleMore"
327-
/>
328366
<!--<span class="el-dropdown-link">
329367
<RouterLink class="router-link" id="header-nav-spaces" to="/spaces">{{
330368
$t('header.spaces')
@@ -529,7 +567,8 @@ button.login-button-disabled {
529567
/* Custom dropdown containers */
530568
#header-nav-versions,
531569
#header-nav-message-docs,
532-
#header-nav-debug {
570+
#header-nav-help,
571+
#header-nav-banks {
533572
display: inline-block;
534573
vertical-align: middle;
535574
}

src/components/SvelteDropdown.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ onBeforeUnmount(() => {
8787
8888
// Watch for prop changes and update Svelte component
8989
watch(
90-
() => props.items,
91-
(newItems) => {
90+
() => [props.items, props.label],
91+
([newItems, newLabel]) => {
9292
if (svelteComponent && containerRef.value) {
9393
// Remount with new props
9494
unmount(svelteComponent)
9595
svelteComponent = mount(Dropdown, {
9696
target: containerRef.value,
9797
props: {
98-
label: props.label,
99-
items: newItems,
98+
label: newLabel as string,
99+
items: newItems as string[],
100100
hoverColor: props.hoverColor,
101101
backgroundColor: props.backgroundColor
102102
}

src/obp/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,7 @@ export async function getMyAPICollectionsEndpoint(collectionName: string): Promi
199199
`/obp/${OBP_API_VERSION}/my/api-collections/${collectionName}/api-collection-endpoints`
200200
)
201201
}
202+
203+
export async function getOBPBanks(): Promise<any> {
204+
return await get(`obp/${OBP_API_VERSION}/banks`)
205+
}

0 commit comments

Comments
 (0)