Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fix errors related to navigation #1623

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Sidebar from './modules/sidebar/sections/Sidebar.vue'
import { useResizeObserver } from '@vueuse/core'
import { loadState } from '@nextcloud/initial-state'
import { useTablesStore } from './store/store.js'
import { generateUrl } from '@nextcloud/router'

export default {
name: 'App',
Expand All @@ -44,7 +45,7 @@ export default {
}
},
computed: {
...mapState(useTablesStore, ['isLoadingSomething']),
...mapState(useTablesStore, ['isLoadingSomething', 'activeView', 'activeTable', 'activeContext']),
},
watch: {
'$route'(to, from) {
Expand All @@ -63,6 +64,8 @@ export default {
methods: {
...mapActions(useTablesStore, ['loadTablesFromBE', 'getAllContexts', 'loadViewsSharedWithMeFromBE', 'loadTemplatesFromBE', 'setActiveRowId', 'setActiveTableId', 'setActiveViewId', 'setActiveContextId']),
routing(currentRoute) {
const url = generateUrl('/apps/tables/')

try {
if (loadState('tables', 'contextId', undefined)) {
// prepare route, when Context is opened from navigation bar
Expand All @@ -85,20 +88,20 @@ export default {
this.setActiveTableId(parseInt(currentRoute.params.tableId))
this.setPageTitle(this.activeTable.title)
if (!currentRoute.path.includes('/row/')) {
this.switchActiveMenuEntry(document.querySelector('header .header-left .app-menu a[title="Tables"]'))
this.switchActiveMenuEntry(document.querySelector(`header .header-start .app-menu a[href="${url}"]`))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have any other idea how to make it works for non-en locales - feel free to suggest

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see nextcloud/server#51207

It can looks like:

if (currentRoute.path.startsWith('/table/')) {
	this.setActiveTableId(parseInt(currentRoute.params.tableId))
	this.setPageTitle(this.activeTable.title)
	if (!currentRoute.path.includes('/row/')) {
		emit('nextcloud:app-menu.active', 'tables')
}

}
} else if (currentRoute.path.startsWith('/view/')) {
this.setActiveViewId(parseInt(currentRoute.params.viewId))
this.setPageTitle(this.activeView.title)
if (!currentRoute.path.includes('/row/')) {
this.switchActiveMenuEntry(document.querySelector('header .header-left .app-menu a[title="Tables"]'))
this.switchActiveMenuEntry(document.querySelector(`header .header-start .app-menu a[href="${url}"]`))
}
} else if (currentRoute.path.startsWith('/application/')) {
const contextId = parseInt(currentRoute.params.contextId)
this.setActiveContextId(contextId)
this.setPageTitle(this.activeContext.name)
// 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.
this.switchActiveMenuEntry(document.querySelector(`header .header-left .app-menu [title="${this.activeContext.name}"]`))
this.switchActiveMenuEntry(document.querySelector(`header .header-start .app-menu [title="${this.activeContext.name}"]`))

// move the focus away from nav bar (import for app-internal switch)
const appContent = document.getElementById('app-content-vue')
Expand All @@ -112,7 +115,7 @@ export default {
},
switchActiveMenuEntry(targetElement) {
targetElement = targetElement?.tagName?.toLowerCase() === 'a' ? targetElement.parentElement : targetElement
const currentlyActive = document.querySelector('header .header-left .app-menu li.app-menu-entry--active')
const currentlyActive = document.querySelector('header .header-start .app-menu li.app-menu-entry--active')
currentlyActive.classList.remove('app-menu-entry--active')
targetElement.classList.add('app-menu-entry--active')
},
Expand Down
2 changes: 1 addition & 1 deletion src/modules/navigation/partials/NavigationTableItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

<template #actions>
<!-- EDIT -->
<NcActionButton v-if="canManageElement(table) "
<NcActionButton v-if="canManageElement(table)"
:close-after-click="true"
@click="emit('tables:table:edit', table.id)">
<template #icon>
Expand Down
Loading