-
Notifications
You must be signed in to change notification settings - Fork 887
fix: Role assign ui fixes #3521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ResourceRoleAssignment: {ActionCreate, ActionRead, ActionUpdate, ActionDelete}, | ||
ResourceUser: {ActionCreate, ActionRead, ActionUpdate, ActionDelete}, | ||
// Full perms to manage org members | ||
ResourceOrganizationMember: {ActionCreate, ActionRead, ActionUpdate, ActionDelete}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs org_member role to create new users
RoleAssignment to assign roles. They can only assign org_member and member roles right now.
export const getSiteRoles = async (): Promise<Array<TypesGen.Role>> => { | ||
const response = await axios.get<Array<TypesGen.Role>>(`/api/v2/users/roles`) | ||
export const getSiteRoles = async (): Promise<Array<TypesGen.AssignableRoles>> => { | ||
const response = await axios.get<Array<TypesGen.AssignableRoles>>(`/api/v2/users/roles`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually, it would be nice differentiate the two roles
endpoints by label a bit more. In the network tab, all I see is "roles" and it's hard to filter or figure out what I'm looking at.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a bad idea
Nice job! Do you mind adding two tests?
LMK if you need help! |
Will get on this tomorrow 👍 |
coderd/rbac/builtin_test.go
Outdated
@@ -251,8 +251,8 @@ func TestRolePermissions(t *testing.T) { | |||
Actions: []rbac.Action{rbac.ActionCreate, rbac.ActionUpdate, rbac.ActionDelete}, | |||
Resource: rbac.ResourceRoleAssignment, | |||
AuthorizeMap: map[bool][]authSubject{ | |||
true: {admin}, | |||
false: {orgAdmin, orgMemberMe, otherOrgAdmin, otherOrgMember, memberMe, templateAdmin, userAdmin}, | |||
true: {admin, userAdmin}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we got rid of admin
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
admin
is just the name of the owner
user. Forgot to rename the var 👍
export const MockSiteRoles = [MockUserAdminRole, MockAuditorRole] | ||
export const MockAssignableSiteRoles = [MockAssignableOwnerRole, MockAssignableUserAdminRole, MockAssignableAuditorRole] | ||
|
||
export function assignableRole(role: TypesGen.Role, assignable: boolean): TypesGen.AssignableRoles { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍
MockOwnerRole, MockTemplateAdminRole, | ||
MockUserAdminRole, | ||
render | ||
} from "../../testHelpers/renderHelpers" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} from "../../testHelpers/renderHelpers" | |
} from "testHelpers/renderHelpers" |
We're trying to favor absolute paths when we're not in the same directory as whatever we're importing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great once CI passes. Thanks for adding those tests.
What this does
Roles you cannot assign are disabled
Fixes
User admin also needs the ability to create organization_members to create a new user. Creating a new user assigns them to the single org atm.