diff options
Diffstat (limited to 'apps/files/src/actions/sidebarAction.ts')
-rw-r--r-- | apps/files/src/actions/sidebarAction.ts | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/apps/files/src/actions/sidebarAction.ts b/apps/files/src/actions/sidebarAction.ts index aeb09490fb0..8f020b4ee8d 100644 --- a/apps/files/src/actions/sidebarAction.ts +++ b/apps/files/src/actions/sidebarAction.ts @@ -2,21 +2,29 @@ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ -import { Permission, type Node, View, FileAction, FileType } from '@nextcloud/files' +import type { Node, View } from '@nextcloud/files' + +import { Permission, FileAction } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' +import { isPublicShare } from '@nextcloud/sharing/public' + import InformationSvg from '@mdi/svg/svg/information-variant.svg?raw' -import logger from '../logger.js' +import logger from '../logger.ts' export const ACTION_DETAILS = 'details' export const action = new FileAction({ id: ACTION_DETAILS, - displayName: () => t('files', 'Open details'), + displayName: () => t('files', 'Details'), iconSvgInline: () => InformationSvg, // Sidebar currently supports user folder only, /files/USER enabled: (nodes: Node[]) => { + if (isPublicShare()) { + return false + } + // Only works on single node if (nodes.length !== 1) { return false @@ -36,14 +44,22 @@ export const action = new FileAction({ async exec(node: Node, view: View, dir: string) { try { + // If the sidebar is already open for the current file, do nothing + if (window.OCA.Files.Sidebar.file === node.path) { + logger.debug('Sidebar already open for this file', { node }) + return null + } + // Open sidebar and set active tab to sharing by default + window.OCA.Files.Sidebar.setActiveTab('sharing') + // TODO: migrate Sidebar to use a Node instead await window.OCA.Files.Sidebar.open(node.path) // Silently update current fileid - window.OCP.Files.Router.goToRoute( + window.OCP?.Files?.Router?.goToRoute( null, - { view: view.id, fileid: node.fileid }, - { ...window.OCP.Files.Router.query, dir }, + { view: view.id, fileid: String(node.fileid) }, + { ...window.OCP.Files.Router.query, dir, opendetails: 'true' }, true, ) |