Skip to content

Commit 25fc2d8

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 e1049a8 commit 25fc2d8

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

apps/files/src/actions/convertAction.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import type { IFileAction } from '@nextcloud/files'
77

88
import AutoRenewSvg from '@mdi/svg/svg/autorenew.svg?raw'
99
import { getCapabilities } from '@nextcloud/capabilities'
10-
import { registerFileAction } from '@nextcloud/files'
10+
import { Permission, registerFileAction } from '@nextcloud/files'
1111
import { t } from '@nextcloud/l10n'
1212
import { generateUrl } from '@nextcloud/router'
13+
import { isPublicShare } from '@nextcloud/sharing/public'
1314
import { convertFile, convertFiles } from './convertUtils.ts'
1415

1516
type ConversionsProvider = {
@@ -30,7 +31,11 @@ export function registerConvertActions() {
3031
id: `convert-${from}-${to}`,
3132
displayName: () => t('files', 'Save as {displayName}', { displayName }),
3233
iconSvgInline: () => generateIconSvg(to),
33-
enabled: ({ nodes }) => {
34+
enabled: ({ nodes, folder }) => {
35+
if (isPublicShare() && !(folder.permissions & Permission.CREATE)) {
36+
// cannot create the converted file in a public share if we don't have create permissions
37+
return false
38+
}
3439
// Check that all nodes have the same mime type
3540
return nodes.every((node) => from === node.mime)
3641
},

0 commit comments

Comments
 (0)