mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add a theme picker (#11140)
This commit is contained in:
+20
-1
@@ -55,6 +55,7 @@ type User struct {
|
||||
Roles []Role `json:"roles"`
|
||||
AvatarURL string `json:"avatar_url" format:"uri"`
|
||||
LoginType LoginType `json:"login_type"`
|
||||
ThemePreference string `json:"theme_preference"`
|
||||
}
|
||||
|
||||
type GetUsersResponse struct {
|
||||
@@ -92,6 +93,10 @@ type UpdateUserProfileRequest struct {
|
||||
Username string `json:"username" validate:"required,username"`
|
||||
}
|
||||
|
||||
type UpdateUserAppearanceSettingsRequest struct {
|
||||
ThemePreference string `json:"theme_preference" validate:"required"`
|
||||
}
|
||||
|
||||
type UpdateUserPasswordRequest struct {
|
||||
OldPassword string `json:"old_password" validate:""`
|
||||
Password string `json:"password" validate:"required"`
|
||||
@@ -249,7 +254,7 @@ func (c *Client) DeleteUser(ctx context.Context, id uuid.UUID) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateUserProfile enables callers to update profile information
|
||||
// UpdateUserProfile updates the username of a user.
|
||||
func (c *Client) UpdateUserProfile(ctx context.Context, user string, req UpdateUserProfileRequest) (User, error) {
|
||||
res, err := c.Request(ctx, http.MethodPut, fmt.Sprintf("/api/v2/users/%s/profile", user), req)
|
||||
if err != nil {
|
||||
@@ -288,6 +293,20 @@ func (c *Client) UpdateUserStatus(ctx context.Context, user string, status UserS
|
||||
return resp, json.NewDecoder(res.Body).Decode(&resp)
|
||||
}
|
||||
|
||||
// UpdateUserAppearanceSettings updates the appearance settings for a user.
|
||||
func (c *Client) UpdateUserAppearanceSettings(ctx context.Context, user string, req UpdateUserAppearanceSettingsRequest) (User, error) {
|
||||
res, err := c.Request(ctx, http.MethodPut, fmt.Sprintf("/api/v2/users/%s/appearance", user), req)
|
||||
if err != nil {
|
||||
return User{}, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != http.StatusOK {
|
||||
return User{}, ReadBodyAsError(res)
|
||||
}
|
||||
var resp User
|
||||
return resp, json.NewDecoder(res.Body).Decode(&resp)
|
||||
}
|
||||
|
||||
// UpdateUserPassword updates a user password.
|
||||
// It calls PUT /users/{user}/password
|
||||
func (c *Client) UpdateUserPassword(ctx context.Context, user string, req UpdateUserPasswordRequest) error {
|
||||
|
||||
Reference in New Issue
Block a user