Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit edit item modal results #2011

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

KoenP
Copy link

@KoenP KoenP commented Dec 22, 2022

References

Description

The frontend PR ensures that, when a user clicks Edit->Item in the admin sidebar, they only see items they have permission to edit. The backend PR extends the REST API with a findItemsWithEdit search method to support quickly finding these relevant items.

Instructions for Reviewers

List of changes in this PR:

  • New component EditableItemSelectorComponent, which renders a list of items that are editable by the current user.
  • EditItemSelectorComponent now uses a custom template instead of the generic DSOSelectorModalWrapperComponent template.
  • BaseItemDataService: now implements SearchData<Item> and defines a new method findItemsWithEdit, which calls a new REST method with the same name to retrieve the list of items for which the current user has editing rights.

Manual testing can be done via the REST API at /api/core/items/search/findItemsWithEdit or via the frontend.

  • Make a user and grant that user editing rights on some items in various ways
    • via direct resource policty
    • by making the user admin of a collection with some items in it
    • by making the user admin of a community with some collections with some items in it...
  • Either call into the REST API or use the frontend to verify only these items are returned.
  • Add a query to verify only relevant items are returned.

Checklist

This checklist provides a reminder of what we are going to look for when reviewing your PR. You need not complete this checklist prior to creating your PR (draft PRs are always welcome). If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!

  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes ESLint validation using yarn lint
  • My PR doesn't introduce circular dependencies (verified via yarn check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

@KoenP KoenP changed the title W2p 97257 limit edit item modal results Limit edit item modal results Dec 22, 2022
@github-actions
Copy link

github-actions bot commented Jan 3, 2023

Hi @KoenP,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@KoenP KoenP force-pushed the w2p-97257_limit-edit-item-modal-results branch from b68e39f to 7982259 Compare January 3, 2023 14:29
@github-actions
Copy link

github-actions bot commented Jan 3, 2023

Hi @KoenP,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@KoenP KoenP marked this pull request as ready for review January 3, 2023 15:44
@tdonohue tdonohue requested review from tdonohue and artlowel January 5, 2023 15:32
@tdonohue tdonohue added bug authorization related to authorization, permissions or groups labels Jan 18, 2023
Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KoenP : I tried to test this today, but I cannot build this PR when I apply it to the latest main. It appears this PR may be accidentally undoing many of the changes to the "shared.module.ts" which were recently applied to main.

We could always wait to rebase this after #1999 is fully merged (I think it's close). But, I just wanted to let you know that this PR appears to have build issues right now.

@KoenP KoenP force-pushed the w2p-97257_limit-edit-item-modal-results branch from 258009c to 14a45fa Compare January 23, 2023 10:00
@KoenP KoenP force-pushed the w2p-97257_limit-edit-item-modal-results branch from 14a45fa to 4526097 Compare January 23, 2023 14:38
@tdonohue tdonohue self-requested a review January 23, 2023 18:03
Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 @KoenP : I tested and reviewed this today. I have a few very minor inline requests which I'd like to be resolved prior to merger. However, this works well, so I'll go ahead and approve it.

@@ -54,6 +54,15 @@ export const getFirstSucceededRemoteWithNotEmptyData = <T>() =>
(source: Observable<RemoteData<T>>): Observable<RemoteData<T>> =>
source.pipe(find((rd: RemoteData<T>) => rd.hasSucceeded && isNotEmpty(rd.payload)));

export const mapRemoteDataPayload = <T,U>(fn: (payload: T) => U) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment or TypeDocs to describe how/when to use this? See for example how "getFirstSucceededRemoteDataPayload" is described (and others below it.)

@@ -14,7 +14,8 @@ import { Item } from '../../../../core/shared/item.model';

@Component({
selector: 'ds-edit-item-selector',
templateUrl: '../dso-selector-modal-wrapper.component.html',
templateUrl: './edit-item-selector.component.html',
// templateUrl: '../dso-selector-modal-wrapper.component.html',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove the commented out code here?

@github-actions
Copy link

Hi @KoenP,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

Copy link
Member

@artlowel artlowel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @KoenP!

The code in this PR looks good and it works well.

However I noticed some cases where the solr index seemed to be outdated after adding or removing a user from a group. I made a comment about it on the rest PR: DSpace/DSpace#8616 (comment)

@artlowel artlowel changed the base branch from main to ui-demo February 2, 2023 16:41
@artlowel artlowel changed the base branch from ui-demo to main February 2, 2023 16:41
@tdonohue tdonohue requested review from tdonohue and artlowel February 3, 2023 15:09
@tdonohue tdonohue added this to the 7.6 milestone Feb 3, 2023
@tdonohue tdonohue removed this from the 7.6 milestone Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
authorization related to authorization, permissions or groups bug merge conflict work in progress
Projects
Status: ❓ Stalled/On Hold
Development

Successfully merging this pull request may close these issues.

Search function in sidebar menu "Edit" => "Item" does not consider user rights
3 participants