diff options
Diffstat (limited to 'apps/files/src/actions')
-rw-r--r-- | apps/files/src/actions/openFolderAction.spec.ts | 8 | ||||
-rw-r--r-- | apps/files/src/actions/openFolderAction.ts | 4 | ||||
-rw-r--r-- | apps/files/src/actions/openInFilesAction.spec.ts | 4 | ||||
-rw-r--r-- | apps/files/src/actions/openInFilesAction.ts | 2 | ||||
-rw-r--r-- | apps/files/src/actions/sidebarAction.spec.ts | 14 | ||||
-rw-r--r-- | apps/files/src/actions/sidebarAction.ts | 20 | ||||
-rw-r--r-- | apps/files/src/actions/viewInFolderAction.spec.ts | 4 | ||||
-rw-r--r-- | apps/files/src/actions/viewInFolderAction.ts | 2 |
8 files changed, 42 insertions, 16 deletions
diff --git a/apps/files/src/actions/openFolderAction.spec.ts b/apps/files/src/actions/openFolderAction.spec.ts index 5a0ccc98978..49fc9a9a63a 100644 --- a/apps/files/src/actions/openFolderAction.spec.ts +++ b/apps/files/src/actions/openFolderAction.spec.ts @@ -19,11 +19,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import { action } from './openFolderAction' +import type { Navigation } from '../services/Navigation' + import { expect } from '@jest/globals' import { File, Folder, Node, Permission } from '@nextcloud/files' + +import { action } from './openFolderAction' import { DefaultType, FileAction } from '../services/FileAction' -import type { Navigation } from '../services/Navigation' const view = { id: 'files', @@ -132,7 +134,7 @@ describe('Open folder action execute tests', () => { // Silent action expect(exec).toBe(null) expect(goToRouteMock).toBeCalledTimes(1) - expect(goToRouteMock).toBeCalledWith(null, null, { dir: '/FooBar' }) + expect(goToRouteMock).toBeCalledWith(null, { fileid: undefined, view: 'files' }, { dir: '/FooBar' }) }) test('Open folder fails without node', async () => { diff --git a/apps/files/src/actions/openFolderAction.ts b/apps/files/src/actions/openFolderAction.ts index ccb3f1a43ea..c0e03b20af0 100644 --- a/apps/files/src/actions/openFolderAction.ts +++ b/apps/files/src/actions/openFolderAction.ts @@ -59,8 +59,8 @@ export const action = new FileAction({ window.OCP.Files.Router.goToRoute( null, - null, - { dir: join(dir, node.basename) }, + { view: view.id, fileid: undefined }, + { dir: join(dir, node.basename), fileid: undefined }, ) return null }, diff --git a/apps/files/src/actions/openInFilesAction.spec.ts b/apps/files/src/actions/openInFilesAction.spec.ts index 302a6c45c6b..4fc402c73a8 100644 --- a/apps/files/src/actions/openInFilesAction.spec.ts +++ b/apps/files/src/actions/openInFilesAction.spec.ts @@ -78,7 +78,7 @@ describe('Open in files action execute tests', () => { // Silent action expect(exec).toBe(null) expect(goToRouteMock).toBeCalledTimes(1) - expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { fileid: 1, dir: '/Foo', openfile: true }) + expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { fileid: 1, dir: '/Foo' }) }) test('Open in files with folder', async () => { @@ -98,6 +98,6 @@ describe('Open in files action execute tests', () => { // Silent action expect(exec).toBe(null) expect(goToRouteMock).toBeCalledTimes(1) - expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { fileid: 1, dir: '/Foo/Bar', openfile: true }) + expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { fileid: 1, dir: '/Foo/Bar' }) }) }) diff --git a/apps/files/src/actions/openInFilesAction.ts b/apps/files/src/actions/openInFilesAction.ts index 283bfc63d50..9d3ceaf3b7b 100644 --- a/apps/files/src/actions/openInFilesAction.ts +++ b/apps/files/src/actions/openInFilesAction.ts @@ -44,7 +44,7 @@ export const action = new FileAction({ window.OCP.Files.Router.goToRoute( null, // use default route { view: 'files', fileid: node.fileid }, - { dir, fileid: node.fileid, openfile: true }, + { dir, fileid: node.fileid }, ) return null }, diff --git a/apps/files/src/actions/sidebarAction.spec.ts b/apps/files/src/actions/sidebarAction.spec.ts index 69eabe4be79..6b33667d1dd 100644 --- a/apps/files/src/actions/sidebarAction.spec.ts +++ b/apps/files/src/actions/sidebarAction.spec.ts @@ -19,11 +19,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import { action } from './sidebarAction' +import type { Navigation } from '../services/Navigation' + import { expect } from '@jest/globals' import { File, Permission } from '@nextcloud/files' + +import { action } from './sidebarAction' import { FileAction } from '../services/FileAction' -import type { Navigation } from '../services/Navigation' import logger from '../logger' const view = { @@ -127,6 +129,8 @@ describe('Open sidebar action exec tests', () => { test('Open sidebar', async () => { const openMock = jest.fn() window.OCA = { Files: { Sidebar: { open: openMock } } } + const goToRouteMock = jest.fn() + window.OCP = { Files: { Router: { goToRoute: goToRouteMock } } } const file = new File({ id: 1, @@ -139,6 +143,12 @@ describe('Open sidebar action exec tests', () => { // Silent action expect(exec).toBe(null) expect(openMock).toBeCalledWith('/foobar.txt') + expect(goToRouteMock).toBeCalledWith( + null, + { view: view.id, fileid: 1 }, + { dir: '/' }, + true, + ) }) test('Open sidebar fails', async () => { diff --git a/apps/files/src/actions/sidebarAction.ts b/apps/files/src/actions/sidebarAction.ts index 6c553d97902..849cf78368d 100644 --- a/apps/files/src/actions/sidebarAction.ts +++ b/apps/files/src/actions/sidebarAction.ts @@ -19,9 +19,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ +import type { Navigation } from '../services/Navigation' + +import { Permission, type Node } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' import InformationSvg from '@mdi/svg/svg/information-variant.svg?raw' -import { Permission, type Node } from '@nextcloud/files' import { registerFileAction, FileAction } from '../services/FileAction' import logger from '../logger.js' @@ -40,6 +42,10 @@ export const action = new FileAction({ return false } + if (!nodes[0]) { + return false + } + // Only work if the sidebar is available if (!window?.OCA?.Files?.Sidebar) { return false @@ -48,10 +54,18 @@ export const action = new FileAction({ return (nodes[0].root?.startsWith('/files/') && nodes[0].permissions !== Permission.NONE) ?? false }, - async exec(node: Node) { + async exec(node: Node, view: Navigation) { try { // TODO: migrate Sidebar to use a Node instead - window?.OCA?.Files?.Sidebar?.open?.(node.path) + await window.OCA.Files.Sidebar.open(node.path) + + // Silently update current fileid + window.OCP.Files.Router.goToRoute( + null, + { view: view.id, fileid: node.fileid }, + { dir: node.dirname }, + true, + ) return null } catch (error) { diff --git a/apps/files/src/actions/viewInFolderAction.spec.ts b/apps/files/src/actions/viewInFolderAction.spec.ts index 887ed5d47c6..7d61fa4298d 100644 --- a/apps/files/src/actions/viewInFolderAction.spec.ts +++ b/apps/files/src/actions/viewInFolderAction.spec.ts @@ -128,7 +128,7 @@ describe('View in folder action execute tests', () => { // Silent action expect(exec).toBe(null) expect(goToRouteMock).toBeCalledTimes(1) - expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { fileid: 1, dir: '/' }) + expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/' }) }) test('View in (sub) folder', async () => { @@ -148,7 +148,7 @@ describe('View in folder action execute tests', () => { // Silent action expect(exec).toBe(null) expect(goToRouteMock).toBeCalledTimes(1) - expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { fileid: 1, dir: '/Foo/Bar' }) + expect(goToRouteMock).toBeCalledWith(null, { fileid: 1, view: 'files' }, { dir: '/Foo/Bar' }) }) test('View in folder fails without node', async () => { diff --git a/apps/files/src/actions/viewInFolderAction.ts b/apps/files/src/actions/viewInFolderAction.ts index 2f603e6cf3a..f0c5d2485a3 100644 --- a/apps/files/src/actions/viewInFolderAction.ts +++ b/apps/files/src/actions/viewInFolderAction.ts @@ -61,7 +61,7 @@ export const action = new FileAction({ window.OCP.Files.Router.goToRoute( null, { view: 'files', fileid: node.fileid }, - { dir: node.dirname, fileid: node.fileid }, + { dir: node.dirname }, ) return null }, |