Skip to content

Commit 03e5971

Browse files
committed
chore: make owner_name and owner_username consistent
1 parent 6a2f22a commit 03e5971

37 files changed

+81
-61
lines changed

cli/testdata/coder_list_--output_json.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"created_at": "====[timestamp]=====",
55
"updated_at": "====[timestamp]=====",
66
"owner_id": "==========[first user ID]===========",
7-
"owner_name": "testuser",
7+
"owner_username": "testuser",
88
"owner_avatar_url": "",
99
"organization_id": "===========[first org ID]===========",
1010
"organization_name": "coder",

coderd/apidoc/docs.go

Lines changed: 3 additions & 0 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: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/workspaces.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,8 @@ func convertWorkspace(
22482248
CreatedAt: workspace.CreatedAt,
22492249
UpdatedAt: workspace.UpdatedAt,
22502250
OwnerID: workspace.OwnerID,
2251-
OwnerName: workspace.OwnerUsername,
2251+
OwnerName: workspace.OwnerName,
2252+
OwnerUsername: workspace.OwnerUsername,
22522253
OwnerAvatarURL: workspace.OwnerAvatarUrl,
22532254
OrganizationID: workspace.OrganizationID,
22542255
OrganizationName: workspace.OrganizationName,

coderd/workspaces_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,12 +1379,12 @@ func TestWorkspaceByOwnerAndName(t *testing.T) {
13791379

13801380
// Then:
13811381
// When we call without includes_deleted, we don't expect to get the workspace back
1382-
_, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{})
1382+
_, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{})
13831383
require.ErrorContains(t, err, "404")
13841384

13851385
// Then:
13861386
// When we call with includes_deleted, we should get the workspace back
1387-
workspaceNew, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{IncludeDeleted: true})
1387+
workspaceNew, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{IncludeDeleted: true})
13881388
require.NoError(t, err)
13891389
require.Equal(t, workspace.ID, workspaceNew.ID)
13901390

@@ -1402,7 +1402,7 @@ func TestWorkspaceByOwnerAndName(t *testing.T) {
14021402

14031403
// Then:
14041404
// We can fetch the most recent workspace
1405-
workspaceNew, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{})
1405+
workspaceNew, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{})
14061406
require.NoError(t, err)
14071407
require.Equal(t, workspace.ID, workspaceNew.ID)
14081408

@@ -1416,7 +1416,7 @@ func TestWorkspaceByOwnerAndName(t *testing.T) {
14161416

14171417
// Then:
14181418
// When we fetch the deleted workspace, we get the most recently deleted one
1419-
workspaceNew, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{IncludeDeleted: true})
1419+
workspaceNew, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{IncludeDeleted: true})
14201420
require.NoError(t, err)
14211421
require.Equal(t, workspace.ID, workspaceNew.ID)
14221422
})
@@ -1901,7 +1901,7 @@ func TestWorkspaceFilterManual(t *testing.T) {
19011901
require.NoError(t, err)
19021902
require.Len(t, res.Workspaces, len(workspaces))
19031903
for _, found := range res.Workspaces {
1904-
require.Equal(t, found.OwnerName, sdkUser.Username)
1904+
require.Equal(t, found.OwnerUsername, sdkUser.Username)
19051905
}
19061906
})
19071907
t.Run("IDs", func(t *testing.T) {
@@ -2033,7 +2033,7 @@ func TestWorkspaceFilterManual(t *testing.T) {
20332033

20342034
// single workspace
20352035
res, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{
2036-
FilterQuery: fmt.Sprintf("template:%s %s/%s", template.Name, workspace.OwnerName, workspace.Name),
2036+
FilterQuery: fmt.Sprintf("template:%s %s/%s", template.Name, workspace.OwnerUsername, workspace.Name),
20372037
})
20382038
require.NoError(t, err)
20392039
require.Len(t, res.Workspaces, 1)

codersdk/workspaces.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ type Workspace struct {
3030
CreatedAt time.Time `json:"created_at" format:"date-time"`
3131
UpdatedAt time.Time `json:"updated_at" format:"date-time"`
3232
OwnerID uuid.UUID `json:"owner_id" format:"uuid"`
33-
OwnerName string `json:"owner_name"`
33+
OwnerName string `json:"owner_name,omitempty"`
34+
OwnerUsername string `json:"owner_username"`
3435
OwnerAvatarURL string `json:"owner_avatar_url"`
3536
OrganizationID uuid.UUID `json:"organization_id" format:"uuid"`
3637
OrganizationName string `json:"organization_name"`

docs/reference/api/schemas.md

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

docs/reference/api/workspaces.md

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

site/src/api/queries/workspaces.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export const activate = (workspace: Workspace, queryClient: QueryClient) => {
267267
},
268268
onSuccess: (updatedWorkspace: Workspace) => {
269269
queryClient.setQueryData(
270-
workspaceByOwnerAndNameKey(workspace.owner_name, workspace.name),
270+
workspaceByOwnerAndNameKey(workspace.owner_username, workspace.name),
271271
updatedWorkspace,
272272
);
273273
},
@@ -316,12 +316,12 @@ export const toggleFavorite = (
316316
},
317317
onSuccess: async () => {
318318
queryClient.setQueryData(
319-
workspaceByOwnerAndNameKey(workspace.owner_name, workspace.name),
319+
workspaceByOwnerAndNameKey(workspace.owner_username, workspace.name),
320320
{ ...workspace, favorite: !workspace.favorite },
321321
);
322322
await queryClient.invalidateQueries({
323323
queryKey: workspaceByOwnerAndNameKey(
324-
workspace.owner_name,
324+
workspace.owner_username,
325325
workspace.name,
326326
),
327327
});

site/src/api/typesGenerated.ts

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

site/src/modules/apps/apps.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ describe("getAppHref", () => {
8181
path: "/path-base",
8282
});
8383
expect(href).toBe(
84-
`/path-base/@${MockWorkspace.owner_name}/Test-Workspace.a-workspace-agent/apps/${app.slug}/`,
84+
`/path-base/@${MockWorkspace.owner_username}/Test-Workspace.a-workspace-agent/apps/${app.slug}/`,
8585
);
8686
});
8787

@@ -97,7 +97,7 @@ describe("getAppHref", () => {
9797
path: "",
9898
});
9999
expect(href).toBe(
100-
`/@${MockWorkspace.owner_name}/Test-Workspace.a-workspace-agent/terminal?command=ls%20-la`,
100+
`/@${MockWorkspace.owner_username}/Test-Workspace.a-workspace-agent/terminal?command=ls%20-la`,
101101
);
102102
});
103103

@@ -129,7 +129,7 @@ describe("getAppHref", () => {
129129
path: "/path-base",
130130
});
131131
expect(href).toBe(
132-
`/path-base/@${MockWorkspace.owner_name}/Test-Workspace.a-workspace-agent/apps/${app.slug}/`,
132+
`/path-base/@${MockWorkspace.owner_username}/Test-Workspace.a-workspace-agent/apps/${app.slug}/`,
133133
);
134134
});
135135
});

site/src/modules/apps/apps.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export const getAppHref = (
105105
// Terminal links are relative. The terminal page knows how
106106
// to select the correct workspace proxy for the websocket
107107
// connection.
108-
return `/@${workspace.owner_name}/${workspace.name}.${
108+
return `/@${workspace.owner_username}/${workspace.name}.${
109109
agent.name
110110
}/terminal?command=${encodeURIComponent(app.command)}`;
111111
}
@@ -119,7 +119,7 @@ export const getAppHref = (
119119

120120
// The backend redirects if the trailing slash isn't included, so we add it
121121
// here to avoid extra roundtrips.
122-
return `${path}/@${workspace.owner_name}/${workspace.name}.${
122+
return `${path}/@${workspace.owner_username}/${workspace.name}.${
123123
agent.name
124124
}/apps/${encodeURIComponent(app.slug)}/`;
125125
};

site/src/modules/resources/AgentDevcontainerCard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export const AgentDevcontainerCard: FC<AgentDevcontainerCardProps> = ({
142142

143143
<div className="flex gap-4 flex-wrap mt-4">
144144
<VSCodeDevContainerButton
145-
userName={workspace.owner_name}
145+
userName={workspace.owner_username}
146146
workspaceName={workspace.name}
147147
devContainerName={container.name}
148148
devContainerFolder={containerFolder}
@@ -154,7 +154,7 @@ export const AgentDevcontainerCard: FC<AgentDevcontainerCardProps> = ({
154154
workspaceName={workspace.name}
155155
agentName={agent.name}
156156
containerName={container.name}
157-
userName={workspace.owner_name}
157+
userName={workspace.owner_username}
158158
/>
159159
{wildcardHostname !== "" &&
160160
container.ports.map((port) => {
@@ -170,7 +170,7 @@ export const AgentDevcontainerCard: FC<AgentDevcontainerCardProps> = ({
170170
port.host_port,
171171
agent.name,
172172
workspace.name,
173-
workspace.owner_name,
173+
workspace.owner_username,
174174
location.protocol === "https" ? "https" : "http",
175175
)
176176
: "";

site/src/modules/resources/AgentRow.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export const AgentRow: FC<AgentRowProps> = ({
216216
host={proxy.preferredWildcardHostname}
217217
workspaceName={workspace.name}
218218
agent={agent}
219-
username={workspace.owner_name}
219+
username={workspace.owner_username}
220220
workspaceID={workspace.id}
221221
template={template}
222222
/>
@@ -239,7 +239,7 @@ export const AgentRow: FC<AgentRowProps> = ({
239239
<>
240240
{showVSCode && (
241241
<VSCodeDesktopButton
242-
userName={workspace.owner_name}
242+
userName={workspace.owner_username}
243243
workspaceName={workspace.name}
244244
agentName={agent.name}
245245
folderPath={agent.expanded_directory}
@@ -261,7 +261,7 @@ export const AgentRow: FC<AgentRowProps> = ({
261261
<TerminalLink
262262
workspaceName={workspace.name}
263263
agentName={agent.name}
264-
userName={workspace.owner_name}
264+
userName={workspace.owner_username}
265265
/>
266266
)}
267267
</section>

site/src/modules/resources/VSCodeDesktopButton/VSCodeDesktopButton.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type Story = StoryObj<typeof VSCodeDesktopButton>;
1212

1313
export const Default: Story = {
1414
args: {
15-
userName: MockWorkspace.owner_name,
15+
userName: MockWorkspace.owner_username,
1616
workspaceName: MockWorkspace.name,
1717
agentName: MockWorkspaceAgent.name,
1818
displayApps: [

site/src/modules/resources/VSCodeDevContainerButton/VSCodeDevContainerButton.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type Story = StoryObj<typeof VSCodeDevContainerButton>;
1212

1313
export const Default: Story = {
1414
args: {
15-
userName: MockWorkspace.owner_name,
15+
userName: MockWorkspace.owner_username,
1616
workspaceName: MockWorkspace.name,
1717
agentName: MockWorkspaceAgent.name,
1818
devContainerName: "musing_ride",
@@ -29,7 +29,7 @@ export const Default: Story = {
2929

3030
export const VSCodeOnly: Story = {
3131
args: {
32-
userName: MockWorkspace.owner_name,
32+
userName: MockWorkspace.owner_username,
3333
workspaceName: MockWorkspace.name,
3434
agentName: MockWorkspaceAgent.name,
3535
devContainerName: "nifty_borg",
@@ -45,7 +45,7 @@ export const VSCodeOnly: Story = {
4545

4646
export const InsidersOnly: Story = {
4747
args: {
48-
userName: MockWorkspace.owner_name,
48+
userName: MockWorkspace.owner_username,
4949
workspaceName: MockWorkspace.name,
5050
agentName: MockWorkspaceAgent.name,
5151
devContainerName: "amazing_swartz",

site/src/modules/workspaces/WorkspaceMoreActions/WorkspaceMoreActions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const WorkspaceMoreActions: FC<WorkspaceMoreActionsProps> = ({
9090
<DropdownMenuContent id="workspace-options" align="end">
9191
<DropdownMenuItem asChild>
9292
<RouterLink
93-
to={`/@${workspace.owner_name}/${workspace.name}/settings`}
93+
to={`/@${workspace.owner_username}/${workspace.name}/settings`}
9494
>
9595
<SettingsIcon />
9696
Settings

site/src/pages/ChatPage/ChatToolInvocation.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const CreateWorkspace: Story = {
3838
name: MockWorkspace.name,
3939
rich_parameters: {},
4040
template_version_id: MockWorkspace.template_active_version_id,
41-
user: MockWorkspace.owner_name,
41+
user: MockWorkspace.owner_username,
4242
},
4343
MockWorkspace,
4444
),

site/src/pages/CreateWorkspacePage/CreateWorkspacePage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const CreateWorkspacePage: FC = () => {
102102

103103
const onCreateWorkspace = useCallback(
104104
(workspace: Workspace) => {
105-
navigate(`/@${workspace.owner_name}/${workspace.name}`);
105+
navigate(`/@${workspace.owner_username}/${workspace.name}`);
106106
},
107107
[navigate],
108108
);

site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ const CreateWorkspacePageExperimental: FC = () => {
195195

196196
const onCreateWorkspace = useCallback(
197197
(workspace: Workspace) => {
198-
navigate(`/@${workspace.owner_name}/${workspace.name}`);
198+
navigate(`/@${workspace.owner_username}/${workspace.name}`);
199199
},
200200
[navigate],
201201
);

site/src/pages/TasksPage/TasksPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ const TasksTable: FC<TasksTableProps> = ({ templates }) => {
330330
</TableCell>
331331
<TableCell>
332332
<AvatarData
333-
title={workspace.owner_name}
333+
title={workspace.owner_username}
334334
subtitle={
335335
<span className="block first-letter:uppercase">
336336
{relativeTime(new Date(workspace.created_at))}

0 commit comments

Comments
 (0)