Skip to content

feat: add display_name field to groups #8740

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

Merged
merged 20 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix insert all users group
  • Loading branch information
Emyrk committed Jul 26, 2023
commit 15f19faeffa99ff3d88ba28c060974be83ed6264
1 change: 1 addition & 0 deletions coderd/database/dbfake/dbfake.go
Original file line number Diff line number Diff line change
Expand Up @@ -3381,6 +3381,7 @@ func (q *FakeQuerier) InsertAllUsersGroup(ctx context.Context, orgID uuid.UUID)
return q.InsertGroup(ctx, database.InsertGroupParams{
ID: orgID,
Name: database.AllUsersGroup,
DisplayName: database.AllUsersGroup,
OrganizationID: orgID,
})
}
Expand Down
4 changes: 3 additions & 1 deletion coderd/database/dbgen/dbgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,11 @@ func OrganizationMember(t testing.TB, db database.Store, orig database.Organizat
}

func Group(t testing.TB, db database.Store, orig database.Group) database.Group {
name := takeFirst(orig.Name, namesgenerator.GetRandomName(1))
group, err := db.InsertGroup(genCtx, database.InsertGroupParams{
ID: takeFirst(orig.ID, uuid.New()),
Name: takeFirst(orig.Name, namesgenerator.GetRandomName(1)),
Name: name,
DisplayName: takeFirst(orig.DisplayName, name),
OrganizationID: takeFirst(orig.OrganizationID, uuid.New()),
AvatarURL: takeFirst(orig.AvatarURL, "https://logo.example.com"),
QuotaAllowance: takeFirst(orig.QuotaAllowance, 0),
Expand Down
3 changes: 2 additions & 1 deletion coderd/database/queries/groups.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ VALUES
INSERT INTO groups (
id,
name,
display_name,
organization_id
)
VALUES
(sqlc.arg(organization_id), 'Everyone', sqlc.arg(organization_id)) RETURNING *;
(sqlc.arg(organization_id), 'Everyone', 'Everyone', sqlc.arg(organization_id)) RETURNING *;

-- name: UpdateGroupByID :one
UPDATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ export const UserOrGroupAutocomplete: React.FC<
}}
isOptionEqualToValue={(option, value) => option.id === value.id}
getOptionLabel={(option) =>
isGroup(option) ? option.name : option.email
isGroup(option) ? option.display_name : option.email
}
renderOption={(props, option) => {
const isOptionGroup = isGroup(option)

return (
<Box component="li" {...props}>
<AvatarData
title={isOptionGroup ? option.name : option.username}
title={isOptionGroup ? option.display_name : option.username}
subtitle={isOptionGroup ? getGroupSubtitle(option) : option.email}
src={option.avatar_url}
/>
Expand Down
7 changes: 7 additions & 0 deletions site/src/pages/GroupsPage/GroupsPageView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ WithGroups.args = {
isTemplateRBACEnabled: true,
}

export const WithDisplayGroup = Template.bind({})
WithGroups.args = {
groups: [{ ...MockGroup, name: "front-end" }],
canCreateGroup: true,
isTemplateRBACEnabled: true,
}

export const EmptyGroup = Template.bind({})
EmptyGroup.args = {
groups: [],
Expand Down