diff --git a/frontend/src/components/drawers/navigation/MainNav.vue b/frontend/src/components/drawers/navigation/MainNav.vue index b83fe6b816..4ece80038d 100644 --- a/frontend/src/components/drawers/navigation/MainNav.vue +++ b/frontend/src/components/drawers/navigation/MainNav.vue @@ -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 } @@ -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: @@ -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) + } } } }