Skip to content

refactor(site): Refactor the schedule controls in the workspace page #7083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 11, 2023
Prev Previous commit
Next Next commit
Fix controls
  • Loading branch information
BrunoQuaresma committed Apr 11, 2023
commit 4f44c08191a6d8ef417b7ff2c93b4db33ce360a0
1 change: 1 addition & 0 deletions site/src/components/Workspace/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
handleUpdate={handleUpdate}
maxDeadlineDecrease={scheduleProps.maxDeadlineDecrease}
maxDeadlineIncrease={scheduleProps.maxDeadlineIncrease}
canUpdateWorkspace={canUpdateWorkspace}
/>

{failedBuildLogs && (
Expand Down
44 changes: 24 additions & 20 deletions site/src/components/WorkspaceStats/WorkspaceStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface WorkspaceStatsProps {
workspace: Workspace
maxDeadlineIncrease: number
maxDeadlineDecrease: number
canUpdateWorkspace: boolean
quota_budget?: number
handleUpdate: () => void
}
Expand All @@ -46,6 +47,7 @@ export const WorkspaceStats: FC<WorkspaceStatsProps> = ({
maxDeadlineDecrease,
maxDeadlineIncrease,
handleUpdate,
canUpdateWorkspace,
}) => {
const initiatedBy = getDisplayWorkspaceBuildInitiatedBy(
workspace.latest_build,
Expand Down Expand Up @@ -114,26 +116,28 @@ export const WorkspaceStats: FC<WorkspaceStatsProps> = ({
? autostopDisplay(workspace)
: autostartDisplay(workspace.autostart_schedule)}
</Link>
<span className={styles.scheduleControls}>
<IconButton
disabled={!deadlineMinusEnabled}
size="small"
title="Subtract hours from deadline"
className={styles.scheduleButton}
>
<RemoveIcon />
</IconButton>
<IconButton
disabled={!deadlinePlusEnabled}
size="small"
title="Add hours to deadline"
className={styles.scheduleButton}
ref={addingButtonRef}
onClick={() => setIsAddingTime(true)}
>
<AddIcon />
</IconButton>
</span>
{canUpdateWorkspace && canEditDeadline(workspace) && (
<span className={styles.scheduleControls}>
<IconButton
disabled={!deadlineMinusEnabled}
size="small"
title="Subtract hours from deadline"
className={styles.scheduleButton}
>
<RemoveIcon />
</IconButton>
<IconButton
disabled={!deadlinePlusEnabled}
size="small"
title="Add hours to deadline"
className={styles.scheduleButton}
ref={addingButtonRef}
onClick={() => setIsAddingTime(true)}
>
<AddIcon />
</IconButton>
</span>
)}
</span>
}
/>
Expand Down