@@ -7,9 +7,11 @@ import { Alert } from "components/Alert/Alert";
77import { ErrorAlert } from "components/Alert/ErrorAlert" ;
88import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog" ;
99import { displayError , displaySuccess } from "components/GlobalSnackbar/utils" ;
10+ import { Link } from "components/Link/Link" ;
1011import { Loader } from "components/Loader/Loader" ;
1112import { PageHeader , PageHeaderTitle } from "components/PageHeader/PageHeader" ;
1213import dayjs from "dayjs" ;
14+ import { isPrebuiltWorkspace } from "modules/workspaces/prebuilds" ;
1315import {
1416 scheduleChanged ,
1517 scheduleToAutostart ,
@@ -20,6 +22,7 @@ import { type FC, useState } from "react";
2022import { Helmet } from "react-helmet-async" ;
2123import { useMutation , useQuery , useQueryClient } from "react-query" ;
2224import { useNavigate , useParams } from "react-router-dom" ;
25+ import { docs } from "utils/docs" ;
2326import { pageTitle } from "utils/page" ;
2427import { WorkspaceScheduleForm } from "./WorkspaceScheduleForm" ;
2528import {
@@ -94,42 +97,65 @@ const WorkspaceSchedulePage: FC = () => {
9497 </ Alert >
9598 ) }
9699
97- { template && (
98- < WorkspaceScheduleForm
99- template = { template }
100- error = { submitScheduleMutation . error }
101- initialValues = { {
102- ...getAutostart ( workspace ) ,
103- ...getAutostop ( workspace ) ,
104- } }
105- isLoading = { submitScheduleMutation . isPending }
106- defaultTTL = { dayjs . duration ( template . default_ttl_ms , "ms" ) . asHours ( ) }
107- onCancel = { ( ) => {
108- navigate ( `/@${ username } /${ workspaceName } ` ) ;
109- } }
110- onSubmit = { async ( values ) => {
111- const data = {
112- workspace,
113- autostart : formValuesToAutostartRequest ( values ) ,
114- ttl : formValuesToTTLRequest ( values ) ,
115- autostartChanged : scheduleChanged (
116- getAutostart ( workspace ) ,
117- values ,
118- ) ,
119- autostopChanged : scheduleChanged ( getAutostop ( workspace ) , values ) ,
120- } ;
121-
122- await submitScheduleMutation . mutateAsync ( data ) ;
123-
124- if (
125- data . autostopChanged &&
126- getAutostop ( workspace ) . autostopEnabled
127- ) {
128- setIsConfirmingApply ( true ) ;
129- }
130- } }
131- />
132- ) }
100+ { template &&
101+ // Prebuilt workspaces have their own scheduling system,
102+ // so we avoid showing the workspace-level schedule settings form.
103+ // Instead, show an informational message with a link to the relevant docs.
104+ ( isPrebuiltWorkspace ( workspace ) ? (
105+ < Alert severity = "info" >
106+ Prebuilt workspaces do not support workspace-level scheduling. For
107+ prebuilt workspace specific scheduling refer to the{ " " }
108+ < Link
109+ title = "Prebuilt Workspaces Scheduling"
110+ href = { docs (
111+ "/admin/templates/extending-templates/prebuilt-workspaces#scheduling" ,
112+ ) }
113+ target = "_blank"
114+ rel = "noreferrer"
115+ >
116+ Prebuilt Workspaces Scheduling
117+ </ Link >
118+ documentation page.
119+ </ Alert >
120+ ) : (
121+ < WorkspaceScheduleForm
122+ template = { template }
123+ error = { submitScheduleMutation . error }
124+ initialValues = { {
125+ ...getAutostart ( workspace ) ,
126+ ...getAutostop ( workspace ) ,
127+ } }
128+ isLoading = { submitScheduleMutation . isPending }
129+ defaultTTL = { dayjs . duration ( template . default_ttl_ms , "ms" ) . asHours ( ) }
130+ onCancel = { ( ) => {
131+ navigate ( `/@${ username } /${ workspaceName } ` ) ;
132+ } }
133+ onSubmit = { async ( values ) => {
134+ const data = {
135+ workspace,
136+ autostart : formValuesToAutostartRequest ( values ) ,
137+ ttl : formValuesToTTLRequest ( values ) ,
138+ autostartChanged : scheduleChanged (
139+ getAutostart ( workspace ) ,
140+ values ,
141+ ) ,
142+ autostopChanged : scheduleChanged (
143+ getAutostop ( workspace ) ,
144+ values ,
145+ ) ,
146+ } ;
147+
148+ await submitScheduleMutation . mutateAsync ( data ) ;
149+
150+ if (
151+ data . autostopChanged &&
152+ getAutostop ( workspace ) . autostopEnabled
153+ ) {
154+ setIsConfirmingApply ( true ) ;
155+ }
156+ } }
157+ />
158+ ) ) }
133159
134160 < ConfirmDialog
135161 open = { isConfirmingApply }
0 commit comments