Skip to content

Commit d7c9df7

Browse files
committed
Start sketching out new design
1 parent d165d76 commit d7c9df7

File tree

3 files changed

+58
-22
lines changed

3 files changed

+58
-22
lines changed

site/src/components/WorkspaceScheduleButton/WorkspaceScheduleButton.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Tooltip from "@material-ui/core/Tooltip"
66
import AddIcon from "@material-ui/icons/Add"
77
import RemoveIcon from "@material-ui/icons/Remove"
88
import ScheduleIcon from "@material-ui/icons/Schedule"
9+
import { Maybe } from "components/Conditionals/Maybe"
910
import dayjs from "dayjs"
1011
import advancedFormat from "dayjs/plugin/advancedFormat"
1112
import duration from "dayjs/plugin/duration"
@@ -70,10 +71,10 @@ export const WorkspaceScheduleButton: React.FC<WorkspaceScheduleButtonProps> = (
7071

7172
return (
7273
<span className={styles.wrapper}>
73-
{shouldDisplayScheduleLabel(workspace) && (
74+
<Maybe condition={shouldDisplayScheduleLabel(workspace)}>
7475
<span className={styles.label}>
7576
<WorkspaceScheduleLabel workspace={workspace} />
76-
{canUpdateWorkspace && shouldDisplayPlusMinus(workspace) && (
77+
<Maybe condition={canUpdateWorkspace && shouldDisplayPlusMinus(workspace)}>
7778
<span className={styles.actions}>
7879
<IconButton
7980
className={styles.iconButton}
@@ -96,9 +97,9 @@ export const WorkspaceScheduleButton: React.FC<WorkspaceScheduleButtonProps> = (
9697
</Tooltip>
9798
</IconButton>
9899
</span>
99-
)}
100+
</Maybe>
100101
</span>
101-
)}
102+
</Maybe>
102103
<>
103104
<Button
104105
ref={anchorRef}

site/src/components/WorkspaceScheduleButton/WorkspaceScheduleLabel.tsx

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,61 @@
11
import { makeStyles } from "@material-ui/core/styles"
2+
import TextField from "@material-ui/core/TextField"
3+
import { ChooseOne, Cond } from "components/Conditionals/ChooseOne"
4+
import { Maybe } from "components/Conditionals/Maybe"
5+
import { LoadingButton } from "components/LoadingButton/LoadingButton"
6+
import { useTranslation } from "react-i18next"
27
import { Workspace } from "../../api/typesGenerated"
38
import { combineClasses } from "../../util/combineClasses"
4-
import { autoStartDisplay, autoStopDisplay, isShuttingDown, Language } from "../../util/schedule"
9+
import { autoStartDisplay, autoStopDisplay, isShuttingDown } from "../../util/schedule"
510
import { isWorkspaceOn } from "../../util/workspace"
611

12+
const AutoStopDisplay = ({ workspace }: { workspace: Workspace }): JSX.Element => {
13+
const { t } = useTranslation("common")
14+
const autoStopTime = autoStopDisplay(workspace)
15+
return (
16+
<ChooseOne>
17+
<Cond condition={isEditing}>
18+
<>
19+
<TextField
20+
value={autoStopTime}
21+
onChange={}
22+
/>
23+
<LoadingButton disabled={}>
24+
{t("schedule.submitUpdate")}
25+
</LoadingButton>
26+
</>
27+
</Cond>
28+
<Cond>
29+
{autoStopTime}
30+
</Cond>
31+
</ChooseOne>
32+
)
33+
}
34+
735
export const WorkspaceScheduleLabel: React.FC<{ workspace: Workspace }> = ({ workspace }) => {
836
const styles = useStyles()
37+
const { t } = useTranslation("common")
938

10-
if (isWorkspaceOn(workspace)) {
11-
const stopLabel = autoStopDisplay(workspace)
12-
const shouldDisplayStrongLabel = !isShuttingDown(workspace)
13-
14-
// If it is shutting down, we don't need to display the auto stop label
15-
return (
39+
return <ChooseOne>
40+
<Cond condition={isWorkspaceOn(workspace)}>
1641
<span className={combineClasses([styles.labelText, "chromatic-ignore"])}>
17-
{shouldDisplayStrongLabel && <strong>{Language.autoStopLabel}</strong>}{" "}
18-
<span className={styles.value}>{stopLabel}</span>
42+
<Maybe condition={!isShuttingDown(workspace)}>
43+
<strong>{t("schedule.autoStopLabel")}</strong>
44+
</Maybe>
45+
{" "}
46+
<span className={styles.value}>
47+
<AutoStopDisplay workspace={workspace} />
48+
</span>
1949
</span>
20-
)
21-
}
22-
23-
return (
24-
<span className={combineClasses([styles.labelText, "chromatic-ignore"])}>
25-
<strong>{Language.autoStartLabel}</strong>{" "}
26-
<span className={styles.value}>{autoStartDisplay(workspace.autostart_schedule)}</span>
27-
</span>
28-
)
50+
</Cond>
51+
<Cond>
52+
<span className={combineClasses([styles.labelText, "chromatic-ignore"])}>
53+
<strong>{t("schedule.autoStartLabel")}</strong>
54+
{" "}
55+
<span className={styles.value}>{autoStartDisplay(workspace.autostart_schedule)}</span>
56+
</span>
57+
</Cond>
58+
</ChooseOne>
2959
}
3060

3161
const useStyles = makeStyles((theme) => ({

site/src/i18n/en/common.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,10 @@
1818
"confirm": "Are you sure you want to proceed? Type the name of this {{entity}} below to confirm.",
1919
"confirmLabel": "Name of {{entity}} to delete",
2020
"incorrectName": "Incorrect {{entity}} name."
21+
},
22+
"schedule": {
23+
"autoStartLabel": "Starts at",
24+
"autoStopLabel": "Stops at",
25+
"submitUpdate": "Update"
2126
}
2227
}

0 commit comments

Comments
 (0)