Skip to content

Commit 046ba2d

Browse files
committed
when change version show endpoint count instead of first endpoint
1 parent 6a83e54 commit 046ba2d

4 files changed

Lines changed: 100 additions & 25 deletions

File tree

src/components/Content.vue

Lines changed: 63 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ const prev = ref({ id: 'prev' })
5353
const next = ref({ id: 'next' })
5454
const favoriteButtonStyle = ref('favorite favoriteButton')
5555
const summaryPagerLinksColor = ref(summaryPagerLinksColorSetting)
56+
const showPlaceholder = ref(false)
57+
const placeholderVersion = ref('')
58+
const totalEndpoints = ref(0)
5659
let routeId = ''
5760
let version = obpVersion
5861
let isFavorite = false
@@ -144,35 +147,60 @@ const showNotification = (message: string, type: string): void => {
144147
onMounted(async () => {
145148
routeId = route.query.operationid
146149
version = route.params.version ? route.params.version : obpVersion
147-
setOperationDetails(routeId, version)
148-
setPager(routeId)
149-
await tagFavoriteButton(routeId)
150+
151+
if (!routeId) {
152+
// No operation selected, show placeholder
153+
showPlaceholder.value = true
154+
placeholderVersion.value = version
155+
totalEndpoints.value = resourceDocs[version]?.resource_docs?.length || 0
156+
} else {
157+
showPlaceholder.value = false
158+
setOperationDetails(routeId, version)
159+
setPager(routeId)
160+
await tagFavoriteButton(routeId)
161+
}
150162
})
151163
onBeforeRouteUpdate(async (to) => {
152164
routeId = to.query.operationid
153165
version = to.params.version ? to.params.version : obpVersion
154-
setOperationDetails(routeId, version)
155-
setPager(routeId)
156-
await tagFavoriteButton(routeId)
166+
167+
if (!routeId) {
168+
// No operation selected, show placeholder
169+
showPlaceholder.value = true
170+
placeholderVersion.value = version
171+
totalEndpoints.value = resourceDocs[version]?.resource_docs?.length || 0
172+
} else {
173+
showPlaceholder.value = false
174+
setOperationDetails(routeId, version)
175+
setPager(routeId)
176+
await tagFavoriteButton(routeId)
177+
}
157178
})
158179
</script>
159180

160181
<template>
161182
<main>
162183
<el-container>
163184
<el-main>
164-
<el-row>
165-
<el-col :span="22">
166-
<span>{{ summary }}</span>
167-
</el-col>
168-
<el-col :span="2">
169-
<span :class="favoriteButtonStyle" @click="createDeleteFavorite()">★</span>
170-
<!--<el-button text>★</el-button>-->
171-
</el-col>
172-
</el-row>
173-
<div v-html="description" class="content"></div>
185+
<div v-if="showPlaceholder" class="placeholder-message">
186+
<h2>Version {{ placeholderVersion }} Selected</h2>
187+
<p>There are {{ totalEndpoints }} endpoints available in this version.</p>
188+
<p>Please click an endpoint on the left to view its details.</p>
189+
</div>
190+
<div v-else>
191+
<el-row>
192+
<el-col :span="22">
193+
<span>{{ summary }}</span>
194+
</el-col>
195+
<el-col :span="2">
196+
<span :class="favoriteButtonStyle" @click="createDeleteFavorite()">★</span>
197+
<!--<el-button text>★</el-button>-->
198+
</el-col>
199+
</el-row>
200+
<div v-html="description" class="content"></div>
201+
</div>
174202
</el-main>
175-
<el-footer class="footer">
203+
<el-footer class="footer" v-if="!showPlaceholder">
176204
<el-divider class="divider" />
177205
<el-row>
178206
<el-col :span="12" class="pager-left">
@@ -208,6 +236,24 @@ span {
208236
font-size: 28px;
209237
}
210238
239+
.placeholder-message {
240+
text-align: center;
241+
padding: 60px 20px;
242+
color: #606266;
243+
}
244+
245+
.placeholder-message h2 {
246+
font-size: 24px;
247+
margin-bottom: 20px;
248+
color: #39455f;
249+
}
250+
251+
.placeholder-message p {
252+
font-size: 16px;
253+
margin: 10px 0;
254+
line-height: 1.6;
255+
}
256+
211257
div {
212258
font-size: 14px;
213259
}

src/components/HeaderNav.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const handleMore = (command: string) => {
8989
console.log('Navigating to resource docs:', `/resource-docs/${command}`)
9090
console.log('Current route:', route.path)
9191
// Clear operationid query param when changing versions to avoid showing non-existent operation
92-
router.replace({ path: `/resource-docs/${command}`, query: {} })
92+
router.push(`/resource-docs/${command}`)
9393
}
9494
}
9595

src/components/Preview.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,25 @@ const submitEntitlement = async () => {
401401
onBeforeMount(async () => {
402402
const route = useRoute()
403403
const version = route.params.version ? route.params.version : configVersion
404-
setOperationDetails(route.query.operationid, version)
404+
405+
// Only set operation details if operationid exists
406+
if (route.query.operationid) {
407+
setOperationDetails(route.query.operationid, version)
408+
}
405409
406410
const currentUser = await getCurrentUser()
407411
isUserLogon.value = currentUser.username
408412
setRoleForm()
409413
})
410414
onBeforeRouteUpdate((to) => {
411415
const version = to.params.version ? to.params.version : configVersion
412-
setOperationDetails(to.query.operationid, version)
413-
responseHeaderTitle.value = 'TYPICAL SUCCESSFUL RESPONSE'
416+
417+
// Only set operation details if operationid exists
418+
if (to.query.operationid) {
419+
setOperationDetails(to.query.operationid, version)
420+
responseHeaderTitle.value = 'TYPICAL SUCCESSFUL RESPONSE'
421+
}
422+
414423
setRoleForm()
415424
})
416425

src/components/SearchNav.vue

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,32 @@ onBeforeMount(async () => {
107107
})
108108
109109
onMounted(async () => {
110-
await nextTick()
111-
routeToFirstAPI()
110+
// Only auto-route if there's already an operationid in the URL
111+
if (route.query.operationid) {
112+
await nextTick()
113+
routeToFirstAPI()
114+
}
112115
})
113116
114117
watch(
115118
() => route.params.version,
116119
async (version) => {
120+
console.log('SearchNav: version changed to:', version)
117121
selectedVersion = version
118122
docs.value = getGroupedResourceDocs(version, resourceDocs.value)
119123
groups.value = JSON.parse(JSON.stringify(docs.value))
120124
activeKeys.value = Object.keys(groups.value)
121125
sortedKeys.value = activeKeys.value.sort()
126+
console.log('SearchNav: groups loaded, total groups:', activeKeys.value.length)
122127
await initializeAPICollections()
123128
await nextTick()
124-
routeToFirstAPI()
129+
// Only auto-route if there's an operationid in the URL (user navigated directly to an endpoint)
130+
if (route.query.operationid) {
131+
console.log('SearchNav: calling routeToFirstAPI')
132+
routeToFirstAPI()
133+
} else {
134+
console.log('SearchNav: no operationid, not auto-routing')
135+
}
125136
countApis()
126137
}
127138
)
@@ -139,17 +150,26 @@ const countApis = () => {
139150
const routeToFirstAPI = () => {
140151
let element
141152
const elements = document.getElementsByClassName('api-router-link')
153+
console.log('routeToFirstAPI: found', elements.length, 'api links')
142154
const id = route.query.operationid
155+
console.log('routeToFirstAPI: looking for operationid:', id)
143156
for (const el of elements) {
144157
if (el.id === id) {
145158
element = el
146159
break
147160
}
148161
}
149162
if (element) {
163+
console.log('routeToFirstAPI: clicking matching element:', id)
150164
element.click()
151165
} else {
152-
if (elements.item(0)) elements.item(0).click()
166+
console.log('routeToFirstAPI: no match, clicking first element')
167+
if (elements.item(0)) {
168+
console.log('routeToFirstAPI: first element id:', elements.item(0).id)
169+
elements.item(0).click()
170+
} else {
171+
console.log('routeToFirstAPI: NO ELEMENTS FOUND!')
172+
}
153173
}
154174
}
155175

0 commit comments

Comments
 (0)