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
5 changes: 3 additions & 2 deletions apps/files/src/actions/editLocallyAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import { encodePath } from '@nextcloud/paths'
import { generateOcsUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
import { FileAction, Permission, type Node } from '@nextcloud/files'
import { FileAction, type Node } from '@nextcloud/files'
import { showError, DialogBuilder } from '@nextcloud/dialogs'
import { translate as t } from '@nextcloud/l10n'
import axios from '@nextcloud/axios'
import LaptopSvg from '@mdi/svg/svg/laptop.svg?raw'
import IconWeb from '@mdi/svg/svg/web.svg?raw'
import { isPublicShare } from '@nextcloud/sharing/public'
import { isSyncable } from '../utils/permissions.ts'

export const action = new FileAction({
id: 'edit-locally',
Expand All @@ -30,7 +31,7 @@ export const action = new FileAction({
return false
}

return (nodes[0].permissions & Permission.UPDATE) !== 0
return isSyncable(nodes[0])
},

async exec(node: Node) {
Expand Down
19 changes: 19 additions & 0 deletions apps/files/src/utils/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,22 @@ export function isDownloadable(node: Node): boolean {

return true
}

/**
* Check permissions on the node if it can be synced/open locally
*
* @param node The node to check
* @return True if syncable, false otherwise
*/
export function isSyncable(node: Node): boolean {
if (!node.isDavResource) {
return false
}

if ((node.permissions & Permission.UPDATE) === 0) {
return false
}

// Syncable has the same permissions as downloadable for now
return isDownloadable(node)
}
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.

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

Large diffs are not rendered by default.

Loading