Skip to content

Commit dff1dbb

Browse files
committed
Fix: Fix errors related to navigation
Signed-off-by: Kostiantyn Miakshyn <[email protected]>
1 parent e9b11e5 commit dff1dbb

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/App.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Sidebar from './modules/sidebar/sections/Sidebar.vue'
2222
import { useResizeObserver } from '@vueuse/core'
2323
import { loadState } from '@nextcloud/initial-state'
2424
import { useTablesStore } from './store/store.js'
25+
import { generateUrl } from '@nextcloud/router'
2526
2627
export default {
2728
name: 'App',
@@ -44,7 +45,7 @@ export default {
4445
}
4546
},
4647
computed: {
47-
...mapState(useTablesStore, ['isLoadingSomething']),
48+
...mapState(useTablesStore, ['isLoadingSomething', 'activeView', 'activeTable', 'activeContext']),
4849
},
4950
watch: {
5051
'$route'(to, from) {
@@ -63,6 +64,8 @@ export default {
6364
methods: {
6465
...mapActions(useTablesStore, ['loadTablesFromBE', 'getAllContexts', 'loadViewsSharedWithMeFromBE', 'loadTemplatesFromBE', 'setActiveRowId', 'setActiveTableId', 'setActiveViewId', 'setActiveContextId']),
6566
routing(currentRoute) {
67+
const url = generateUrl('/apps/tables/')
68+
6669
try {
6770
if (loadState('tables', 'contextId', undefined)) {
6871
// prepare route, when Context is opened from navigation bar
@@ -85,20 +88,20 @@ export default {
8588
this.setActiveTableId(parseInt(currentRoute.params.tableId))
8689
this.setPageTitle(this.activeTable.title)
8790
if (!currentRoute.path.includes('/row/')) {
88-
this.switchActiveMenuEntry(document.querySelector('header .header-left .app-menu a[title="Tables"]'))
91+
this.switchActiveMenuEntry(document.querySelector(`header .header-start .app-menu a[href="${url}"]`))
8992
}
9093
} else if (currentRoute.path.startsWith('/view/')) {
9194
this.setActiveViewId(parseInt(currentRoute.params.viewId))
9295
this.setPageTitle(this.activeView.title)
9396
if (!currentRoute.path.includes('/row/')) {
94-
this.switchActiveMenuEntry(document.querySelector('header .header-left .app-menu a[title="Tables"]'))
97+
this.switchActiveMenuEntry(document.querySelector(`header .header-start .app-menu a[href="${url}"]`))
9598
}
9699
} else if (currentRoute.path.startsWith('/application/')) {
97100
const contextId = parseInt(currentRoute.params.contextId)
98101
this.setActiveContextId(contextId)
99102
this.setPageTitle(this.activeContext.name)
100103
// This breaks if there are multiple contexts with the same name or another app has the same name. We need a better way to identify the correct element.
101-
this.switchActiveMenuEntry(document.querySelector(`header .header-left .app-menu [title="${this.activeContext.name}"]`))
104+
this.switchActiveMenuEntry(document.querySelector(`header .header-start .app-menu [title="${this.activeContext.name}"]`))
102105
103106
// move the focus away from nav bar (import for app-internal switch)
104107
const appContent = document.getElementById('app-content-vue')
@@ -112,7 +115,7 @@ export default {
112115
},
113116
switchActiveMenuEntry(targetElement) {
114117
targetElement = targetElement?.tagName?.toLowerCase() === 'a' ? targetElement.parentElement : targetElement
115-
const currentlyActive = document.querySelector('header .header-left .app-menu li.app-menu-entry--active')
118+
const currentlyActive = document.querySelector('header .header-start .app-menu li.app-menu-entry--active')
116119
currentlyActive.classList.remove('app-menu-entry--active')
117120
targetElement.classList.add('app-menu-entry--active')
118121
},

src/modules/navigation/partials/NavigationTableItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
<template #actions>
3636
<!-- EDIT -->
37-
<NcActionButton v-if="canManageElement(table) "
37+
<NcActionButton v-if="canManageElement(table)"
3838
:close-after-click="true"
3939
@click="emit('tables:table:edit', table.id)">
4040
<template #icon>

0 commit comments

Comments
 (0)