Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Make user role mappings configurable #11441

Closed

Conversation

dhenneke
Copy link
Contributor

@dhenneke dhenneke commented Aug 21, 2023

We want to be able to specify new role labels for power levels. This goes beyond renaming them (-> custom_translations_url or module system) and relates to matrix-org/matrix-react-sdk-module-api#6. There are different MSC proposal but nothing agreed upon, yet, so we would like to introduce a Client-global configuration until a more flexible and standardised solution will become available eventually. This assumes that all rooms in a controlled Element/Synapse installation use the same roles.

We create a new setting custom_power_level_roles (it could also be a custom_power_level_roles_url if you would prefer that):

Docs for Element Web that I will create a PR for once we agreed on how to move on

Custom user role mappings

Element maps common power levels to a human readable identifier. These are by default:

  • 0: "Default" ("Restricted", if a custom default user level is configured in the room)
  • 50: "Moderator"
  • 100: "Admin"

They can be replaced globally with the custom_power_level_roles configuration:

{
    "custom_power_level_roles": {
        "0": {
            "en": "Noob",
            "de": "Niemand",
            // other languages...
        },
        "25": {
            "en": "Crew",
            "de": "Mannschaft"
        },
        "50": {
            "en": "Head of Staff",
            "de": "Stabschef"
        },
        "100": {
            "en": "Captain",
            "de": "Kapitän"
        }
    }
}

This will replace the complete set of default labels so you can't fall back to the default labels. Any unknown languages will fall back to the English translation.

This PR also adds UIFeature.customPowerLevel in order to hide the "Custom Level" option that might be discouraged in certain environments:

Docs for Element Web that I will create a PR for once we agreed on how to move on

  • UIFeature.customPowerLevel - Whether or not a custom power level is settable.

This is used in the following places:

image
image
image

It's not used in the people list, yet, because I'm not sure what the intention there is. It looks like this explicitly uses short-forms of the labels to better fit in the sidebar so we can't just use the labels from above.

image

We could do:

{
  "custom_power_level_roles": {
    "0": {
      "label": {
        "en": "Noob",
        "de": "Niemand",
      },
      "short_label": { /* no label */ },
    },
    "25": {
      "label": {
        "en": "Crew",
        "de": "Mannschaft"
      },
      "short_label": { "en": "Crew" }
    },
    // ...
  }
}

but I would be happy about some feedback.

Checklist

  • Tests written for new code (and old code if feasible)
  • Linter and other CI checks pass
  • Sign-off given on the changes (see CONTRIBUTING.md)

Type: enhancement


Here's what your changelog entry will look like:

✨ Features

@dhenneke dhenneke requested a review from a team as a code owner August 21, 2023 14:48
@github-actions github-actions bot added Z-Community-PR Issue is solved by a community member's PR T-Enhancement New features, changes in functionality, performance boosts, user-facing improvements labels Aug 21, 2023
Signed-off-by: Dominik Henneke <dominik.henneke@nordeck.net>
@@ -33,6 +33,7 @@ export const enum UIFeature {
RoomHistorySettings = "UIFeature.roomHistorySettings",
TimelineEnableRelativeDates = "UIFeature.timelineEnableRelativeDates",
BulkUnverifiedSessionsReminder = "UIFeature.BulkUnverifiedSessionsReminder",
CustomPowerLevel = "UIFeature.customPowerLevel",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Johennes Johennes added A-Timesheet-1 Log any time spent on this into the A-Timesheet-1 project and removed Z-Community-PR Issue is solved by a community member's PR labels Aug 24, 2023
@Johennes
Copy link
Contributor

I've updated the time sheeting label on this pull request. Reviewers, please take this into account when filling your sheets.

@germain-gg germain-gg removed their request for review August 30, 2023 06:56
@Johennes
Copy link
Contributor

Johennes commented Oct 2, 2023

Based on our chat on Matrix, I'm going to assume that overriding the translations of the existing roles will be sufficient for your needs for now and that we can avoid polluting the config / module API until the larger problem is solved on the spec level. The fixes to unbreak the latter should be landing this week (matrix-org/matrix-web-i18n#13, matrix-org/matrix-react-sdk-module-api#20, #11685 & element-hq/element-web#26262).

@Johennes Johennes closed this Oct 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Timesheet-1 Log any time spent on this into the A-Timesheet-1 project T-Enhancement New features, changes in functionality, performance boosts, user-facing improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants