Skip to content

Commit 207c80f

Browse files
committed
feat: add is_prebuild flag to workspace API response
1 parent 95ca5f7 commit 207c80f

File tree

11 files changed

+30
-15
lines changed

11 files changed

+30
-15
lines changed

cli/testdata/coder_list_--output_json.golden

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"automatic_updates": "never",
8787
"allow_renames": false,
8888
"favorite": false,
89-
"next_start_at": "====[timestamp]====="
89+
"next_start_at": "====[timestamp]=====",
90+
"is_prebuild": false
9091
}
9192
]

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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,6 +2231,12 @@ func convertWorkspace(
22312231
if latestAppStatus.ID == uuid.Nil {
22322232
appStatus = nil
22332233
}
2234+
2235+
isPrebuild := false
2236+
if workspace.OwnerID == database.PrebuildsSystemUserID {
2237+
isPrebuild = true
2238+
}
2239+
22342240
return codersdk.Workspace{
22352241
ID: workspace.ID,
22362242
CreatedAt: workspace.CreatedAt,
@@ -2265,6 +2271,7 @@ func convertWorkspace(
22652271
AllowRenames: allowRenames,
22662272
Favorite: requesterFavorite,
22672273
NextStartAt: nextStartAt,
2274+
IsPrebuild: isPrebuild,
22682275
}, nil
22692276
}
22702277

codersdk/workspaces.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ type Workspace struct {
6666
AllowRenames bool `json:"allow_renames"`
6767
Favorite bool `json:"favorite"`
6868
NextStartAt *time.Time `json:"next_start_at" format:"date-time"`
69+
IsPrebuild bool `json:"is_prebuild"`
6970
}
7071

7172
func (w Workspace) FullName() string {

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/typesGenerated.ts

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

site/src/modules/workspaces/prebuilds.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

site/src/pages/WorkspaceSettingsPage/WorkspaceSchedulePage/WorkspaceSchedulePage.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { Link } from "components/Link/Link";
1111
import { Loader } from "components/Loader/Loader";
1212
import { PageHeader, PageHeaderTitle } from "components/PageHeader/PageHeader";
1313
import dayjs from "dayjs";
14-
import { isPrebuiltWorkspace } from "modules/workspaces/prebuilds";
1514
import {
1615
scheduleChanged,
1716
scheduleToAutostart,
@@ -98,13 +97,10 @@ const WorkspaceSchedulePage: FC = () => {
9897
)}
9998

10099
{template &&
101-
// Prebuilt workspaces have their own scheduling system,
102-
// so we avoid showing the workspace-level schedule settings form.
103-
// Instead, show an informational message with a link to the relevant docs.
104-
(isPrebuiltWorkspace(workspace) ? (
100+
(workspace.is_prebuild ? (
105101
<Alert severity="info">
106-
Prebuilt workspaces do not support workspace-level scheduling. For
107-
prebuilt workspace specific scheduling refer to the{" "}
102+
Prebuilt workspaces ignore workspace-level scheduling until they are claimed.
103+
For prebuilt workspace specific scheduling refer to the{" "}
108104
<Link
109105
title="Prebuilt Workspaces Scheduling"
110106
href={docs(

0 commit comments

Comments
 (0)