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

UI to manage users/permissions for the content libraries [FC-0062] #1362

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

pomegranited
Copy link
Contributor

@pomegranited pomegranited commented Oct 4, 2024

Description

Adds a modal UI to add/remove users from the Library Team, with different roles: Admin, Author, or Reader

Also updates the Libraries UI to ensure read-only users can't see the Publish, Revert, or Add Tags buttons -- these would only throw errors as the user doesn't have permission on the backend.

This change impacts Content Authors using Libraries V2.

Screenshots

Admin view

Library Team -- admin view

Author view

Library Team -- author view

Reader view

Library Team -- reader view

Supporting information

Part of: #1342
Resolves: #1376
Private-ref: FAL-3869

Testing instructions

You will need 1 or 2 extra users for these tests.

  1. Create a library, and add one or more components.
  2. From the library info sidebar, click "Manage Access"
    You should see yourself as an Admin.
  3. Click "Add team member", and add another user.
    That user should be added to the Team as a Reader.
  4. In a private window, login as the Reader user and visit the library page in the MFE.
    Confirm that you can view the library and its components, but cannot edit anything.
    Confirm that you cannot see any "Publish" , "Revert changes", or "Manage Access" buttons in the library sidebar.
  5. As the original Admin user, click "Make Author" to promote the user to Author.
  6. In the private window, close and re-open the library info tab.
    Confirm that you can now edit/publish/revert the library and its components.
    Click "Manage Access" in the library sidebar, and confirm that you can see the Library Team, but cannot make any changes.
  7. As the original Admin user, click "Make Admin" to promote the user to Admin.
  8. In the private window, close and re-open the library info tab.
    Confirm that you can now edit/publish/revert the library and its components.
    Click "Manage Access" in the library sidebar, and confirm that you can edit the Library Team.
  9. As the original Admin user, delete the user you added.
    This should remove access to the library for that user.
  10. In the private window, refresh the library page.
    You should see a spinner and 403 errors in the Network tab.
    The "Libraries" list will not contain this library.
  11. As the original Admin user, toggle the "Allow Public Read" switch ON.
    Confirm that this setting saves as expected.
  12. In the private window, refresh the Libraries list.
    Confirm that you can view the library and its components, but cannot edit anything.
    Confirm that you cannot see any "Publish" , "Revert changes", or "Manage Access" buttons in the library sidebar.
  13. As the original Admin user, test the responsiveness of the Library Team modal in various browser sizes.

Author Concerns

  1. Do we need help text shown in the Library Team modal to explain the different roles?
  2. Once there's more than one Admin user in a Library Team, it's possible for the current user to demote or remove their own Admin member record. Unless they're also a Global Staff, they will lose access to the Library and/or the Library Team. Do we need to guard/warn against this?

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 4, 2024
@openedx-webhooks
Copy link

openedx-webhooks commented Oct 4, 2024

Thanks for the pull request, @pomegranited!

What's next?

Please work through the following steps to get your changes ready for engineering review:

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Let us know that your PR is ready for review:

Who will review my changes?

This repository is currently maintained by @openedx/2u-tnl. Tag them in a comment and let them know that your changes are ready for review.

Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@pomegranited pomegranited force-pushed the jill/library-team branch 2 times, most recently from 56078bd to c9b5d2f Compare October 9, 2024 11:19
which allows Library Admins to add Readers, Authors, and other Admin
users to the list of people who can access a Library.

* Readers can only see the library, but not its Team.
* Authors can see the Library Team, but cannot alter it.
* Admins can update the Library Team.

Modal is triggered from a button on the LibraryInfo sidebar which is
only accessible to users who can edit the library.
@@ -136,7 +145,7 @@ export const useUpdateLibraryMetadata = () => {

const newLibraryData = {
...previousLibraryData,
title: data.title,
...data,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to make this change to avoid a runtime error when toggling the "Allow Public Read" switch: "Helmet expects a string as a child of <title>"

This happened because the library.title is used in the page <title> component, and because I'm only updating allow_public_read, there's no data.title available while the query cache is being updated.

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

Attention: Patch coverage is 93.72385% with 15 lines in your changes missing coverage. Please review.

Project coverage is 93.01%. Comparing base (66b14a5) to head (9041907).

Files with missing lines Patch % Lines
src/library-authoring/library-team/LibraryTeam.tsx 86.90% 11 Missing ⚠️
src/library-authoring/data/api.ts 85.71% 3 Missing ⚠️
src/content-tags-drawer/ContentTagsDrawer.tsx 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1362      +/-   ##
==========================================
- Coverage   93.01%   93.01%   -0.01%     
==========================================
  Files        1035     1042       +7     
  Lines       19632    19844     +212     
  Branches     4172     4220      +48     
==========================================
+ Hits        18261    18458     +197     
- Misses       1306     1321      +15     
  Partials       65       65              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -0,0 +1,61 @@
import { useIntl } from '@edx/frontend-platform/i18n';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The library-team UI borrows heavily from the course-team UI. I initially tried to factor out the common parts so we could re-use components. But there were so many subtle differences between them -- 3 roles instead of 2, different text, the "allow public" toggle switch -- that it made the code really hard to read and use. So I ended up just copying over what I needed, though I did decide to use some css classes to keep a consistent appearance.

Copy link
Contributor

@rpenido rpenido left a comment

Choose a reason for hiding this comment

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

LGTM 👍
Thank you for your work, @pomegranited!

  • I tested this using the instructions from the PR
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

Some comments:

  • The user can "Manage Tags" (at least try to) in the readonly mode. We are addressing it in at least 2 other PRs, but I think we should also need it here.

In the private window, refresh the library page.
You should see a spinner and 403 errors in the Network tab.

I don't think this is a BIG issue, but because we use a token on the meilisearch queries it will still work. We can reduce the token expiry, as I think it is currently set to one week.

src/library-authoring/data/apiHooks.ts Outdated Show resolved Hide resolved
src/library-authoring/library-team/LibraryTeamMember.tsx Outdated Show resolved Hide resolved
/>
</div>
) : (
// Explain why this user cannot change the single Admin member
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think you would like to expand this comment?

* camel-case the updated library data before storing it in the cache
* add validation for the email on the Add Team Member form
* remove showToast from the useCallback context (console errors)
* key field only needs to be locally unique
* updates comments on "don't demote/delete the single Admin member"
@pomegranited
Copy link
Contributor Author

@rpenido

The user can "Manage Tags" (at least try to) in the readonly mode. We are addressing it in at least 2 other PRs, but I think we should also need it here.

I looked into this and it's more complicated than it seems on the surface because of how complicated our tagging permissions are :/ Have raised #1376 to address this, because it's going to require both backend + frontend changes to fix.

@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Oct 10, 2024
@pomegranited pomegranited marked this pull request as ready for review October 11, 2024 11:15
@pomegranited pomegranited requested a review from a team as a code owner October 11, 2024 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U
Projects
Status: Waiting on Author
Development

Successfully merging this pull request may close these issues.

Users with read-only access to a library should not be able to tag components
4 participants