mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add members settings page for organizations (#13817)
This commit is contained in:
@@ -66,8 +66,11 @@ type OrganizationMember struct {
|
||||
Roles []SlimRole `table:"organization_roles" json:"roles"`
|
||||
}
|
||||
|
||||
type OrganizationMemberWithName struct {
|
||||
Username string `table:"username,default_sort" json:"username"`
|
||||
type OrganizationMemberWithUserData struct {
|
||||
Username string `table:"username,default_sort" json:"username"`
|
||||
Name string `table:"name" json:"name"`
|
||||
AvatarURL string `json:"avatar_url"`
|
||||
GlobalRoles []SlimRole `json:"global_roles"`
|
||||
OrganizationMember `table:"m,recursive_inline"`
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -402,14 +402,14 @@ func (c *Client) DeleteOrganizationMember(ctx context.Context, organizationID uu
|
||||
return err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != http.StatusOK {
|
||||
if res.StatusCode != http.StatusNoContent {
|
||||
return ReadBodyAsError(res)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// OrganizationMembers lists all members in an organization
|
||||
func (c *Client) OrganizationMembers(ctx context.Context, organizationID uuid.UUID) ([]OrganizationMemberWithName, error) {
|
||||
func (c *Client) OrganizationMembers(ctx context.Context, organizationID uuid.UUID) ([]OrganizationMemberWithUserData, error) {
|
||||
res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/organizations/%s/members/", organizationID), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -418,7 +418,7 @@ func (c *Client) OrganizationMembers(ctx context.Context, organizationID uuid.UU
|
||||
if res.StatusCode != http.StatusOK {
|
||||
return nil, ReadBodyAsError(res)
|
||||
}
|
||||
var members []OrganizationMemberWithName
|
||||
var members []OrganizationMemberWithUserData
|
||||
return members, json.NewDecoder(res.Body).Decode(&members)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user