Skip to content

Commit 9e720eb

Browse files
Merge pull request #59872 from nextcloud/chore/backport-apps/files/src/actions/convertAction.ts
[stable32] fix(files): do not show convert-file action in view-only shares
2 parents ca96c4a + e138fc6 commit 9e720eb

3 files changed

Lines changed: 17 additions & 5 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
},

dist/files-init.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-init.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)