Skip to content

Commit

Permalink
Allow users with can_modify_folder = true to delete items
Browse files Browse the repository at this point in the history
  • Loading branch information
npinter authored and mvdbeek committed Oct 7, 2024
1 parent c84e014 commit af6fd74
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const containsFileOrFolder = computed(() => {
return props.folderContents.find((el) => el.type === "folder" || el.type === "file");
});
const canDelete = computed(() => {
return !!(containsFileOrFolder.value && isAdmin.value);
return !!(containsFileOrFolder.value && props.metadata.can_modify_folder);
});
const datasetManipulation = computed(() => {
return !!(containsFileOrFolder.value && userStore.currentUser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@
alert="User with <strong>any</strong> of these roles can modify this library (name, synopsis, etc.)."
title="Roles that can modify this library"
@input="setUserPermissionsPreferences" />
<PermissionsInputField
v-if="manage_library_role_list"
:id="library_id"
:permission_type="manage_type"
:initial_value="manage_library_role_list"
:api-root-url="apiRootUrl"
alert="User with <strong>any</strong> of these roles can manage this library."
title="Roles that can manage this library"
@input="setUserPermissionsPreferences" />
<button title="Save modifications" class="toolbtn_save_permissions" @click="postPermissions">
<FontAwesomeIcon :icon="['far', 'save']" />
Save
Expand Down Expand Up @@ -71,10 +80,12 @@ export default {
library: undefined,
add_library_item_role_list: undefined,
modify_library_role_list: undefined,
manage_library_role_list: undefined,
access_library_role_list: undefined,
apiRootUrl: `${getAppRoot()}api/libraries`,
add_type: "add_library_item_role_list",
modify_type: "modify_library_role_list",
manage_type: "manage_library_role_list",
access_type: "access_library_role_list",
};
},
Expand All @@ -85,6 +96,7 @@ export default {
console.log("fetched_permissions", fetched_permissions);
this.add_library_item_role_list = extractRoles(fetched_permissions.add_library_item_role_list);
this.modify_library_role_list = extractRoles(fetched_permissions.modify_library_role_list);
this.manage_library_role_list = extractRoles(fetched_permissions.manage_library_role_list);
this.access_library_role_list = extractRoles(fetched_permissions.access_library_role_list);
});
this.services.getLibrary(this.library_id).then((library) => {
Expand All @@ -103,6 +115,7 @@ export default {
[
{ "add_ids[]": this.add_library_item_role_list },
{ "modify_ids[]": this.modify_library_role_list },
{ "manage_ids[]": this.manage_library_role_list },
{ "access_ids[]": this.access_library_role_list },
],
(fetched_permissions) => {
Expand Down

0 comments on commit af6fd74

Please sign in to comment.