fix(files): open folder fileid while navigating without opening the sidebar

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ 2023-09-24 12:34:15 +02:00
parent 912b18b1fc
commit 8e9e222105
No known key found for this signature in database
GPG key ID: 60C25B8C072916CF
8 changed files with 19 additions and 13 deletions

View file

@ -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 () => {

View file

@ -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
},

View file

@ -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,

View file

@ -169,7 +169,7 @@ 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)
@ -177,8 +177,13 @@ export default Vue.extend({
// 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 })

4
dist/files-init.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
dist/files-main.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long