diff options
Diffstat (limited to 'apps/files/src/actions/sidebarAction.ts')
-rw-r--r-- | apps/files/src/actions/sidebarAction.ts | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/apps/files/src/actions/sidebarAction.ts b/apps/files/src/actions/sidebarAction.ts index 32cd8e6d433..8f020b4ee8d 100644 --- a/apps/files/src/actions/sidebarAction.ts +++ b/apps/files/src/actions/sidebarAction.ts @@ -1,39 +1,30 @@ /** - * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com> - * - * @author John Molakvoæ <skjnldsv@protonmail.com> - * - * @license AGPL-3.0-or-later - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * 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 @@ -53,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 }, - { dir }, + { view: view.id, fileid: String(node.fileid) }, + { ...window.OCP.Files.Router.query, dir, opendetails: 'true' }, true, ) |