@@ -7,9 +7,11 @@ import { Alert } from "components/Alert/Alert";
7
7
import { ErrorAlert } from "components/Alert/ErrorAlert" ;
8
8
import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog" ;
9
9
import { displayError , displaySuccess } from "components/GlobalSnackbar/utils" ;
10
+ import { Link } from "components/Link/Link" ;
10
11
import { Loader } from "components/Loader/Loader" ;
11
12
import { PageHeader , PageHeaderTitle } from "components/PageHeader/PageHeader" ;
12
13
import dayjs from "dayjs" ;
14
+ import { isPrebuildWorkspace } from "modules/workspaces/prebuilds" ;
13
15
import {
14
16
scheduleChanged ,
15
17
scheduleToAutostart ,
@@ -20,6 +22,7 @@ import { type FC, useState } from "react";
20
22
import { Helmet } from "react-helmet-async" ;
21
23
import { useMutation , useQuery , useQueryClient } from "react-query" ;
22
24
import { useNavigate , useParams } from "react-router-dom" ;
25
+ import { docs } from "utils/docs" ;
23
26
import { pageTitle } from "utils/page" ;
24
27
import { WorkspaceScheduleForm } from "./WorkspaceScheduleForm" ;
25
28
import {
@@ -94,42 +97,65 @@ const WorkspaceSchedulePage: FC = () => {
94
97
</ Alert >
95
98
) }
96
99
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
+ ( isPrebuildWorkspace ( 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
+ ) ) }
133
159
134
160
< ConfirmDialog
135
161
open = { isConfirmingApply }
0 commit comments