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

Add button to copy permissions from a existing role #9842

Closed
wants to merge 1 commit into from

Conversation

iicdii
Copy link
Contributor

@iicdii iicdii commented Mar 26, 2021

What does it do?

I added a dropdown button to permission section to copy permission from a existing role.

copy-a-role.mp4

Why is it needed?

Each time you create new role, you need to set permissions all over again and it's annoying.
you can copy permissions from a existing role with one click, It reduces amount of time to click checkboxes.

Describe the issue you are solving.

How to test it?

  1. Go to .../admin/settings/users-permissions/roles/{id} page
  2. Scroll down to Permissions section
  3. Click "Copy a existing role" button
  4. Select a role you want to copy

@codecov
Copy link

codecov bot commented Mar 26, 2021

Codecov Report

Merging #9842 (a88cc0d) into master (2c5224a) will decrease coverage by 0.08%.
The diff coverage is 12.50%.

❗ Current head a88cc0d differs from pull request most recent head 8a33441. Consider uploading reports for the commit 8a33441 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9842      +/-   ##
==========================================
- Coverage   35.88%   35.80%   -0.09%     
==========================================
  Files        1342     1348       +6     
  Lines       14808    14854      +46     
  Branches     1476     1478       +2     
==========================================
+ Hits         5314     5318       +4     
- Misses       8575     8616      +41     
- Partials      919      920       +1     
Flag Coverage Δ
front 27.14% <0.00%> (-0.12%) ⬇️
unit 55.58% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ns/admin/src/components/Roles/RolePicker/Button.js 0.00% <0.00%> (ø)
...ions/admin/src/components/Roles/RolePicker/List.js 0.00% <0.00%> (ø)
.../admin/src/components/Roles/RolePicker/ListItem.js 0.00% <0.00%> (ø)
...min/src/components/Roles/RolePicker/ListWrapper.js 0.00% <0.00%> (ø)
.../src/components/Roles/RolePicker/StyledListItem.js 0.00% <0.00%> (ø)
...ons/admin/src/components/Roles/RolePicker/index.js 0.00% <0.00%> (ø)
...ons/admin/src/components/UsersPermissions/index.js 0.00% <0.00%> (ø)
...s/admin/src/components/UsersPermissions/reducer.js 100.00% <ø> (ø)
packages/strapi/lib/services/metrics/index.js 65.00% <100.00%> (ø)
packages/strapi/lib/services/metrics/sender.js 100.00% <100.00%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2c5224a...8a33441. Read the comment docs.

@soupette soupette requested a review from sam-pires March 29, 2021 07:49
@derrickmehaffy
Copy link
Member

This is really neat! Thank you for the PR!

@soupette soupette added the flag: don't merge This PR should not be merged at the moment label Mar 30, 2021
@soupette
Copy link
Contributor

Thank you for your contribution, we will review it soon

@sam-pires
Copy link
Contributor

sam-pires commented Apr 7, 2021

Hello @iicdii
Thanks for the PR 🙂

In order to review the PR could you give us more context about your need, please?

  • How many roles do you have in your project(s)?
  • How often do you create new roles?
  • How often do you need to duplicate roles and why do you need several roles with the same permissions?

On a side note, have you considered using the same duplicate system as in RBAC?

Capture d’écran 2021-04-07 à 09 58 46

That will help us a lot!
Thanks

@sam-pires sam-pires requested a review from JabStrapi April 7, 2021 08:05
@iicdii
Copy link
Contributor Author

iicdii commented Apr 7, 2021

Hello @sam-pires!

  • How many roles do you have in your project(s)?
    We have 3 admin roles (created by Strapi), and 7 users roles in users-permission plugin.

  • How often do you create new roles?
    When I built first project, we started 3 roles (Public, Authenticated, Admin). Then there were requests to add new roles from client and it's now 7 roles.

  • How often do you need to duplicate roles?
    Every time I need to create new role. Because the permissions are always same as Authenticated role, but only some APIs' permission are required for new role.

  • Why do you need several roles with the same permissions?
    We built pages which only some users can access and use in front-end. So we don't use RBAC but roles are separated for users signed in normal auth process. (We built site when Strapi was in beta, so there wasn't RBAC anyway)

  • On a side note, have you considered using the same duplicate system as in RBAC?
    Yes, it's good but you need to create new one when you use it. When roles are already existed, you probably need to remove old one and create new one using duplicate button. But my PR can cover both case creating new one and updating existing one.

@alexandrebodin alexandrebodin added the issue: feature request Issue suggesting a new feature label May 11, 2021
@iicdii
Copy link
Contributor Author

iicdii commented Dec 4, 2021

Close since v4 is out, it needs rework

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flag: don't merge This PR should not be merged at the moment issue: feature request Issue suggesting a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants