Skip to content

feat: remove new library button if user does not have create access for v1 libraries#1216

Merged
bradenmacdonald merged 2 commits intoopenedx:masterfrom
open-craft:kaustav/hide_new_library_button_if_no_access
Sep 6, 2024
Merged

feat: remove new library button if user does not have create access for v1 libraries#1216
bradenmacdonald merged 2 commits intoopenedx:masterfrom
open-craft:kaustav/hide_new_library_button_if_no_access

Conversation

@kaustavb12
Copy link
Contributor

@kaustavb12 kaustavb12 commented Aug 15, 2024

Description

Currently the New Library button is shown to studio users even if they don't have the required access to create a library. This creates a confusing user experince for the user, since if such an user tries to create a library, they get a error down the UI flow.

This PR fixes this behavior for V1 libraries inline with the the legacy Studio UI

Testing instructions

  1. Setup this PR branch in a local or sandbox environment.
  2. Login to studio through a user account without any staff access
  3. Ensure New Library button is missing there.

Other information

Private Ref: BB-9077

@kaustavb12 kaustavb12 requested a review from a team as a code owner August 15, 2024 15:25
@openedx-webhooks
Copy link

Thanks for the pull request, @kaustavb12!

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.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Aug 15, 2024
@mphilbrick211 mphilbrick211 added the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Aug 15, 2024
@kaustavb12 kaustavb12 force-pushed the kaustav/hide_new_library_button_if_no_access branch from 3a8deb4 to a9a4d93 Compare August 15, 2024 16:22
@codecov
Copy link

codecov bot commented Aug 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.22%. Comparing base (34f0bf5) to head (8877b3e).
Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1216   +/-   ##
=======================================
  Coverage   92.22%   92.22%           
=======================================
  Files        1008     1008           
  Lines       18514    18516    +2     
  Branches     3947     3949    +2     
=======================================
+ Hits        17074    17076    +2     
  Misses       1371     1371           
  Partials       69       69           

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

@KristinAoki KristinAoki removed the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Aug 16, 2024
@bradenmacdonald
Copy link
Contributor

bradenmacdonald commented Aug 17, 2024

For V2 libraries, the permissions are all centralized in permissions.py. I am not sure if this change should be affecting both V1 and V2 like is is now, or just V1. But if it is deliberately trying to affect both V1 and V2 libraries, then the platform PR needs to be updated to use the CAN_CREATE_CONTENT_LIBRARY permission to determine if the user can create V2 libraries rather than these sort of custom functions. As much as possible, any new permissions checking code should be written using bridgekeeper rather than writing random functions - and for V2 we already have very clear permissions checking in that file.

I do think the rule for "who can create V2 libraries" needs to be updated though; currently it says "any active user" and it should be something more elaborate like "any global staff or (if creator groups are enabled, anyone in the creator group, otherwise any active user)", but expressed using bridgekeeper. CC @jmakowski1123 because I'm not sure on the exact product requirements for who can create V2 libraries.

If you don't want to take all that on now @kaustavb12, I think this PR should be updated to be explicitly for V1 only.

Copy link
Contributor

@0x29a 0x29a left a comment

Choose a reason for hiding this comment

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

👍

  • I tested that the new library button isn't visible for users without access.
  • I read through the code

@kaustavb12
Copy link
Contributor Author

kaustavb12 commented Aug 28, 2024

@bradenmacdonald

Firstly sorry for the late reply and thanks a lot for the context on the permissions system for V2 libraries.

The main motivation behind this PR was to re-use the existing function which was used in the legacy UI to check access to 'Create Library' button for V1. It would have been nice to implement a common logic for both V1 and V2 instead of creating a technical debt, but as you mentioned the rules for the CAN_CREATE_CONTENT_LIBRARY permission is not finalized yet.

For this reason I am inclined to convert this PR to just target V1.

But if I have guidance about the intented rules for CAN_CREATE_CONTENT_LIBRARY permission, I would be happy to implement that instead and perhaps use it for both V1 and V2.

@bradenmacdonald
Copy link
Contributor

@kaustavb12 It's fine with me if you update the PR so it doesn't make any changes that affect v2. I believe @jmakowski1123 is still working to define how permissions are supposed to work in v2 anyways.

@kaustavb12 kaustavb12 force-pushed the kaustav/hide_new_library_button_if_no_access branch from 8551ffb to 6954861 Compare August 29, 2024 09:44
@kaustavb12 kaustavb12 changed the title feat: remove new library button if user does not have create access feat: remove new library button if user does not have create access for v1 libraries Aug 29, 2024
@kaustavb12
Copy link
Contributor Author

@bradenmacdonald @0x29a
The PR has been updated to affect only v1. Please take a look.

@0x29a
Copy link
Contributor

0x29a commented Aug 30, 2024

I tested this locally and verified that the changes affect only v1 now. LGTM. 👍

@bradenmacdonald bradenmacdonald force-pushed the kaustav/hide_new_library_button_if_no_access branch from 6954861 to 8877b3e Compare September 4, 2024 17:30
@bradenmacdonald bradenmacdonald merged commit 6b10fa7 into openedx:master Sep 6, 2024
@bradenmacdonald bradenmacdonald deleted the kaustav/hide_new_library_button_if_no_access branch September 6, 2024 17:49
navinkarkera pushed a commit to open-craft/frontend-app-authoring that referenced this pull request Sep 9, 2024
kaustavb12 added a commit to open-craft/frontend-app-authoring that referenced this pull request Sep 10, 2024
kaustavb12 added a commit to open-craft/frontend-app-authoring that referenced this pull request Sep 15, 2024
Arpit-Nakrani-Networked pushed a commit to Arpit-Nakrani-Networked/frontend-app-authoring that referenced this pull request Jul 13, 2025
…penedx#1216)

Part of openedx/axim-engineering#23

This updates the `@edx/brand` alias to point to the `brand-openedx` package at
the `openedx` scope. This does not impact imports because this package is used
via an alias.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants