Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
defaultSchedule,
emptySchedule,
} from "pages/WorkspaceSchedulePage/schedule"
import { defaultTTL } from "pages/WorkspaceSchedulePage/ttl"
import { ChangeEvent, FC } from "react"
import * as Yup from "yup"
import { getFormHelpers } from "../../util/formUtils"
Expand Down Expand Up @@ -81,6 +80,7 @@ export interface WorkspaceScheduleFormProps {
onSubmit: (values: WorkspaceScheduleFormValues) => void
// for storybook
initialTouched?: FormikTouched<WorkspaceScheduleFormValues>
defaultTTL: number
}

export interface WorkspaceScheduleFormValues {
Expand Down Expand Up @@ -192,6 +192,7 @@ export const WorkspaceScheduleForm: FC<
onCancel,
onSubmit,
initialTouched,
defaultTTL,
}) => {
const styles = useStyles()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useMachine } from "@xstate/react"
import { AlertBanner } from "components/AlertBanner/AlertBanner"
import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog"
import { Margins } from "components/Margins/Margins"
import dayjs from "dayjs"
import { scheduleToAutoStart } from "pages/WorkspaceSchedulePage/schedule"
import { ttlMsToAutoStop } from "pages/WorkspaceSchedulePage/ttl"
import React, { useEffect } from "react"
Expand Down Expand Up @@ -46,6 +47,7 @@ export const WorkspaceSchedulePage: React.FC = () => {
getTemplateError,
permissions,
workspace,
template,
} = scheduleState.context

// Get workspace on mount and whenever the args for getting a workspace change.
Expand All @@ -60,7 +62,7 @@ export const WorkspaceSchedulePage: React.FC = () => {
return <Navigate to="/workspaces" />
}

if (scheduleState.hasTag("loading")) {
if (scheduleState.hasTag("loading") || !template) {
return <FullScreenLoader />
}

Expand Down Expand Up @@ -104,6 +106,7 @@ export const WorkspaceSchedulePage: React.FC = () => {
...getAutoStop(workspace),
}}
isLoading={scheduleState.tags.has("loading")}
defaultTTL={dayjs.duration(template.default_ttl_ms, "ms").asHours()}
onCancel={() => {
navigate(`/@${username}/${workspaceName}`)
}}
Expand Down
2 changes: 0 additions & 2 deletions site/src/pages/WorkspaceSchedulePage/ttl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ export interface AutoStop {

export const emptyTTL = 0

export const defaultTTL = 12

const msToHours = (ms: number) => Math.round(ms / (1000 * 60 * 60))

export const ttlMsToAutoStop = (ttl_ms?: number): AutoStop =>
Expand Down