Skip to content

Commit 8e51888

Browse files
committed
site: add buttons to workspace schedule to edit deadline
1 parent 7df5827 commit 8e51888

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

site/src/components/Workspace/Workspace.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ export interface WorkspaceProps {
1919
isLoading?: boolean
2020
onExtend: () => void
2121
}
22+
scheduleProps: {
23+
onDeadlinePlus: () => void
24+
onDeadlineMinus: () => void
25+
}
2226
handleStart: () => void
2327
handleStop: () => void
2428
handleDelete: () => void
@@ -36,6 +40,7 @@ export interface WorkspaceProps {
3640
*/
3741
export const Workspace: FC<WorkspaceProps> = ({
3842
bannerProps,
43+
scheduleProps,
3944
handleStart,
4045
handleStop,
4146
handleDelete,
@@ -99,7 +104,11 @@ export const Workspace: FC<WorkspaceProps> = ({
99104
</Stack>
100105

101106
<Stack direction="column" className={styles.secondColumnSpacer} spacing={3}>
102-
<WorkspaceSchedule workspace={workspace} />
107+
<WorkspaceSchedule
108+
workspace={workspace}
109+
onDeadlineMinus={scheduleProps.onDeadlineMinus}
110+
onDeadlinePlus={scheduleProps.onDeadlinePlus}
111+
/>
103112
</Stack>
104113
</Stack>
105114
</Margins>

site/src/components/WorkspaceSchedule/WorkspaceSchedule.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Button from "@material-ui/core/Button"
12
import Link from "@material-ui/core/Link"
23
import { makeStyles } from "@material-ui/core/styles"
34
import Typography from "@material-ui/core/Typography"
@@ -66,6 +67,8 @@ export const Language = {
6667
}
6768
},
6869
editScheduleLink: "Edit schedule",
70+
editDeadlineMinus: "[-1 hour]",
71+
editDeadlinePlus: "[+1 hour]",
6972
scheduleHeader: (workspace: Workspace): string => {
7073
const tz = workspace.autostart_schedule
7174
? extractTimezone(workspace.autostart_schedule)
@@ -76,6 +79,16 @@ export const Language = {
7679

7780
export interface WorkspaceScheduleProps {
7881
workspace: Workspace
82+
onDeadlinePlus: () => void
83+
onDeadlineMinus: () => void
84+
}
85+
86+
export const shouldDisplayPlusMins = (workspace: Workspace): boolean => {
87+
if (!isWorkspaceOn(workspace)) {
88+
return false
89+
}
90+
const deadline = dayjs(workspace.latest_build.deadline).utc()
91+
return deadline.year() > 1
7992
}
8093

8194
export const WorkspaceSchedule: FC<WorkspaceScheduleProps> = ({ workspace }) => {
@@ -100,6 +113,16 @@ export const WorkspaceSchedule: FC<WorkspaceScheduleProps> = ({ workspace }) =>
100113
{Language.autoStopDisplay(workspace)}
101114
</span>
102115
</div>
116+
<div>
117+
<Stack direction="row">
118+
<Button className={styles.editDeadline}>
119+
<span className={styles.scheduleLabel}>{Language.editDeadlineMinus}</span>
120+
</Button>
121+
<Button className={styles.editDeadline}>
122+
<span className={styles.scheduleLabel}>{Language.editDeadlinePlus}</span>
123+
</Button>
124+
</Stack>
125+
</div>
103126
<div>
104127
<Link
105128
className={styles.scheduleAction}
@@ -146,4 +169,12 @@ const useStyles = makeStyles((theme) => ({
146169
scheduleAction: {
147170
cursor: "pointer",
148171
},
172+
editDeadline: {
173+
fontSize: 12,
174+
textTransform: "uppercase",
175+
display: "inline-block",
176+
fontWeight: 600,
177+
color: theme.palette.text.secondary,
178+
margin: theme.spacing(0),
179+
},
149180
}))

site/src/pages/WorkspacePage/WorkspacePage.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ export const WorkspacePage: React.FC = () => {
5959
bannerSend({ type: "EXTEND_DEADLINE_DEFAULT", workspaceId: workspace.id })
6060
},
6161
}}
62+
scheduleProps={{
63+
onDeadlineMinus: () => {
64+
console.log("not implemented")
65+
},
66+
onDeadlinePlus: () => {
67+
console.log("not implemented")
68+
},
69+
}}
6270
workspace={workspace}
6371
handleStart={() => workspaceSend("START")}
6472
handleStop={() => workspaceSend("STOP")}

0 commit comments

Comments
 (0)