aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src/actions/favoriteAction.ts
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2023-07-06 15:21:07 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2023-07-11 13:52:28 +0200
commita9f7e66d3dbdd7740aa7f308665d576d3a491378 (patch)
treecdb6969b4e9d5135baf5ea5f5a307dcc5929d282 /apps/files/src/actions/favoriteAction.ts
parent6f54f72bb40113662a9b906bebcf37393b45e9fa (diff)
downloadnextcloud-server-a9f7e66d3dbdd7740aa7f308665d576d3a491378.tar.gz
nextcloud-server-a9f7e66d3dbdd7740aa7f308665d576d3a491378.zip
fix(files): actions permissions requirements
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files/src/actions/favoriteAction.ts')
-rw-r--r--apps/files/src/actions/favoriteAction.ts13
1 files changed, 8 insertions, 5 deletions
diff --git a/apps/files/src/actions/favoriteAction.ts b/apps/files/src/actions/favoriteAction.ts
index 1ae77b6fb21..a33aacf4947 100644
--- a/apps/files/src/actions/favoriteAction.ts
+++ b/apps/files/src/actions/favoriteAction.ts
@@ -20,13 +20,15 @@
*
*/
import { emit } from '@nextcloud/event-bus'
+import { generateUrl } from '@nextcloud/router'
+import { Permission, type Node } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import axios from '@nextcloud/axios'
-import StarSvg from '@mdi/svg/svg/star.svg?raw'
+import Vue from 'vue'
+
import StarOutlineSvg from '@mdi/svg/svg/star-outline.svg?raw'
-import type { Node } from '@nextcloud/files'
+import StarSvg from '@mdi/svg/svg/star.svg?raw'
-import { generateUrl } from '@nextcloud/router'
import { registerFileAction, FileAction } from '../services/FileAction'
import logger from '../logger.js'
import type { Navigation } from '../services/Navigation'
@@ -54,7 +56,7 @@ export const favoriteNode = async (node: Node, view: Navigation, willFavorite: b
}
// Update the node webdav attribute
- node.attributes.favorite = willFavorite ? 1 : 0
+ Vue.set(node.attributes, 'favorite', willFavorite ? 1 : 0)
// Dispatch event to whoever is interested
if (willFavorite) {
@@ -85,8 +87,9 @@ export const action = new FileAction({
},
enabled(nodes: Node[]) {
- // We can only favorite nodes within files
+ // We can only favorite nodes within files and with permissions
return !nodes.some(node => !node.root?.startsWith?.('/files'))
+ && nodes.every(node => node.permissions !== Permission.NONE)
},
async exec(node: Node, view: Navigation) {