Skip to content

Commit 225dde8

Browse files
committed
u
1 parent 0811bab commit 225dde8

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

site/src/pages/WorkspacePage/WorkspaceScheduleControls.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ interface AutoStopDisplayProps {
138138
}
139139

140140
const AutoStopDisplay: FC<AutoStopDisplayProps> = ({ workspace, template }) => {
141-
const display = autostopDisplay(workspace);
141+
const display = autostopDisplay(workspace, template);
142142

143143
console.log(template.autostop_requirement);
144144

site/src/utils/schedule.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import utc from "dayjs/plugin/utc";
88
import { type ReactNode } from "react";
99
import type { Template, Workspace } from "api/typesGenerated";
1010
import { isWorkspaceOn } from "./workspace";
11+
import { templateVersionExternalAuthKey } from "api/queries/templates";
1112

1213
// REMARK: some plugins depend on utc, so it's listed first. Otherwise they're
1314
// sorted alphabetically.
@@ -91,38 +92,39 @@ export const isShuttingDown = (
9192

9293
export const autostopDisplay = (
9394
workspace: Workspace,
95+
template: Template,
9496
): {
9597
message: ReactNode;
9698
tooltip?: string;
9799
} => {
98100
const ttl = workspace.ttl_ms;
99101

100-
// workspace.latest_build.resources.map((resource) => resource.agents?.map((agent) => agent.
101-
102-
if (isWorkspaceOn(workspace) && true) {
103-
return {
104-
message: "Connected with SSH",
105-
tooltip: "Workspace will not stop while there is an active connection",
106-
};
107-
}
108-
109102
if (isWorkspaceOn(workspace) && workspace.latest_build.deadline) {
110103
// Workspace is on --> derive from latest_build.deadline. Note that the
111104
// user may modify their workspace object (ttl) while the workspace is
112105
// running and depending on system semantics, the deadline may still
113106
// represent the previously defined ttl. Thus, we always derive from the
114107
// deadline as the source of truth.
115108

109+
workspace.
110+
116111
const deadline = dayjs(workspace.latest_build.deadline).utc();
117112
if (isShuttingDown(workspace, deadline)) {
118113
return {
119114
message: Language.workspaceShuttingDownLabel,
120115
};
121116
} else {
122117
const deadlineTz = deadline.tz(dayjs.tz.guess());
118+
let reason = "";
119+
if (template.autostop_requirement) {
120+
121+
}
122+
const reason = template.allow_user_autostop;
123123
return {
124124
message: `Stop ${deadlineTz.fromNow()}`,
125-
tooltip: deadlineTz.format("MMMM D, YYYY h:mm A"),
125+
tooltip: `This workspace will be stopped on ${deadlineTz.format(
126+
"MMMM D, YYYY [at] h:mm A",
127+
)}`,
126128
};
127129
}
128130
} else if (!ttl || ttl < 1) {

0 commit comments

Comments
 (0)