Skip to content

Commit bb1451f

Browse files
authored
Merge pull request #56060 from nextcloud/fix/hide-open-locally-action
2 parents 94a00b6 + 478509a commit bb1451f

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

apps/files/src/actions/openLocallyAction.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ import IconWeb from '@mdi/svg/svg/web.svg?raw'
1010
import { getCurrentUser } from '@nextcloud/auth'
1111
import axios from '@nextcloud/axios'
1212
import { DialogBuilder, showError } from '@nextcloud/dialogs'
13-
import { FileAction, Permission } from '@nextcloud/files'
13+
import { FileAction } from '@nextcloud/files'
1414
import { translate as t } from '@nextcloud/l10n'
1515
import { encodePath } from '@nextcloud/paths'
1616
import { generateOcsUrl } from '@nextcloud/router'
1717
import { isPublicShare } from '@nextcloud/sharing/public'
1818
import logger from '../logger.ts'
19+
import { isSyncable } from '../utils/permissions.ts'
1920

2021
export const action = new FileAction({
2122
id: 'edit-locally',
@@ -34,7 +35,7 @@ export const action = new FileAction({
3435
return false
3536
}
3637

37-
return (nodes[0].permissions & Permission.UPDATE) !== 0
38+
return isSyncable(nodes[0])
3839
},
3940

4041
async exec(node: Node) {

apps/files/src/utils/permissions.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,22 @@ export function isDownloadable(node: Node): boolean {
3636

3737
return true
3838
}
39+
40+
/**
41+
* Check permissions on the node if it can be synced/open locally
42+
*
43+
* @param node The node to check
44+
* @return True if syncable, false otherwise
45+
*/
46+
export function isSyncable(node: Node): boolean {
47+
if (!node.isDavResource) {
48+
return false
49+
}
50+
51+
if ((node.permissions & Permission.UPDATE) === 0) {
52+
return false
53+
}
54+
55+
// Syncable has the same permissions as downloadable for now
56+
return isDownloadable(node)
57+
}

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.

dist/files-main.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)