Skip to content

Commit 397abec

Browse files
authored
[Enhancement] Highlight AppNav item on Refresh (#2894)
* [Enhancement] Highlight AppNav item on Refresh * EsLint * SonarQube updates * Linter:
1 parent b7a5b9b commit 397abec

File tree

1 file changed

+25
-0
lines changed
  • openc3-cosmos-init/plugins/packages/openc3-vue-common/src/tools/base

1 file changed

+25
-0
lines changed

openc3-cosmos-init/plugins/packages/openc3-vue-common/src/tools/base/AppNav.vue

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<v-treeview
4949
:items="items"
5050
:opened="initiallyOpen"
51+
:activated="activeItems"
5152
item-value="name"
5253
density="compact"
5354
class="ml-2"
@@ -193,6 +194,7 @@ export default {
193194
logo: '/img/logo.png',
194195
wordmark: '/img/COSMOS.svg',
195196
initiallyOpen: [],
197+
activeItems: [],
196198
showUpgradeToEnterpriseDialog: false,
197199
chromeless: null,
198200
}
@@ -338,6 +340,7 @@ export default {
338340
start({
339341
urlRerouteOnly: true,
340342
})
343+
this.updateActiveItem()
341344
342345
// Check every minute if we need to update our token
343346
setInterval(() => {
@@ -350,8 +353,30 @@ export default {
350353
},
351354
)
352355
},
356+
mounted() {
357+
globalThis.addEventListener(
358+
'single-spa:routing-event',
359+
this.updateActiveItem,
360+
)
361+
},
362+
beforeUnmount() {
363+
globalThis.removeEventListener(
364+
'single-spa:routing-event',
365+
this.updateActiveItem,
366+
)
367+
},
353368
methods: {
354369
navigateToUrl,
370+
updateActiveItem() {
371+
const path = globalThis.location.pathname
372+
const allTools = this.items.flatMap((item) =>
373+
item.children ? item.children : [item],
374+
)
375+
const match = allTools.find(
376+
(tool) => tool.url && path.startsWith(tool.url),
377+
)
378+
this.activeItems = match ? [match.name] : []
379+
},
355380
newTabUrl(tool) {
356381
let url = null
357382
try {

0 commit comments

Comments
 (0)