Skip to content
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 it on the backend instead
  • Loading branch information
aslilac committed Apr 10, 2024
commit 66cc750df389fbc69d236475e1a700de3eecad90
5 changes: 5 additions & 0 deletions coderd/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,11 @@ func convertWorkspace(
}

ttlMillis := convertWorkspaceTTLMillis(workspace.Ttl)
// If the template doesn't allow a workspace-configured value, then report the
// template value instead.
if !template.AllowUserAutostop {
ttlMillis = convertWorkspaceTTLMillis(sql.NullInt64{Valid: true, Int64: template.DefaultTTL})
}

// Only show favorite status if you own the workspace.
requesterFavorite := workspace.OwnerID == requesterID && workspace.Favorite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const WorkspaceSchedulePage: FC = () => {
error={submitScheduleMutation.error}
initialValues={{
...getAutostart(workspace),
...getAutostop(workspace, template),
...getAutostop(workspace),
}}
isLoading={submitScheduleMutation.isLoading}
defaultTTL={dayjs.duration(template.default_ttl_ms, "ms").asHours()}
Expand All @@ -117,10 +117,7 @@ export const WorkspaceSchedulePage: FC = () => {
getAutostart(workspace),
values,
),
autostopChanged: scheduleChanged(
getAutostop(workspace, template),
values,
),
autostopChanged: scheduleChanged(getAutostop(workspace), values),
};

await submitScheduleMutation.mutateAsync(data);
Expand Down Expand Up @@ -154,13 +151,8 @@ export const WorkspaceSchedulePage: FC = () => {
const getAutostart = (workspace: TypesGen.Workspace) =>
scheduleToAutostart(workspace.autostart_schedule);

const getAutostop = (
workspace: TypesGen.Workspace,
template: TypesGen.Template,
) =>
template.allow_user_autostop
? ttlMsToAutostop(workspace.ttl_ms)
: ttlMsToAutostop(template.default_ttl_ms);
const getAutostop = (workspace: TypesGen.Workspace) =>
ttlMsToAutostop(workspace.ttl_ms);

type SubmitScheduleData = {
workspace: TypesGen.Workspace;
Expand Down