Skip to content

Commit 28cce58

Browse files
committed
Moving debug, adding bank_id drop down
1 parent ade4ad6 commit 28cce58

4 files changed

Lines changed: 45 additions & 12 deletions

File tree

components.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ declare module 'vue' {
3838
ElMain: typeof import('element-plus/es')['ElMain']
3939
ElRow: typeof import('element-plus/es')['ElRow']
4040
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
41-
ElTable: typeof import('element-plus/es')['ElTable']
42-
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
4341
ElTag: typeof import('element-plus/es')['ElTag']
4442
ElTooltip: typeof import('element-plus/es')['ElTooltip']
4543
GlossarySearchNav: typeof import('./src/components/GlossarySearchNav.vue')['default']

src/components/HeaderNav.vue

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,21 @@ const combinedMessageDocs = computed(() => {
6464
const helpMenuItems = ref(['/help', '/debug/providers-status', '/debug/oidc'])
6565
6666
// 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))
67+
const banks = ref<Array<{ bank_id: string; bank_code: string; full_name: string }>>([])
68+
const bankItems = computed(() =>
69+
[...banks.value]
70+
.sort((a, b) => (a.full_name || a.bank_id || '').localeCompare(b.full_name || b.bank_id || ''))
71+
.map(b => {
72+
const name = b.full_name || b.bank_id || ''
73+
const id = b.bank_id || ''
74+
return name !== id ? `${name} | ${id}` : id
75+
})
76+
)
6977
const selectedBankId = ref(localStorage.getItem('obp-selected-bank-id') || '')
7078
const banksDropdownLabel = computed(() => {
7179
if (selectedBankId.value) {
72-
const bank = banks.value.find(b => b.id === selectedBankId.value)
73-
return bank ? (bank.short_name || bank.id) : 'Banks'
80+
const bank = banks.value.find(b => b.bank_id === selectedBankId.value)
81+
return bank ? (bank.full_name || bank.bank_id) : 'Banks'
7482
}
7583
return 'Banks'
7684
})
@@ -253,11 +261,15 @@ const handleMore = (command: string, source?: string) => {
253261
}
254262
}
255263
256-
const handleBankSelect = (shortName: string) => {
257-
const bank = banks.value.find(b => (b.short_name || b.id) === shortName)
264+
const handleBankSelect = (item: string) => {
265+
// Extract bank_id from display format "full_name | bank_id" or just "bank_id"
266+
const parts = item.split(' | ')
267+
const bankId = parts[parts.length - 1]
268+
const bank = banks.value.find(b => b.bank_id === bankId)
258269
if (bank) {
259-
selectedBankId.value = bank.id
260-
localStorage.setItem('obp-selected-bank-id', bank.id)
270+
selectedBankId.value = bank.bank_id
271+
localStorage.setItem('obp-selected-bank-id', bank.bank_id)
272+
window.dispatchEvent(new CustomEvent('obp-bank-selected', { detail: bank.bank_id }))
261273
}
262274
}
263275

src/components/Preview.vue

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
-->
2727

2828
<script setup lang="ts">
29-
import { ref, reactive, inject, onBeforeMount } from 'vue'
29+
import { ref, reactive, inject, onBeforeMount, onMounted, onUnmounted } from 'vue'
3030
import { onBeforeRouteUpdate, useRoute } from 'vue-router'
3131
import { getOperationDetails } from '../obp/resource-docs'
3232
import { ElNotification, FormInstance } from 'element-plus'
@@ -73,6 +73,13 @@ const requestForm = reactive({ url: '' })
7373
const roleFormRef = reactive<FormInstance>({})
7474
const roleForm = reactive({})
7575
76+
const replaceUrlPlaceholders = () => {
77+
const selectedBankId = localStorage.getItem('obp-selected-bank-id')
78+
if (selectedBankId && url.value) {
79+
url.value = url.value.replace(/BANK_ID/g, selectedBankId)
80+
}
81+
}
82+
7683
const setOperationDetails = (id: string, version: string): void => {
7784
const operation = getOperationDetails(version, id, resourceDocs)
7885
@@ -93,6 +100,7 @@ const setOperationDetails = (id: string, version: string): void => {
93100
} else {
94101
url.value = operation?.specified_url
95102
}
103+
replaceUrlPlaceholders()
96104
method.value = operation?.request_verb
97105
exampleRequestBody.value = operation.example_request_body
98106
requiredRoles.value = operation.roles || []
@@ -609,6 +617,21 @@ onBeforeRouteUpdate(async (to) => {
609617
setRoleForm()
610618
})
611619
620+
const onBankSelected = (event: Event) => {
621+
const bankId = (event as CustomEvent).detail
622+
if (bankId && url.value) {
623+
url.value = url.value.replace(/BANK_ID/g, bankId)
624+
}
625+
}
626+
627+
onMounted(() => {
628+
window.addEventListener('obp-bank-selected', onBankSelected)
629+
})
630+
631+
onUnmounted(() => {
632+
window.removeEventListener('obp-bank-selected', onBankSelected)
633+
})
634+
612635
const copyToClipboard = () => {
613636
// Create a temporary text area to hold the content
614637
const textArea = document.createElement('textarea');

src/obp/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,5 +201,5 @@ export async function getMyAPICollectionsEndpoint(collectionName: string): Promi
201201
}
202202

203203
export async function getOBPBanks(): Promise<any> {
204-
return await get(`obp/${OBP_API_VERSION}/banks`)
204+
return await get(`obp/v6.0.0/banks`)
205205
}

0 commit comments

Comments
 (0)