Provide extension point to provide a custom set of power levels to role label mapping #6
Description
Is your feature request related to a problem? Please describe.
We have custom requirements of introducing more "roles" to Element. In general the power level model is quite flexible when it comes to custom setups. However, in this case it is important that the user can see a name and not just a custom power level in the UI. This affects the following parts of the UI:
I may have missed a part of the UI.
Describe the solution you'd like
The module system provides a hook that we can override. If it is overridden, the module is responsible for returning a map of roles to translated labels. The matrix-react-sdk
calls this hook whenever it needs to resolve a power level to a role, or displays a role selection dropdown.
Right now it is used in multiple places which define multiple power level to role maps:
- Power Level Selection for a member and settings dialog https://github.com/matrix-org/matrix-react-sdk/blob/develop/src/components/views/elements/PowerSelector.tsx#L166-L171
- Readonly display for a single member: https://github.com/matrix-org/matrix-react-sdk/blob/develop/src/components/views/right_panel/UserInfo.tsx#L988
- Central role definition: https://github.com/matrix-org/matrix-react-sdk/blob/develop/src/Roles.ts
- Member List in the Sidebar https://github.com/matrix-org/matrix-react-sdk/blob/develop/src/components/views/rooms/EntityTile.tsx#L167-L171
- Finding closes role: https://github.com/matrix-org/matrix-react-sdk/blob/develop/src/components/views/rooms/MemberTile.tsx#L203-L217
All these places have to use the new hook of the module system to get the map of power level to role mapping.
Describe alternatives you've considered
Currently we achieve this changes by forking Element and the matrix-react-sdk
, however, to resolve the fork, we want to move it to the module system.
I would also be open to add it to the matrix-react-sdk
itself, but I see the problem that new roles would require custom translatable labels, which the module system already supports. So I think it is a better fit here.
There are also ideas to extend this to be user customizable per room element-hq/element-meta#87, however our primary goal is to make it a global configuration. But one can interpret the feature request also as introducing groups. Here I still wonder how to make it translatable. We could change the default room events to include this custom configuration in every room we create.
Additional context