Skip to content

Commit

Permalink
Merge pull request #4949 from FlowFuse/fix-main-nav-backToButton-race…
Browse files Browse the repository at this point in the history
…-condition

Fixes setMainNavBackButton race condition before a team is present after logging in
  • Loading branch information
knolleary authored Dec 20, 2024
2 parents 9c07b1b + 60a0e84 commit d29e97d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions frontend/src/components/drawers/navigation/MainNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default {
backToButton () {
const defaultBackToRoute = {
label: 'Back to Dashboard',
to: { name: 'Applications', params: { team_slug: this.team.slug } },
to: { name: 'Applications', params: { team_slug: this.team?.slug } },
tag: 'back',
icon: ChevronLeftIcon
}
Expand All @@ -93,7 +93,7 @@ export default {
return { ...defaultBackToRoute, ...this.nearestMetaMenu.backTo }
case isNearestMenuAnObject && hasBackToProp && typeof this.nearestMetaMenu.backTo === 'function':
return { ...defaultBackToRoute, ...this.nearestMetaMenu.backTo({ team_slug: this.team.slug }) }
return { ...defaultBackToRoute, ...this.nearestMetaMenu.backTo({ team_slug: this.team?.slug }) }
case typeof this.nearestMetaMenu === 'string':
default:
Expand All @@ -107,23 +107,25 @@ export default {
watch: {
nearestContextualMenu: {
handler: function (menu) {
if (Object.keys(this.mainNavContexts).includes(menu)) {
this.setMainNavContext(menu)
}
this.setMainNavContext(menu)
},
immediate: true
},
backToButton: {
handler: function (menu) {
this.setMainNavBackButton(menu)
},
handler: 'setBackButton',
immediate: true
}
},
team: 'setBackButton'
},
methods: {
...mapActions('ux', ['setMainNavContext', 'setMainNavBackButton']),
onMenuItemClick () {
this.$store.dispatch('ux/closeLeftDrawer')
},
setBackButton () {
if (this.team) {
this.setMainNavBackButton(this.backToButton)
}
}
}
}
Expand Down

0 comments on commit d29e97d

Please sign in to comment.