diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-06-04 01:25:52 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-09-06 03:38:47 +0200 |
commit | 767e87a466c62f222eb6f24042aded954b152255 (patch) | |
tree | 726e2b42209a7283ca9fcad169944c212aedcef0 /apps/files | |
parent | 96c827558611033ac35f6095b77ea04dca8044dd (diff) | |
download | nextcloud-server-767e87a466c62f222eb6f24042aded954b152255.tar.gz nextcloud-server-767e87a466c62f222eb6f24042aded954b152255.zip |
fix(files): Do not use `favorite`, `sidebar` and `view-in-folder` action for public shares
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/src/actions/favoriteAction.ts | 19 | ||||
-rw-r--r-- | apps/files/src/actions/sidebarAction.ts | 10 | ||||
-rw-r--r-- | apps/files/src/actions/viewInFolderAction.ts | 6 |
3 files changed, 29 insertions, 6 deletions
diff --git a/apps/files/src/actions/favoriteAction.ts b/apps/files/src/actions/favoriteAction.ts index bb7d82ba2cd..52beb6e7454 100644 --- a/apps/files/src/actions/favoriteAction.ts +++ b/apps/files/src/actions/favoriteAction.ts @@ -2,10 +2,14 @@ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ +import type { Node, View } from '@nextcloud/files' + import { emit } from '@nextcloud/event-bus' -import { generateUrl } from '@nextcloud/router' -import { Permission, type Node, View, FileAction } from '@nextcloud/files' +import { Permission, FileAction } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' +import { encodePath } from '@nextcloud/paths' +import { generateUrl } from '@nextcloud/router' +import { isPublicShare } from '@nextcloud/sharing/public' import axios from '@nextcloud/axios' import Vue from 'vue' @@ -13,7 +17,6 @@ import StarOutlineSvg from '@mdi/svg/svg/star-outline.svg?raw' import StarSvg from '@mdi/svg/svg/star.svg?raw' import logger from '../logger.ts' -import { encodePath } from '@nextcloud/paths' // If any of the nodes is not favorited, we display the favorite action. const shouldFavorite = (nodes: Node[]): boolean => { @@ -69,8 +72,14 @@ export const action = new FileAction({ }, enabled(nodes: Node[]) { - // We can only favorite nodes within files and with permissions - return !nodes.some(node => !node.root?.startsWith?.('/files')) + // Not enabled for public shares + if (isPublicShare()) { + return false + } + + // We can only favorite nodes if they are located in files + return nodes.every(node => node.root?.startsWith?.('/files')) + // and we have permissions && nodes.every(node => node.permissions !== Permission.NONE) }, diff --git a/apps/files/src/actions/sidebarAction.ts b/apps/files/src/actions/sidebarAction.ts index f00088f8d0c..a9d80c412da 100644 --- a/apps/files/src/actions/sidebarAction.ts +++ b/apps/files/src/actions/sidebarAction.ts @@ -2,8 +2,12 @@ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ -import { Permission, type Node, View, FileAction } 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.ts' @@ -17,6 +21,10 @@ export const action = new FileAction({ // 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 diff --git a/apps/files/src/actions/viewInFolderAction.ts b/apps/files/src/actions/viewInFolderAction.ts index cc6873f4fa3..9a9775d1c65 100644 --- a/apps/files/src/actions/viewInFolderAction.ts +++ b/apps/files/src/actions/viewInFolderAction.ts @@ -5,6 +5,7 @@ import { Node, FileType, Permission, View, FileAction } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' import FolderMoveSvg from '@mdi/svg/svg/folder-move.svg?raw' +import { isPublicShare } from '@nextcloud/sharing/public' export const action = new FileAction({ id: 'view-in-folder', @@ -14,6 +15,11 @@ export const action = new FileAction({ iconSvgInline: () => FolderMoveSvg, enabled(nodes: Node[], view: View) { + // Not enabled for public shares + if (isPublicShare()) { + return false + } + // Only works outside of the main files view if (view.id === 'files') { return false |