Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions apps/files/src/actions/convertAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { Node, View } from '@nextcloud/files'

import { FileAction, registerFileAction } from '@nextcloud/files'
import { FileAction, Permission, registerFileAction } from '@nextcloud/files'
import { generateUrl } from '@nextcloud/router'
import { getCapabilities } from '@nextcloud/capabilities'
import { t } from '@nextcloud/l10n'

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

import { convertFile, convertFiles } from './convertUtils'
import { isPublicShare } from '@nextcloud/sharing/public'
import { useFilesStore } from '../store/files'

type ConversionsProvider = {
from: string,
Expand All @@ -28,7 +31,16 @@ export const registerConvertActions = () => {
id: `convert-${from}-${to}`,
displayName: () => t('files', 'Save as {displayName}', { displayName }),
iconSvgInline: () => generateIconSvg(to),
enabled: (nodes: Node[]) => {
enabled: (nodes: Node[], view: View) => {
if (isPublicShare()) {
// public shares without create permission cant convert files (no way to save the results)
const store = useFilesStore()
const root = store.getRoot(view.id)
if (root && !(root.permissions & Permission.CREATE)) {
return false
}
}

// Check that all nodes have the same mime type
return nodes.every(node => from === node.mime)
},
Expand Down
4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-init.js.map

Large diffs are not rendered by default.

Loading