Skip to content

Commit f6e0a64

Browse files
committed
emotion: CreateTemplateForm
1 parent ffa39ef commit f6e0a64

File tree

1 file changed

+29
-30
lines changed

1 file changed

+29
-30
lines changed

site/src/pages/CreateTemplatePage/CreateTemplateForm.tsx

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1+
import { type Interpolation, type Theme } from "@emotion/react";
12
import Checkbox from "@mui/material/Checkbox";
2-
import { makeStyles } from "@mui/styles";
33
import TextField from "@mui/material/TextField";
4-
import {
4+
import type {
55
ProvisionerJobLog,
66
Template,
77
TemplateExample,
88
TemplateVersionVariable,
99
VariableValue,
1010
} from "api/typesGenerated";
1111
import { Stack } from "components/Stack/Stack";
12-
import { TemplateUpload, TemplateUploadProps } from "./TemplateUpload";
12+
import { TemplateUpload, type TemplateUploadProps } from "./TemplateUpload";
1313
import { useFormik } from "formik";
1414
import { SelectedTemplate } from "pages/CreateWorkspacePage/SelectedTemplate";
15-
import { FC, useEffect } from "react";
15+
import { type FC, useEffect } from "react";
1616
import {
1717
nameValidator,
1818
getFormHelpers,
@@ -43,8 +43,8 @@ import {
4343
} from "pages/TemplateSettingsPage/TemplateSchedulePage/AutostopRequirementHelperText";
4444
import MenuItem from "@mui/material/MenuItem";
4545
import {
46-
TemplateAutostartRequirementDaysValue,
47-
TemplateAutostopRequirementDaysValue,
46+
type TemplateAutostartRequirementDaysValue,
47+
type TemplateAutostopRequirementDaysValue,
4848
} from "utils/schedule";
4949
import {
5050
TemplateScheduleAutostart,
@@ -218,7 +218,6 @@ export const CreateTemplateForm: FC<CreateTemplateFormProps> = (props) => {
218218
allowDisableEveryoneAccess,
219219
allowAutostopRequirement,
220220
} = props;
221-
const styles = useStyles();
222221
const form = useFormik<CreateTemplateData>({
223222
initialValues: getInitialValues({
224223
allowAdvancedScheduling,
@@ -338,7 +337,7 @@ export const CreateTemplateForm: FC<CreateTemplateFormProps> = (props) => {
338337
description="Define when workspaces created from this template automatically stop."
339338
>
340339
<FormFields>
341-
<Stack direction="row" className={styles.ttlFields}>
340+
<Stack direction="row" css={styles.ttlFields}>
342341
<TextField
343342
{...getFieldHelpers(
344343
"default_ttl_hours",
@@ -373,7 +372,7 @@ export const CreateTemplateForm: FC<CreateTemplateFormProps> = (props) => {
373372
</Stack>
374373

375374
{allowAutostopRequirement && (
376-
<Stack direction="row" className={styles.ttlFields}>
375+
<Stack direction="row" css={styles.ttlFields}>
377376
<TextField
378377
{...getFieldHelpers(
379378
"autostop_requirement_days_of_week",
@@ -481,7 +480,7 @@ export const CreateTemplateForm: FC<CreateTemplateFormProps> = (props) => {
481480
<strong>
482481
Allow users to customize autostop duration for workspaces.
483482
</strong>
484-
<span className={styles.optionHelperText}>
483+
<span css={styles.optionHelperText}>
485484
Workspaces will always use the default TTL if this is set.
486485
Regardless of this setting, workspaces can only stay on for
487486
the max TTL.
@@ -514,7 +513,7 @@ export const CreateTemplateForm: FC<CreateTemplateFormProps> = (props) => {
514513
direction="row"
515514
alignItems="center"
516515
spacing={0.5}
517-
className={styles.optionText}
516+
css={styles.optionText}
518517
>
519518
<strong>
520519
Allow users to cancel in-progress workspace jobs
@@ -527,7 +526,7 @@ export const CreateTemplateForm: FC<CreateTemplateFormProps> = (props) => {
527526
</HelpTooltipText>
528527
</HelpTooltip>
529528
</Stack>
530-
<span className={styles.optionHelperText}>
529+
<span css={styles.optionHelperText}>
531530
Depending on your template, canceling builds may leave
532531
workspaces in an unhealthy state. This option isn&apos;t
533532
recommended for most use cases.
@@ -552,7 +551,7 @@ export const CreateTemplateForm: FC<CreateTemplateFormProps> = (props) => {
552551
direction="row"
553552
alignItems="center"
554553
spacing={0.5}
555-
className={styles.optionText}
554+
css={styles.optionText}
556555
>
557556
<strong>Allow everyone to use the template</strong>
558557

@@ -569,7 +568,7 @@ export const CreateTemplateForm: FC<CreateTemplateFormProps> = (props) => {
569568
</HelpTooltipText>
570569
</HelpTooltip>
571570
</Stack>
572-
<span className={styles.optionHelperText}>
571+
<span css={styles.optionHelperText}>
573572
This setting requires an enterprise license for the&nbsp;
574573
<Link href={docs("/admin/rbac")}>
575574
&apos;Template RBAC&apos;
@@ -610,14 +609,14 @@ export const CreateTemplateForm: FC<CreateTemplateFormProps> = (props) => {
610609

611610
{jobError && (
612611
<Stack>
613-
<div className={styles.error}>
614-
<h5 className={styles.errorTitle}>Error during provisioning</h5>
615-
<p className={styles.errorDescription}>
612+
<div css={styles.error}>
613+
<h5 css={styles.errorTitle}>Error during provisioning</h5>
614+
<p css={styles.errorDescription}>
616615
Looks like we found an error during the template provisioning. You
617616
can see the logs bellow.
618617
</p>
619618

620-
<code className={styles.errorDetails}>{jobError}</code>
619+
<code css={styles.errorDetails}>{jobError}</code>
621620
</div>
622621

623622
<WorkspaceBuildLogs logs={logs ?? []} />
@@ -690,43 +689,43 @@ const MaxTTLHelperText = (props: { ttl?: number }) => {
690689
);
691690
};
692691

693-
const useStyles = makeStyles((theme) => ({
692+
const styles = {
694693
ttlFields: {
695694
width: "100%",
696695
},
697696

698-
optionText: {
697+
optionText: (theme) => ({
699698
fontSize: theme.spacing(2),
700699
color: theme.palette.text.primary,
701-
},
700+
}),
702701

703-
optionHelperText: {
702+
optionHelperText: (theme) => ({
704703
fontSize: theme.spacing(1.5),
705704
color: theme.palette.text.secondary,
706-
},
705+
}),
707706

708-
error: {
707+
error: (theme) => ({
709708
padding: theme.spacing(3),
710709
borderRadius: theme.spacing(1),
711710
background: theme.palette.background.paper,
712711
border: `1px solid ${theme.palette.error.main}`,
713-
},
712+
}),
714713

715714
errorTitle: {
716715
fontSize: 16,
717716
margin: 0,
718717
},
719718

720-
errorDescription: {
719+
errorDescription: (theme) => ({
721720
margin: 0,
722721
color: theme.palette.text.secondary,
723722
marginTop: theme.spacing(0.5),
724-
},
723+
}),
725724

726-
errorDetails: {
725+
errorDetails: (theme) => ({
727726
display: "block",
728727
marginTop: theme.spacing(1),
729728
color: theme.palette.error.light,
730729
fontSize: theme.spacing(2),
731-
},
732-
}));
730+
}),
731+
} satisfies Record<string, Interpolation<Theme>>;

0 commit comments

Comments
 (0)