Skip to content

Commit 28228f1

Browse files
authored
feat: allow editing org icon (#13547)
1 parent 58bf0ec commit 28228f1

19 files changed

+116
-22
lines changed

clock/mock.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package clock
22

33
import (
44
"context"
5-
"errors"
65
"fmt"
76
"slices"
87
"sync"
98
"testing"
109
"time"
10+
11+
"golang.org/x/xerrors"
1112
)
1213

1314
// Mock is the testing implementation of Clock. It tracks a time that monotonically increases
@@ -571,7 +572,7 @@ func (t *Trap) Close() {
571572
close(t.done)
572573
}
573574

574-
var ErrTrapClosed = errors.New("trap closed")
575+
var ErrTrapClosed = xerrors.New("trap closed")
575576

576577
func (t *Trap) Wait(ctx context.Context) (*Call, error) {
577578
select {

coderd/apidoc/docs.go

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dbgen/dbgen.go

+1
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ func Organization(t testing.TB, db database.Store, orig database.Organization) d
338338
Name: takeFirst(orig.Name, namesgenerator.GetRandomName(1)),
339339
DisplayName: takeFirst(orig.Name, namesgenerator.GetRandomName(1)),
340340
Description: takeFirst(orig.Description, namesgenerator.GetRandomName(1)),
341+
Icon: takeFirst(orig.Icon, ""),
341342
CreatedAt: takeFirst(orig.CreatedAt, dbtime.Now()),
342343
UpdatedAt: takeFirst(orig.UpdatedAt, dbtime.Now()),
343344
})

coderd/database/dbmem/dbmem.go

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func New() database.Store {
8888
Name: "first-organization",
8989
DisplayName: "first-organization",
9090
Description: "Builtin default organization.",
91+
Icon: "",
9192
CreatedAt: dbtime.Now(),
9293
UpdatedAt: dbtime.Now(),
9394
})
@@ -6189,6 +6190,7 @@ func (q *FakeQuerier) InsertOrganization(_ context.Context, arg database.InsertO
61896190
Name: arg.Name,
61906191
DisplayName: arg.DisplayName,
61916192
Description: arg.Description,
6193+
Icon: arg.Icon,
61926194
CreatedAt: arg.CreatedAt,
61936195
UpdatedAt: arg.UpdatedAt,
61946196
IsDefault: len(q.organizations) == 0,
@@ -7334,6 +7336,7 @@ func (q *FakeQuerier) UpdateOrganization(_ context.Context, arg database.UpdateO
73347336
org.Name = arg.Name
73357337
org.DisplayName = arg.DisplayName
73367338
org.Description = arg.Description
7339+
org.Icon = arg.Icon
73377340
q.organizations[i] = org
73387341
return org, nil
73397342
}

coderd/database/dump.sql

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
alter table organizations
2+
drop column icon;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
alter table organizations
2+
add column icon text not null default '';

coderd/database/models.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

+22-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/organizations.sql

+4-3
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ WHERE
4949

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

5757
-- name: UpdateOrganization :one
5858
UPDATE
@@ -61,7 +61,8 @@ SET
6161
updated_at = @updated_at,
6262
name = @name,
6363
display_name = @display_name,
64-
description = @description
64+
description = @description,
65+
icon = @icon
6566
WHERE
6667
id = @id
6768
RETURNING *;

coderd/organizations.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func (api *API) postOrganizations(rw http.ResponseWriter, r *http.Request) {
8383
Name: req.Name,
8484
DisplayName: req.DisplayName,
8585
Description: req.Description,
86+
Icon: req.Icon,
8687
CreatedAt: dbtime.Now(),
8788
UpdatedAt: dbtime.Now(),
8889
})
@@ -164,6 +165,7 @@ func (api *API) patchOrganization(rw http.ResponseWriter, r *http.Request) {
164165
Name: organization.Name,
165166
DisplayName: organization.DisplayName,
166167
Description: organization.Description,
168+
Icon: organization.Icon,
167169
}
168170

169171
if req.Name != "" {
@@ -172,8 +174,11 @@ func (api *API) patchOrganization(rw http.ResponseWriter, r *http.Request) {
172174
if req.DisplayName != "" {
173175
updateOrgParams.DisplayName = req.DisplayName
174176
}
175-
if req.Description != "" {
176-
updateOrgParams.Description = req.Description
177+
if req.Description != nil {
178+
updateOrgParams.Description = *req.Description
179+
}
180+
if req.Icon != nil {
181+
updateOrgParams.Icon = *req.Icon
177182
}
178183

179184
organization, err = tx.UpdateOrganization(ctx, updateOrgParams)
@@ -248,6 +253,7 @@ func convertOrganization(organization database.Organization) codersdk.Organizati
248253
Name: organization.Name,
249254
DisplayName: organization.DisplayName,
250255
Description: organization.Description,
256+
Icon: organization.Icon,
251257
CreatedAt: organization.CreatedAt,
252258
UpdatedAt: organization.UpdatedAt,
253259
IsDefault: organization.IsDefault,

0 commit comments

Comments
 (0)