Skip to content
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
5 changes: 5 additions & 0 deletions apps/files/src/components/FilesNavigationList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import NcAppNavigationList from '@nextcloud/vue/components/NcAppNavigationList'
import FilesNavigationListItem from './FilesNavigationListItem.vue'
import { useVisibleViews } from '../composables/useViews.ts'

defineProps<{
activeViewId?: string
}>()

const views = useVisibleViews()
const rootViews = computed(() => views.value
.filter((view) => !view.parent)
Expand Down Expand Up @@ -47,6 +51,7 @@ function sortViews(a: IView, b: IView): number {
<FilesNavigationListItem
v-for="view in rootViews"
:key="view.id"
:active-view-id="activeViewId"
:view="view" />
</NcAppNavigationList>
</template>
Expand Down
4 changes: 4 additions & 0 deletions apps/files/src/components/FilesNavigationListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { folderTreeId } from '../services/FolderTree.ts'
import { useViewConfigStore } from '../store/viewConfig.ts'

const props = withDefaults(defineProps<{
activeViewId?: string
view: IView
level?: number
}>(), {
Expand Down Expand Up @@ -62,6 +63,7 @@ const sortedChildViews = computed(() => childViews.value.slice().sort((a, b) =>
return collator.compare(a.name, b.name)
}))
const hasChildViews = computed(() => childViews.value.length > 0)
const isActiveView = computed(() => props.activeViewId === props.view.id)

const navigationRoute = computed(() => {
if (props.view.params) {
Expand Down Expand Up @@ -138,6 +140,7 @@ export default {
<template>
<NcAppNavigationItem
class="files-navigation__item"
:active="isActiveView"
allow-collapse
:loading="isLoading"
:data-cy-files-navigation-item="view.id"
Expand All @@ -161,6 +164,7 @@ export default {
<FilesNavigationListItem
v-for="childView in sortedChildViews"
:key="childView.id"
:active-view-id="activeViewId"
:level="level + 1"
:view="childView" />
</NcAppNavigationItem>
Expand Down
15 changes: 14 additions & 1 deletion apps/files/src/views/FilesNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<FilesNavigationSearch />
</template>
<template #default>
<FilesNavigationList />
<FilesNavigationList :active-view-id="currentNavigationView" />

<!-- Settings modal-->
<FilesAppSettings
Expand Down Expand Up @@ -42,6 +42,7 @@
import { emit } from '@nextcloud/event-bus'
import { getNavigation } from '@nextcloud/files'
import { t } from '@nextcloud/l10n'
import { isSamePath } from '@nextcloud/paths'
import { computed, ref, watchEffect } from 'vue'
import { useRoute } from 'vue-router/composables'
import NcAppNavigation from '@nextcloud/vue/components/NcAppNavigation'
Expand All @@ -65,6 +66,18 @@ const allViews = useViews()

const route = useRoute()
const currentViewId = computed(() => route?.params?.view || 'files')
const currentNavigationView = computed(() => {
const routeDir = typeof route.query?.dir === 'string' ? route.query.dir : undefined
if (routeDir) {
const matchingView = allViews.value.find((view) => typeof view.params?.dir === 'string' && isSamePath(view.params.dir, routeDir))
if (matchingView) {
return matchingView.id
}
return undefined
}

return route?.params?.view || 'files'
})
watchEffect(() => {
if (currentViewId.value !== activeStore.activeView?.id) {
logger.debug(`Route view id ${currentViewId.value} is different from active view id ${activeStore.activeView?.id}, updating active view...`)
Expand Down
4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.