Skip to content

Commit

Permalink
Include SharedResource route in active state of Shares nav item
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Apr 27, 2022
1 parent edb8de4 commit 2f412bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/web-app-files/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ const navItems = [
icon: 'share-forward',
route: {
path: `/${appInfo.id}/shares`
}
},
activeFor: [{ path: `/${appInfo.id}/spaces/shares` }]
},
{
name: $gettext('Spaces'),
Expand Down
18 changes: 15 additions & 3 deletions packages/web-runtime/src/layouts/Application.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,26 @@ export default defineComponent({
const { href: currentHref } = this.$router.resolve(this.$route)
return items.map((item) => {
const { href: comparativeHref } = this.$router.resolve(item.route)
const active = [item.route, ...(item.activeFor || [])]
.filter(Boolean)
.reduce((result, currentItem) => {
if (result) {
return true
}
try {
const comparativeHref = this.$router.resolve(currentItem).href
return currentHref.startsWith(comparativeHref)
} catch (e) {
console.error(e)
return false
}
}, false)
const name = typeof item.name === 'function' ? item.name(this.capabilities) : item.name
return {
...item,
name: this.$gettext(name),
active: currentHref.startsWith(comparativeHref)
active
}
})
},
Expand Down

0 comments on commit 2f412bd

Please sign in to comment.