mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add role selector in the create user form (#24711)
Adds a role selector to the create user form so admins can assign site-level roles at creation time rather than navigating to the user afterward. The `POST /api/v2/users` endpoint now accepts an optional `roles` field, wiring it through to the existing `RBACRoles` field on the internal `CreateUserRequest`. No database changes are needed since roles are already stored inline on the user row. On the frontend, a `RoleSelector` component renders the assignable roles as a scrollable multiselect checklist with the non-assignable Member role pinned as a non-interactive footer. The selector appears once a login type is chosen. Also adds a `condensed` size (690px) to `Margins` between the existing `small` (460px) and `medium` (1080px), and exposes a `size` prop on `FullPageForm`. The create user form uses `condensed` to give the role selector more breathing room. Also fixes `MockUserAdminRole` and `MockTemplateAdminRole` in test helpers to use hyphenated names (`user-admin`, `template-admin`) matching the canonical names in the Go RBAC layer. Fixes `sortRolesByAccessLevel` in `UserRoleCell` to sort unranked roles (e.g. `member`) after all known roles. Previously, `indexOf` returned -1 for unknown names, placing them first; now they receive `POSITIVE_INFINITY` as their rank. 🤖 Generated with [Claude Code](<https://claude.ai/claude-code>) --- https://github.com/user-attachments/assets/75e7c8c5-d0d2-481d-86e8-1fcfb574517c --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
ab75e46f1d
commit
0754016512
Generated
+4
@@ -2747,6 +2747,9 @@ This is required on creation to enable a user-flow of validating a template work
|
||||
"497f6eca-6276-4993-bfeb-53cbbbba6f08"
|
||||
],
|
||||
"password": "string",
|
||||
"roles": [
|
||||
"string"
|
||||
],
|
||||
"service_account": true,
|
||||
"user_status": "active",
|
||||
"username": "string"
|
||||
@@ -2762,6 +2765,7 @@ This is required on creation to enable a user-flow of validating a template work
|
||||
| `name` | string | false | | |
|
||||
| `organization_ids` | array of string | false | | Organization ids is a list of organization IDs that the user should be a member of. |
|
||||
| `password` | string | false | | |
|
||||
| `roles` | array of string | false | | Roles is an optional list of site-level roles to assign at creation. |
|
||||
| `service_account` | boolean | false | | Service accounts are admin-managed accounts that cannot login. |
|
||||
| `user_status` | [codersdk.UserStatus](#codersdkuserstatus) | false | | User status defaults to UserStatusDormant. |
|
||||
| `username` | string | true | | |
|
||||
|
||||
Generated
+3
@@ -92,6 +92,9 @@ curl -X POST http://coder-server:8080/api/v2/users \
|
||||
"497f6eca-6276-4993-bfeb-53cbbbba6f08"
|
||||
],
|
||||
"password": "string",
|
||||
"roles": [
|
||||
"string"
|
||||
],
|
||||
"service_account": true,
|
||||
"user_status": "active",
|
||||
"username": "string"
|
||||
|
||||
Reference in New Issue
Block a user