- Notifications
You must be signed in to change notification settings - Fork1k
fix(site): exclude workspace schedule settings for prebuilt workspaces#18826
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
95ca5f7
207c80f
450b3e1
0bde254
73f5476
f306854
d5e45bb
0120c5b
ad475cf
02c0ff5
1260e49
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
importtype{Workspace}from"api/typesGenerated"; | ||
// Returns true if the workspace is a prebuilt workspace (owned by the prebuilds system user), | ||
// otherwise returns false. | ||
exportconstisPrebuiltWorkspace=(workspace:Workspace):boolean=>{ | ||
returnworkspace.owner_id==="c42fdf75-3097-471c-8c33-fb52454d81c0"; | ||
ssncferreira marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
}; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I'd suggest adding a story here to showcase the new behaviour. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Good catch! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Addressed in73f5476 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -7,9 +7,11 @@ import { Alert } from "components/Alert/Alert"; | ||
import { ErrorAlert } from "components/Alert/ErrorAlert"; | ||
import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog"; | ||
import { displayError, displaySuccess } from "components/GlobalSnackbar/utils"; | ||
import { Link } from "components/Link/Link"; | ||
import { Loader } from "components/Loader/Loader"; | ||
import { PageHeader, PageHeaderTitle } from "components/PageHeader/PageHeader"; | ||
import dayjs from "dayjs"; | ||
import { isPrebuiltWorkspace } from "modules/workspaces/prebuilds"; | ||
import { | ||
scheduleChanged, | ||
scheduleToAutostart, | ||
@@ -20,6 +22,7 @@ import { type FC, useState } from "react"; | ||
import { Helmet } from "react-helmet-async"; | ||
import { useMutation, useQuery, useQueryClient } from "react-query"; | ||
import { useNavigate, useParams } from "react-router-dom"; | ||
import { docs } from "utils/docs"; | ||
import { pageTitle } from "utils/page"; | ||
import { WorkspaceScheduleForm } from "./WorkspaceScheduleForm"; | ||
import { | ||
@@ -94,42 +97,65 @@ const WorkspaceSchedulePage: FC = () => { | ||
</Alert> | ||
)} | ||
{template && | ||
// Prebuilt workspaces have their own scheduling system, | ||
// so we avoid showing the workspace-level schedule settings form. | ||
// Instead, show an informational message with a link to the relevant docs. | ||
ssncferreira marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
(isPrebuiltWorkspace(workspace) ? ( | ||
<Alert severity="info"> | ||
Prebuilt workspaces do not support workspace-level scheduling. For | ||
prebuilt workspace specific scheduling refer to the{" "} | ||
ssncferreira marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
<Link | ||
title="Prebuilt Workspaces Scheduling" | ||
href={docs( | ||
"/admin/templates/extending-templates/prebuilt-workspaces#scheduling", | ||
)} | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
Prebuilt Workspaces Scheduling | ||
</Link> | ||
documentation page. | ||
</Alert> | ||
) : ( | ||
<WorkspaceScheduleForm | ||
template={template} | ||
error={submitScheduleMutation.error} | ||
initialValues={{ | ||
...getAutostart(workspace), | ||
...getAutostop(workspace), | ||
}} | ||
isLoading={submitScheduleMutation.isPending} | ||
defaultTTL={dayjs.duration(template.default_ttl_ms, "ms").asHours()} | ||
onCancel={() => { | ||
navigate(`/@${username}/${workspaceName}`); | ||
}} | ||
onSubmit={async (values) => { | ||
const data = { | ||
workspace, | ||
autostart: formValuesToAutostartRequest(values), | ||
ttl: formValuesToTTLRequest(values), | ||
autostartChanged: scheduleChanged( | ||
getAutostart(workspace), | ||
values, | ||
), | ||
autostopChanged: scheduleChanged( | ||
getAutostop(workspace), | ||
values, | ||
), | ||
}; | ||
await submitScheduleMutation.mutateAsync(data); | ||
if ( | ||
data.autostopChanged && | ||
getAutostop(workspace).autostopEnabled | ||
) { | ||
setIsConfirmingApply(true); | ||
} | ||
}} | ||
/> | ||
))} | ||
<ConfirmDialog | ||
open={isConfirmingApply} | ||
Uh oh!
There was an error while loading.Please reload this page.