Skip to content

Commit 2debc91

Browse files
committed
Add display name to edit group UI
1 parent 603550b commit 2debc91

File tree

6 files changed

+23
-29
lines changed

6 files changed

+23
-29
lines changed

codersdk/groups.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ type PatchGroupRequest struct {
100100
AddUsers []string `json:"add_users"`
101101
RemoveUsers []string `json:"remove_users"`
102102
Name string `json:"name"`
103-
DisplayName string `db:"display_name" json:"display_name"`
103+
DisplayName *string `json:"display_name"`
104104
AvatarURL *string `json:"avatar_url"`
105105
QuotaAllowance *int `json:"quota_allowance"`
106106
}

docs/cli/groups_list.md

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

enterprise/coderd/groups.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ func (api *API) postGroupByOrganization(rw http.ResponseWriter, r *http.Request)
5353
return
5454
}
5555

56-
// Default the name and display name to the same.
57-
if req.DisplayName == "" {
58-
req.DisplayName = req.Name
59-
}
60-
6156
group, err := api.Database.InsertGroup(ctx, database.InsertGroupParams{
6257
ID: uuid.New(),
6358
Name: req.Name,
@@ -197,8 +192,8 @@ func (api *API) patchGroup(rw http.ResponseWriter, r *http.Request) {
197192
if req.QuotaAllowance != nil {
198193
updateGroupParams.QuotaAllowance = int32(*req.QuotaAllowance)
199194
}
200-
if req.DisplayName != "" {
201-
updateGroupParams.DisplayName = req.DisplayName
195+
if req.DisplayName != nil {
196+
updateGroupParams.DisplayName = *req.DisplayName
202197
}
203198

204199
group, err = tx.UpdateGroupByID(ctx, updateGroupParams)

site/src/api/typesGenerated.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ export interface CreateFirstUserResponse {
175175
// From codersdk/groups.go
176176
export interface CreateGroupRequest {
177177
readonly name: string
178+
readonly display_name: string
178179
readonly avatar_url: string
179180
readonly quota_allowance: number
180181
}
@@ -666,7 +667,7 @@ export interface PatchGroupRequest {
666667
readonly add_users: string[]
667668
readonly remove_users: string[]
668669
readonly name: string
669-
readonly display_name: string
670+
readonly display_name?: string
670671
readonly avatar_url?: string
671672
readonly quota_allowance?: number
672673
}

site/src/pages/GroupsPage/CreateGroupPageView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const CreateGroupPageView: FC<CreateGroupPageViewProps> = ({
2929
const form = useFormik<CreateGroupRequest>({
3030
initialValues: {
3131
name: "",
32+
display_name: "",
3233
avatar_url: "",
3334
quota_allowance: 0,
3435
},

site/src/pages/GroupsPage/SettingsGroupPageView.tsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const UpdateGroupForm: FC<{
3737
name: group.name,
3838
// If these are equal, keep the display name blank. A blank display name means
3939
// default to using the name.
40-
display_name: group.display_name === group.name ? "" : group.display_name,
40+
display_name: group.display_name,
4141
avatar_url: group.avatar_url,
4242
quota_allowance: group.quota_allowance,
4343
},
@@ -59,27 +59,24 @@ const UpdateGroupForm: FC<{
5959
fullWidth
6060
label="Name"
6161
/>
62-
{/* We might want to always show this at some point, but for now only show if
63-
the display name differs from the original name. */}
64-
{group.name !== group.display_name && (
65-
<TextField
66-
{...getFieldHelpers("display_name")}
67-
onChange={onChangeTrimmed(form)}
68-
autoComplete="display_name"
69-
autoFocus
70-
fullWidth
71-
label="Display Name"
72-
/>
73-
)}
74-
62+
<TextField
63+
{...getFieldHelpers(
64+
"display_name",
65+
"Optional: keep empty to default to the name.",
66+
)}
67+
onChange={onChangeTrimmed(form)}
68+
autoComplete="display_name"
69+
autoFocus
70+
fullWidth
71+
label="Display Name"
72+
/>
7573
<LazyIconField
7674
{...getFieldHelpers("avatar_url")}
7775
onChange={onChangeTrimmed(form)}
7876
fullWidth
7977
label={t("form.fields.icon")}
8078
onPickEmoji={(value) => form.setFieldValue("avatar_url", value)}
8179
/>
82-
8380
<TextField
8481
{...getFieldHelpers(
8582
"quota_allowance",

0 commit comments

Comments
 (0)