Skip to content

Commit bb6b0cc

Browse files
committed
fix(files): do not show convert-file action in view-only shares
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent ca96c4a commit bb6b0cc

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

apps/files/src/actions/convertAction.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
5+
56
import type { Node, View } from '@nextcloud/files'
67

7-
import { FileAction, registerFileAction } from '@nextcloud/files'
8+
import { FileAction, Permission, registerFileAction } from '@nextcloud/files'
89
import { generateUrl } from '@nextcloud/router'
910
import { getCapabilities } from '@nextcloud/capabilities'
1011
import { t } from '@nextcloud/l10n'
1112

1213
import AutoRenewSvg from '@mdi/svg/svg/autorenew.svg?raw'
1314

1415
import { convertFile, convertFiles } from './convertUtils'
16+
import { isPublicShare } from '@nextcloud/sharing/public'
17+
import { useFilesStore } from '../store/files'
1518

1619
type ConversionsProvider = {
1720
from: string,
@@ -28,7 +31,16 @@ export const registerConvertActions = () => {
2831
id: `convert-${from}-${to}`,
2932
displayName: () => t('files', 'Save as {displayName}', { displayName }),
3033
iconSvgInline: () => generateIconSvg(to),
31-
enabled: (nodes: Node[]) => {
34+
enabled: (nodes: Node[], view: View) => {
35+
if (isPublicShare()) {
36+
// public shares without create permission cant convert files (no way to save the results)
37+
const store = useFilesStore()
38+
const root = store.getRoot(view.id)
39+
if (root && !(root.permissions & Permission.CREATE)) {
40+
return false
41+
}
42+
}
43+
3244
// Check that all nodes have the same mime type
3345
return nodes.every(node => from === node.mime)
3446
},

0 commit comments

Comments
 (0)