1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/frontend/src
Nuno Góis 0b3ed79ecc
refactor: roles - make better plan assumptions (#4113)
https://linear.app/unleash/issue/2-1171/refactor-custom-root-roles-with-correct-plan-assumptions

This cleans up the hotfix `RoleSelect2` component and makes `RoleSelect`
take in a `roles` prop from the parent component.

This also simplifies the role hooks again to assume Enterprise plan by
default. This means, however, that we must ensure that we only call
these hooks in Enterprise features or, if we do call them in other
plans, that we provide a graceful fallback for non-Enterprise.
Non-Enterprise instances do not have this endpoint, and so they are
currently grabbing role information from e.g. `useUsers` and
`useServiceAccounts`.

I'm not sure how I feel about this. Roles are an overarching concept of
Unleash. To me, having to be extremely conscious about the exact
scenario in which you're using such a hook feels like a trap, instead of
"I need roles, so I'll grab the `useRoles` hook and not think much about
it". I also don't like the way `roles` are currently tied to the users,
service accounts, project access, (...) instead of being its own thing.

This could be solved by a `RoleController` exposing the GET endpoints in
OSS, since all of the logic we need for this use-case lives there
anyways. This would then be overridden with the Enterprise-specific
controller when wrapped. This way we could assume the endpoint is always
there, no matter the plan.
This is just an idea and not something I explored in the PR. For now I'm
just focusing on leaving this feature in a sane state.

Tested this manually on `Pro` and `Enterprise` and I believe everything
is acting the way we intend, but would love some extra eyes.
2023-06-28 16:00:14 +01:00
..
__mocks__
assets
component refactor: roles - make better plan assumptions (#4113) 2023-06-28 16:00:14 +01:00
constants
contexts refactor: token permissions, drop admin-like permissions (#4050) 2023-06-22 08:35:54 +01:00
hooks refactor: roles - make better plan assumptions (#4113) 2023-06-28 16:00:14 +01:00
interfaces chore: remove strategyImprovements flag (#4043) 2023-06-28 11:38:21 +03:00
openapi chore: update orval models (#4062) 2023-06-22 09:52:21 +00:00
themes fix: misc UI fixes mostly responsiveness related (#3868) 2023-05-25 20:28:08 +03:00
types
utils chore: remove strategyImprovements flag (#4043) 2023-06-28 11:38:21 +03:00
index.tsx
setupTests.ts
vite-env.d.ts