Skip to content

Commit 44a70a5

Browse files
authored
feat: edit org display names and descriptions (coder#13474)
1 parent 1131772 commit 44a70a5

22 files changed

+359
-90
lines changed

coderd/apidoc/docs.go

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

coderd/apidoc/swagger.json

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

coderd/database/dbgen/dbgen.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ func Organization(t testing.TB, db database.Store, orig database.Organization) d
336336
org, err := db.InsertOrganization(genCtx, database.InsertOrganizationParams{
337337
ID: takeFirst(orig.ID, uuid.New()),
338338
Name: takeFirst(orig.Name, namesgenerator.GetRandomName(1)),
339+
DisplayName: takeFirst(orig.Name, namesgenerator.GetRandomName(1)),
339340
Description: takeFirst(orig.Description, namesgenerator.GetRandomName(1)),
340341
CreatedAt: takeFirst(orig.CreatedAt, dbtime.Now()),
341342
UpdatedAt: takeFirst(orig.UpdatedAt, dbtime.Now()),

coderd/database/dbmem/dbmem.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func New() database.Store {
8686
defaultOrg, err := q.InsertOrganization(context.Background(), database.InsertOrganizationParams{
8787
ID: uuid.New(),
8888
Name: "first-organization",
89+
DisplayName: "first-organization",
8990
Description: "Builtin default organization.",
9091
CreatedAt: dbtime.Now(),
9192
UpdatedAt: dbtime.Now(),
@@ -6179,11 +6180,13 @@ func (q *FakeQuerier) InsertOrganization(_ context.Context, arg database.InsertO
61796180
defer q.mutex.Unlock()
61806181

61816182
organization := database.Organization{
6182-
ID: arg.ID,
6183-
Name: arg.Name,
6184-
CreatedAt: arg.CreatedAt,
6185-
UpdatedAt: arg.UpdatedAt,
6186-
IsDefault: len(q.organizations) == 0,
6183+
ID: arg.ID,
6184+
Name: arg.Name,
6185+
DisplayName: arg.DisplayName,
6186+
Description: arg.Description,
6187+
CreatedAt: arg.CreatedAt,
6188+
UpdatedAt: arg.UpdatedAt,
6189+
IsDefault: len(q.organizations) == 0,
61876190
}
61886191
q.organizations = append(q.organizations, organization)
61896192
return organization, nil
@@ -7324,6 +7327,8 @@ func (q *FakeQuerier) UpdateOrganization(_ context.Context, arg database.UpdateO
73247327
for i, org := range q.organizations {
73257328
if org.ID == arg.ID {
73267329
org.Name = arg.Name
7330+
org.DisplayName = arg.DisplayName
7331+
org.Description = arg.Description
73277332
q.organizations[i] = org
73287333
return org, nil
73297334
}

coderd/database/dump.sql

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
alter table organizations
2+
drop column display_name;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- This default is just a temporary thing to avoid null errors when first creating the column.
2+
alter table organizations
3+
add column display_name text not null default '';
4+
5+
update organizations
6+
set display_name = name;
7+
8+
-- We can remove the default now that everything has been copied.
9+
alter table organizations
10+
alter column display_name drop default;

coderd/database/models.go

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

coderd/database/queries.sql.go

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

coderd/database/queries/organizations.sql

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,19 @@ WHERE
4949

5050
-- name: InsertOrganization :one
5151
INSERT INTO
52-
organizations (id, "name", description, created_at, updated_at, is_default)
52+
organizations (id, "name", display_name, description, created_at, updated_at, is_default)
5353
VALUES
5454
-- If no organizations exist, and this is the first, make it the default.
55-
($1, $2, $3, $4, $5, (SELECT TRUE FROM organizations LIMIT 1) IS NULL) RETURNING *;
55+
(@id, @name, @display_name, @description, @created_at, @updated_at, (SELECT TRUE FROM organizations LIMIT 1) IS NULL) RETURNING *;
5656

5757
-- name: UpdateOrganization :one
5858
UPDATE
5959
organizations
6060
SET
6161
updated_at = @updated_at,
62-
name = @name
62+
name = @name,
63+
display_name = @display_name,
64+
description = @description
6365
WHERE
6466
id = @id
6567
RETURNING *;

0 commit comments

Comments
 (0)