Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ae47dda

Browse files
committed
fix: Remove "Starts at Manual" label
Fixes #2798.
1 parent f160830 commit ae47dda

File tree

2 files changed

+55
-27
lines changed

2 files changed

+55
-27
lines changed

site/src/components/WorkspaceScheduleButton/WorkspaceScheduleButton.stories.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ WorkspaceOffLong.args = {
7272
},
7373
}
7474

75+
export const WorkspaceOn = Template.bind({})
76+
WorkspaceOn.args = {
77+
deadlineMinusEnabled: () => true,
78+
deadlinePlusEnabled: () => true,
79+
workspace: {
80+
...Mocks.MockWorkspace,
81+
82+
latest_build: {
83+
...Mocks.MockWorkspaceBuild,
84+
transition: "start",
85+
deadline: "2022-05-17T23:59:00.00Z",
86+
},
87+
ttl_ms: 2 * 365 * 24 * 60 * 60 * 1000, // 2 years
88+
},
89+
}
90+
7591
export const CannotEdit = Template.bind({})
7692
CannotEdit.args = {
7793
workspace: {

site/src/components/WorkspaceScheduleButton/WorkspaceScheduleButton.tsx

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ export const shouldDisplayPlusMinus = (workspace: Workspace): boolean => {
3131
return isWorkspaceOn(workspace) && Boolean(workspace.latest_build.deadline)
3232
}
3333

34+
export const shouldDisplayScheduleLabel = (workspace: Workspace): boolean => {
35+
if (shouldDisplayPlusMinus(workspace)) {
36+
return true
37+
}
38+
if (isWorkspaceOn(workspace)) {
39+
return false
40+
}
41+
return Boolean(workspace.autostart_schedule)
42+
}
43+
3444
export interface WorkspaceScheduleButtonProps {
3545
workspace: Workspace
3646
onDeadlinePlus: () => void
@@ -60,33 +70,35 @@ export const WorkspaceScheduleButton: React.FC<WorkspaceScheduleButtonProps> = (
6070

6171
return (
6272
<span className={styles.wrapper}>
63-
<span className={styles.label}>
64-
<WorkspaceScheduleLabel workspace={workspace} />
65-
{canUpdateWorkspace && shouldDisplayPlusMinus(workspace) && (
66-
<span className={styles.actions}>
67-
<IconButton
68-
className={styles.iconButton}
69-
size="small"
70-
disabled={!deadlineMinusEnabled()}
71-
onClick={onDeadlineMinus}
72-
>
73-
<Tooltip title={t("workspaceScheduleButton.editDeadlineMinus")}>
74-
<RemoveIcon />
75-
</Tooltip>
76-
</IconButton>
77-
<IconButton
78-
className={styles.iconButton}
79-
size="small"
80-
disabled={!deadlinePlusEnabled()}
81-
onClick={onDeadlinePlus}
82-
>
83-
<Tooltip title={t("workspaceScheduleButton.editDeadlinePlus")}>
84-
<AddIcon />
85-
</Tooltip>
86-
</IconButton>
87-
</span>
88-
)}
89-
</span>
73+
{shouldDisplayScheduleLabel(workspace) && (
74+
<span className={styles.label}>
75+
<WorkspaceScheduleLabel workspace={workspace} />
76+
{canUpdateWorkspace && shouldDisplayPlusMinus(workspace) && (
77+
<span className={styles.actions}>
78+
<IconButton
79+
className={styles.iconButton}
80+
size="small"
81+
disabled={!deadlineMinusEnabled()}
82+
onClick={onDeadlineMinus}
83+
>
84+
<Tooltip title={t("workspaceScheduleButton.editDeadlineMinus")}>
85+
<RemoveIcon />
86+
</Tooltip>
87+
</IconButton>
88+
<IconButton
89+
className={styles.iconButton}
90+
size="small"
91+
disabled={!deadlinePlusEnabled()}
92+
onClick={onDeadlinePlus}
93+
>
94+
<Tooltip title={t("workspaceScheduleButton.editDeadlinePlus")}>
95+
<AddIcon />
96+
</Tooltip>
97+
</IconButton>
98+
</span>
99+
)}
100+
</span>
101+
)}
90102
<>
91103
<Button
92104
ref={anchorRef}

0 commit comments

Comments
 (0)