1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
unleash.unleash/src/test/fixtures
Nuno Góis bb026c0ba1
feat: custom root roles (#3975)
## About the changes
Implements custom root roles, encompassing a lot of different areas of
the project, and slightly refactoring the current roles logic. It
includes quite a clean up.

This feature itself is behind a flag: `customRootRoles`

This feature covers root roles in:
 - Users;
 - Service Accounts;
 - Groups;

Apologies in advance. I may have gotten a bit carried away 🙈 

### Roles

We now have a new admin tab called "Roles" where we can see all root
roles and manage custom ones. We are not allowed to edit or remove
*predefined* roles.

![image](https://github.com/Unleash/unleash/assets/14320932/1ad8695c-8c3f-440d-ac32-39746720d588)
This meant slightly pushing away the existing roles to `project-roles`
instead. One idea we want to explore in the future is to unify both
types of roles in the UI instead of having 2 separate tabs. This
includes modernizing project roles to fit more into our current design
and decisions.

Hovering the permissions cell expands detailed information about the
role:

![image](https://github.com/Unleash/unleash/assets/14320932/81c4aae7-8b4d-4cb4-92d1-8f1bc3ef1f2a)

### Create and edit role

Here's how the role form looks like (create / edit):

![image](https://github.com/Unleash/unleash/assets/14320932/85baec29-bb10-48c5-a207-b3e9a8de838a)
Here I categorized permissions so it's easier to visualize and manage
from a UX perspective.

I'm using the same endpoint as before. I tried to unify the logic and
get rid of the `projectRole` specific hooks. What distinguishes custom
root roles from custom project roles is the extra `root-custom` type we
see on the payload. By default we assume `custom` (custom project role)
instead, which should help in terms of backwards compatibility.

### Delete role

When we delete a custom role we try to help the end user make an
informed decision by listing all the entities which currently use this
custom root role:

![image](https://github.com/Unleash/unleash/assets/14320932/352ed529-76be-47a8-88da-5e924fb191d4)
~~As mentioned in the screenshot, when deleting a custom role, we demote
all entities associated with it to the predefined `Viewer` role.~~
**EDIT**: Apparently we currently block this from the API
(access-service deleteRole) with a message:

![image](https://github.com/Unleash/unleash/assets/14320932/82a8e50f-8dc5-4c18-a2ba-54e2ae91b91c)
What should the correct behavior be?

### Role selector

I added a new easy-to-use role selector component that is present in:
 - Users 

![image](https://github.com/Unleash/unleash/assets/14320932/76953139-7fb6-437e-b3fa-ace1d9187674)
 - Service Accounts

![image](https://github.com/Unleash/unleash/assets/14320932/2b80bd55-9abb-4883-b715-15650ae752ea)
- Groups

![image](https://github.com/Unleash/unleash/assets/14320932/ab438f7c-2245-4779-b157-2da1689fe402)

### Role description

I also added a new role description component that you can see below the
dropdown in the selector component, but it's also used to better
describe each role in the respective tables:

![image](https://github.com/Unleash/unleash/assets/14320932/a3eecac1-2a34-4500-a68c-e3f62ebfa782)

I'm not listing all the permissions of predefined roles. Those simply
show the description in the tooltip:

![image](https://github.com/Unleash/unleash/assets/14320932/7e5b2948-45f0-4472-8311-bf533409ba6c)

### Role badge

Groups is a bit different, since it uses a list of cards, so I added yet
another component - Role badge:

![image](https://github.com/Unleash/unleash/assets/14320932/1d62c3db-072a-4c97-b86f-1d8ebdd3523e)

I'm using this same component on the profile tab:

![image](https://github.com/Unleash/unleash/assets/14320932/214272db-a828-444e-8846-4f39b9456bc6)

## Discussion points
- Are we being defensive enough with the use of the flag? Should we
cover more?
 - Are we breaking backwards compatibility in any way?
 - What should we do when removing a role? Block or demote?
- Maybe some existing permission-related issues will surface with this
change: Are we being specific enough with our permissions? A lot of
places are simply checking for `ADMIN`;
- We may want to get rid of the API roles coupling we have with the
users and SAs and instead use the new hooks (e.g. `useRoles`)
explicitly;
 - We should update the docs;
- Maybe we could allow the user to add a custom role directly from the
role selector component;

---------

Co-authored-by: Gastón Fournier <gaston@getunleash.io>
2023-06-14 14:40:40 +01:00
..
access-service-mock.ts feat: custom root roles (#3975) 2023-06-14 14:40:40 +01:00
fake-access-store.ts feat: custom root roles (#3975) 2023-06-14 14:40:40 +01:00
fake-account-store.ts fix: add confirmation to disable password login (#3829) 2023-05-23 15:56:34 +01:00
fake-addon-store.ts OpenAPI: addon operations (#3421) 2023-04-18 10:50:34 +00:00
fake-api-token-store.ts Feat/add alias to api tokens (#1931) 2022-08-19 10:48:33 +02:00
fake-client-applications-store.ts refactor: replace ts-ignore with ts-expect-error (#1675) 2022-06-07 11:49:17 +02:00
fake-client-instance-store.ts Remove timeout from store (#3018) 2023-01-30 12:01:44 +01:00
fake-client-metrics-store-v2.ts feat: remove old metrics service 2021-12-10 09:31:54 +01:00
fake-context-field-store.ts Feat/stats service (#2211) 2022-10-25 13:10:27 +02:00
fake-environment-store.ts Update environments (#2339) 2022-11-11 10:24:56 +00:00
fake-event-store.ts feat: postgres lock (#3443) 2023-04-04 13:28:17 +02:00
fake-favorite-features-store.ts Favorite features (#2550) 2022-11-29 16:06:08 +01:00
fake-favorite-projects-store.ts Favorite project (#2569) 2022-11-30 13:41:53 +02:00
fake-feature-environment-store.ts feat: add warning hints on potential misconfiguration (#2948) 2023-01-20 18:09:01 +01:00
fake-feature-strategies-store.ts feat: add instance stats to version check (#3835) 2023-06-13 15:54:20 +02:00
fake-feature-tag-store.ts feat: export by tags (#3635) 2023-04-27 10:22:14 +02:00
fake-feature-toggle-client-store.ts Favorite features (#2550) 2022-11-29 16:06:08 +01:00
fake-feature-toggle-store.ts feat: save memory on reading stats (#3472) 2023-04-06 15:34:08 +02:00
fake-feature-type-store.ts refactor: add OpenAPI schema to feature types controller (#1684) 2022-06-09 13:17:13 +02:00
fake-group-store.ts fix: block adding a root role to a group with a project role (#3775) 2023-05-16 12:11:32 +02:00
fake-pat-store.ts fix: limit total of PATs a user can have (#2301) 2022-11-02 08:11:35 +00:00
fake-project-stats-store.ts refactor: Improved lead time calculation (#3475) 2023-04-07 13:31:27 +02:00
fake-project-store.ts Feat: project default strategy (#3644) 2023-04-28 14:59:04 +03:00
fake-public-signup-store.ts Feat/invite user (#2061) 2022-09-30 13:01:32 +02:00
fake-reset-token-store.ts fix: Stores as typescript and with interfaces. (#902) 2021-08-12 15:04:37 +02:00
fake-role-store.ts feat: expose project members (#3310) 2023-03-14 16:27:57 +01:00
fake-segment-store.ts Feat/stats service (#2211) 2022-10-25 13:10:27 +02:00
fake-session-store.ts fix: Stores as typescript and with interfaces. (#902) 2021-08-12 15:04:37 +02:00
fake-setting-store.ts feat: Disable password based login (#1046) 2021-10-29 10:25:42 +02:00
fake-strategies-store.ts fixes 2-456: Preserve all data from strategy import (#2720) 2022-12-21 13:33:41 +01:00
fake-tag-store.ts fix: Stores as typescript and with interfaces. (#902) 2021-08-12 15:04:37 +02:00
fake-tag-type-store.ts fix: Stores as typescript and with interfaces. (#902) 2021-08-12 15:04:37 +02:00
fake-user-feedback-store.ts fix: Stores as typescript and with interfaces. (#902) 2021-08-12 15:04:37 +02:00
fake-user-splash-store.ts refactor: add schemas to user admin controller (#1692) 2022-06-22 14:55:43 +02:00
fake-user-store.ts feat: adapt user logic to better adapt to SAs (#2917) 2023-01-18 12:12:44 +00:00
no-logger.ts fix: Stores as typescript and with interfaces. (#902) 2021-08-12 15:04:37 +02:00
permissions.ts fix: convert files to typescript 2021-09-14 19:30:11 +02:00
store.ts feat: oss import (#3123) 2023-02-16 08:08:51 +01:00