fix: delete button was not displayed accordingly to new permission "delete children"
Massimo Melina committed
Sep 12, 2023 at 11:23 UTC
e1295265c51b43eca37adebc28f5a0d7f44e909c
1 file changed
+3
-1
src/api.file_list.ts
+3
-1
@@ -1,6 +1,7 @@
1
// This file is part of HFS - Copyright 2021-2023, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
2
3
import {
4
+ applyParentToChild,
5
getNodeName,
6
hasPermission,
7
masksCouldGivePermission,
@@ -40,7 +41,8 @@ export const get_file_list: ApiHandler = async ({ uri, offset, limit, search, c
41
const walker = walkNode(node, ctx, search ? Infinity : 0)
42
const onDirEntryHandlers = mapPlugins(plug => plug.onDirEntry)
43
const can_upload = hasPermission(node, 'can_upload', ctx)
43
- const can_delete = hasPermission(node, 'can_delete', ctx)
44
+ const fakeChild = applyParentToChild({}, node) // we want to know if we want to delete children
45
+ const can_delete = hasPermission(fakeChild, 'can_delete', ctx)
46
const props = { can_upload, can_delete, accept: node.accept }
47
if (!list)
48
return { ...props, list: await asyncGeneratorToArray(produceEntries()) }