-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable owners to change user roles (#648)
### Summary & Motivation Enable owners to change the roles of other users, such as switching from Member to Admin or Owner. This functionality is implemented in a new modal dialog with a dropdown for selecting roles. A new `UserRole.ts` file has been introduced to support translations of all options in the `UserRole` enum. The `AlertDialog` has been updated to support configurations without action buttons (e.g., OK and Cancel), as selecting a role in the dropdown automatically submits the change. Additionally, a new size option for the header has been added to allow for smaller headings. To ensure tenant integrity, it is not possible for users to change their own role, preventing scenarios where a tenant could be left without an owner. This is a UI change only, as there are other ways to lose access to the sole owner. ### Checklist - [x] I have added a Label to the pull-request - [x] I have added tests, and done manual regression tests - [x] I have updated the documentation, if necessary
- Loading branch information
Showing
7 changed files
with
195 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
application/account-management/WebApp/shared/lib/api/userRole.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { t } from "@lingui/core/macro"; | ||
import { UserRole } from "@/shared/lib/api/client"; | ||
|
||
export function getUserRoleLabel(role: UserRole): string { | ||
switch (role) { | ||
case UserRole.Member: | ||
return t`Member`; | ||
case UserRole.Admin: | ||
return t`Admin`; | ||
case UserRole.Owner: | ||
return t`Owner`; | ||
default: { | ||
return String(role); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,9 @@ msgstr "Tilføj flere i brugermenuen" | |
msgid "Added" | ||
msgstr "Tilføjet" | ||
|
||
msgid "Admin" | ||
msgstr "Admin" | ||
|
||
msgid "All Users" | ||
msgstr "Alle brugere" | ||
|
||
|
@@ -48,8 +51,8 @@ msgid "An error occurred while processing your request. {0}" | |
msgstr "Der opstod en fejl under behandlingen af din anmodning. {0}" | ||
|
||
#. placeholder {0}: `${userToDelete?.firstName ?? ""} ${userToDelete?.lastName ?? ""}`.trim() || userToDelete?.email | ||
msgid "Are you sure you want to delete {0}?" | ||
msgstr "Er du sikker på, at du vil slette {0}?" | ||
msgid "Are you sure you want to delete <0>{0}?</0>" | ||
msgstr "Er du sikker på, at du vil slette <0>{0}?</0>" | ||
|
||
msgid "By continuing, you accept our policies" | ||
msgstr "Ved at fortsætte accepterer du vores vilkår" | ||
|
@@ -63,6 +66,12 @@ msgstr "Annuller" | |
msgid "Change avatar options" | ||
msgstr "Skift avatarindstillinger" | ||
|
||
msgid "Change Role" | ||
msgstr "Skift rolle" | ||
|
||
msgid "Change User Role" | ||
msgstr "Skift brugerrolle" | ||
|
||
msgid "Continue" | ||
msgstr "Fortsæt" | ||
|
||
|
@@ -183,6 +192,9 @@ msgstr "Administrer din konto her." | |
msgid "Manage your users and permissions here." | ||
msgstr "Administrer dine brugere og tilladelser her." | ||
|
||
msgid "Member" | ||
msgstr "Medlem" | ||
|
||
msgid "Menu" | ||
msgstr "Menu" | ||
|
||
|
@@ -201,6 +213,9 @@ msgstr "Ingen aktiv tilmeldingssession" | |
msgid "Organization" | ||
msgstr "Organisation" | ||
|
||
msgid "Owner" | ||
msgstr "Ejer" | ||
|
||
msgid "Pending" | ||
msgstr "Afventer" | ||
|
||
|
@@ -246,6 +261,10 @@ msgstr "Skærmbilleder af dashboard-projektet med mobilversioner" | |
msgid "Search" | ||
msgstr "Søg" | ||
|
||
#. placeholder {0}: `${userToChangeRole?.firstName ?? ""} ${userToChangeRole?.lastName ?? ""}`.trim() || userToChangeRole?.email | ||
msgid "Select a new role for <0>{0}</0>" | ||
msgstr "Vælg en ny rolle for <0>{0}</0>" | ||
|
||
msgid "Send invite" | ||
msgstr "Send invitation" | ||
|
||
|
@@ -288,6 +307,9 @@ msgstr "Upload foto" | |
msgid "User profile" | ||
msgstr "Brugerprofil" | ||
|
||
msgid "User Role" | ||
msgstr "Brugerrolle" | ||
|
||
msgid "[email protected]" | ||
msgstr "[email protected]" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,9 @@ msgstr "Add more in the Users menu" | |
msgid "Added" | ||
msgstr "Added" | ||
|
||
msgid "Admin" | ||
msgstr "Admin" | ||
|
||
msgid "All Users" | ||
msgstr "All Users" | ||
|
||
|
@@ -48,8 +51,8 @@ msgid "An error occurred while processing your request. {0}" | |
msgstr "An error occurred while processing your request. {0}" | ||
|
||
#. placeholder {0}: `${userToDelete?.firstName ?? ""} ${userToDelete?.lastName ?? ""}`.trim() || userToDelete?.email | ||
msgid "Are you sure you want to delete {0}?" | ||
msgstr "Are you sure you want to delete {0}?" | ||
msgid "Are you sure you want to delete <0>{0}?</0>" | ||
msgstr "Are you sure you want to delete <0>{0}?</0>" | ||
|
||
msgid "By continuing, you accept our policies" | ||
msgstr "By continuing, you accept our policies" | ||
|
@@ -63,6 +66,12 @@ msgstr "Cancel" | |
msgid "Change avatar options" | ||
msgstr "Change avatar options" | ||
|
||
msgid "Change Role" | ||
msgstr "Change Role" | ||
|
||
msgid "Change User Role" | ||
msgstr "Change User Role" | ||
|
||
msgid "Continue" | ||
msgstr "Continue" | ||
|
||
|
@@ -183,6 +192,9 @@ msgstr "Manage your account here." | |
msgid "Manage your users and permissions here." | ||
msgstr "Manage your users and permissions here." | ||
|
||
msgid "Member" | ||
msgstr "Member" | ||
|
||
msgid "Menu" | ||
msgstr "Menu" | ||
|
||
|
@@ -201,6 +213,9 @@ msgstr "No active signup session" | |
msgid "Organization" | ||
msgstr "Organization" | ||
|
||
msgid "Owner" | ||
msgstr "Owner" | ||
|
||
msgid "Pending" | ||
msgstr "Pending" | ||
|
||
|
@@ -246,6 +261,10 @@ msgstr "Screenshots of the dashboard project with mobile versions" | |
msgid "Search" | ||
msgstr "Search" | ||
|
||
#. placeholder {0}: `${userToChangeRole?.firstName ?? ""} ${userToChangeRole?.lastName ?? ""}`.trim() || userToChangeRole?.email | ||
msgid "Select a new role for <0>{0}</0>" | ||
msgstr "Select a new role for <0>{0}</0>" | ||
|
||
msgid "Send invite" | ||
msgstr "Send invite" | ||
|
||
|
@@ -288,6 +307,9 @@ msgstr "Upload photo" | |
msgid "User profile" | ||
msgstr "User profile" | ||
|
||
msgid "User Role" | ||
msgstr "User Role" | ||
|
||
msgid "[email protected]" | ||
msgstr "[email protected]" | ||
|
||
|
Oops, something went wrong.