matrix-org / matrix-react-sdk-module-api

API surface for writing Modules for the react-sdk
Apache License 2.0
3 stars 8 forks source link

Provide extension point to provide a custom set of power levels to role label mapping #6

Open Fox32 opened 2 years ago

Fox32 commented 2 years ago

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:

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 https://github.com/vector-im/element-meta/issues/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

turt2live commented 2 years ago

For clarity, are you looking to add new mappings or just change the labels?

Fox32 commented 2 years ago

We want to add additional mappings.

We also have the case to rename them, but that case ist already supported by the module system 🙂

Fox32 commented 1 year ago

We are currently opposed to bringing this feature to the module system.

While it would help us short term to support the custom roles, it won't work on other apps like Element Android or iOS. Therefore we need a more "standard" approach that is part of the spec. So a solution like https://github.com/vector-im/element-meta/issues/87 or https://github.com/matrix-org/matrix-spec-proposals/pull/2812 would be a better solution for us.

Fox32 commented 1 year ago

https://github.com/matrix-org/matrix-spec-proposals/pull/3949 might be a good alternative.