Skip to content

Commit

Permalink
fix(files): open folder fileid while navigating without opening the s…
Browse files Browse the repository at this point in the history
…idebar

Signed-off-by: John Molakvoæ <[email protected]>
  • Loading branch information
skjnldsv committed Sep 27, 2023
1 parent 912b18b commit 8e9e222
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apps/files/src/actions/openFolderAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('Open folder action execute tests', () => {
// Silent action
expect(exec).toBe(null)
expect(goToRouteMock).toBeCalledTimes(1)
expect(goToRouteMock).toBeCalledWith(null, { fileid: undefined, view: 'files' }, { dir: '/FooBar' })
expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/FooBar' })
})

test('Open folder fails without node', async () => {
Expand Down
4 changes: 2 additions & 2 deletions apps/files/src/actions/openFolderAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export const action = new FileAction({

window.OCP.Files.Router.goToRoute(
null,
{ view: view.id, fileid: undefined },
{ dir: join(dir, node.basename), fileid: undefined },
{ view: view.id, fileid: node.fileid },
{ dir: join(dir, node.basename) },
)
return null
},
Expand Down
3 changes: 2 additions & 1 deletion apps/files/src/components/BreadCrumbs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export default Vue.extend({
sections() {
return this.dirs.map(dir => {
const to = { ...this.$route, query: { dir } }
const fileid = this.getFileIdFromPath(dir)
const to = { ...this.$route, params: { fileid }, query: { dir } }
return {
dir,
exact: true,
Expand Down
11 changes: 8 additions & 3 deletions apps/files/src/components/FilesListVirtual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,21 @@ export default Vue.extend({
// Scroll to the file if it's in the url
if (this.fileId) {
const index = this.nodes.findIndex(node => node.fileid === this.fileId)
if (index === -1) {
if (index === -1 && this.fileId !== this.currentFolder.fileid) {
showError(this.t('files', 'File not found'))
}
this.scrollToIndex = Math.max(0, index)
}

// Open the file sidebar if we have the room for it
if (document.documentElement.clientWidth > 1024) {
// Open the sidebar on the file if it's in the url and
// we're just loaded the app for the first time.
// Don't open the sidebar for the current folder
if (this.currentFolder.fileid === this.fileId) {
return
}

// Open the sidebar for the given URL fileid
// iif we just loaded the app.
const node = this.nodes.find(n => n.fileid === this.fileId) as Node
if (node && sidebarAction?.enabled?.([node], this.currentView)) {
logger.debug('Opening sidebar on file ' + node.path, { node })
Expand Down
4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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.

0 comments on commit 8e9e222

Please sign in to comment.