Skip to content

feat: Add selected template link at the template select field #1918

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
55 changes: 29 additions & 26 deletions site/src/components/CreateUserForm/CreateUserForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as TypesGen from "../../api/typesGenerated"
import { getFormHelpers, nameValidator, onChangeTrimmed } from "../../util/formUtils"
import { FormFooter } from "../FormFooter/FormFooter"
import { FullPageForm } from "../FullPageForm/FullPageForm"
import { Stack } from "../Stack/Stack"

export const Language = {
emailLabel: "Email",
Expand Down Expand Up @@ -57,32 +58,34 @@ export const CreateUserForm: FC<CreateUserFormProps> = ({
return (
<FullPageForm title="Create user" onCancel={onCancel}>
<form onSubmit={form.handleSubmit}>
<TextField
{...getFieldHelpers("username")}
onChange={onChangeTrimmed(form)}
autoComplete="username"
autoFocus
fullWidth
label={Language.usernameLabel}
variant="outlined"
/>
<TextField
{...getFieldHelpers("email")}
onChange={onChangeTrimmed(form)}
autoComplete="email"
fullWidth
label={Language.emailLabel}
variant="outlined"
/>
<TextField
{...getFieldHelpers("password")}
autoComplete="current-password"
fullWidth
id="password"
label={Language.passwordLabel}
type="password"
variant="outlined"
/>
<Stack spacing={1}>
<TextField
{...getFieldHelpers("username")}
onChange={onChangeTrimmed(form)}
autoComplete="username"
autoFocus
fullWidth
label={Language.usernameLabel}
variant="outlined"
/>
<TextField
{...getFieldHelpers("email")}
onChange={onChangeTrimmed(form)}
autoComplete="email"
fullWidth
label={Language.emailLabel}
variant="outlined"
/>
<TextField
{...getFieldHelpers("password")}
autoComplete="current-password"
fullWidth
id="password"
label={Language.passwordLabel}
type="password"
variant="outlined"
/>
</Stack>
{error && <FormHelperText error>{error}</FormHelperText>}
<FormFooter onCancel={onCancel} isLoading={isLoading} />
</form>
Expand Down
7 changes: 4 additions & 3 deletions site/src/components/FormFooter/FormFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ export interface FormFooterProps {
submitLabel?: string
}

const useStyles = makeStyles(() => ({
const useStyles = makeStyles((theme) => ({
footer: {
display: "flex",
flex: "0",
flexDirection: "row",
justifyContent: "center",
gap: theme.spacing(1.5),
alignItems: "center",
marginTop: theme.spacing(3),
},
button: {
margin: "1em",
width: "100%",
},
}))

Expand Down
5 changes: 2 additions & 3 deletions site/src/components/FormTitle/FormTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ export interface FormTitleProps {

const useStyles = makeStyles((theme) => ({
title: {
textAlign: "center",
marginTop: theme.spacing(5),
marginBottom: theme.spacing(5),
marginTop: theme.spacing(6),
marginBottom: theme.spacing(4),

"& h3": {
marginBottom: theme.spacing(1),
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/FullPageForm/FullPageForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const FullPageForm: FC<FullPageFormProps> = ({ title, detail, onCancel, c
const styles = useStyles()
return (
<main className={styles.root}>
<Margins>
<Margins size="small">
<FormTitle title={title} detail={detail} />
<FormCloseButton onClose={onCancel} />

Expand Down
22 changes: 17 additions & 5 deletions site/src/components/Margins/Margins.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import { makeStyles } from "@material-ui/core/styles"
import { FC } from "react"
import { maxWidth, sidePadding } from "../../theme/constants"
import { containerWidth, sidePadding } from "../../theme/constants"

type Size = "regular" | "medium" | "small"

const widthBySize: Record<Size, number> = {
regular: containerWidth,
medium: containerWidth / 2,
small: containerWidth / 3,
}

const useStyles = makeStyles(() => ({
margins: {
margin: "0 auto",
maxWidth,
padding: `0 ${sidePadding}`,
maxWidth: ({ maxWidth }: { maxWidth: number }) => maxWidth,
padding: `0 ${sidePadding}px`,
flex: 1,
width: "100%",
},
}))

export const Margins: FC = ({ children }) => {
const styles = useStyles()
interface MarginsProps {
size?: Size
}

export const Margins: FC<MarginsProps> = ({ children, size = "regular" }) => {
const styles = useStyles({ maxWidth: widthBySize[size] })
return <div className={styles.margins}>{children}</div>
}
19 changes: 8 additions & 11 deletions site/src/components/ParameterInput/ParameterInput.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import FormControlLabel from "@material-ui/core/FormControlLabel"
import Paper from "@material-ui/core/Paper"
import Radio from "@material-ui/core/Radio"
import RadioGroup from "@material-ui/core/RadioGroup"
import { lighten, makeStyles } from "@material-ui/core/styles"
import { makeStyles } from "@material-ui/core/styles"
import TextField from "@material-ui/core/TextField"
import { FC } from "react"
import { ParameterSchema } from "../../api/typesGenerated"
Expand All @@ -17,15 +16,15 @@ export interface ParameterInputProps {
export const ParameterInput: FC<ParameterInputProps> = ({ disabled, onChange, schema }) => {
const styles = useStyles()
return (
<Paper className={styles.paper}>
<div className={styles.root}>
<div className={styles.title}>
<h2>var.{schema.name}</h2>
{schema.description && <span>{schema.description}</span>}
</div>
<div className={styles.input}>
<ParameterField disabled={disabled} onChange={onChange} schema={schema} />
</div>
</Paper>
</div>
)
}

Expand Down Expand Up @@ -67,28 +66,26 @@ const ParameterField: React.FC<ParameterInputProps> = ({ disabled, onChange, sch
}

const useStyles = makeStyles((theme) => ({
paper: {
root: {
display: "flex",
flexDirection: "column",
fontFamily: MONOSPACE_FONT_FAMILY,
paddingTop: theme.spacing(2),
paddingBottom: theme.spacing(2),
},
title: {
background: lighten(theme.palette.background.default, 0.1),
borderBottom: `1px solid ${theme.palette.divider}`,
padding: theme.spacing(3),
display: "flex",
flexDirection: "column",
"& h2": {
margin: 0,
},
"& span": {
paddingTop: theme.spacing(2),
paddingTop: theme.spacing(1),
},
},
input: {
padding: theme.spacing(3),
marginTop: theme.spacing(2),
display: "flex",
flexDirection: "column",
maxWidth: 480,
},
}))
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({

return (
<FullPageForm onCancel={onCancel} title="Workspace Schedule">
<form className={styles.form} onSubmit={form.handleSubmit}>
<Stack className={styles.stack}>
<form onSubmit={form.handleSubmit} className={styles.form}>
<Stack>
<TextField
{...formHelpers("startTime", Language.startTimeHelperText)}
disabled={form.isSubmitting || isLoading}
Expand All @@ -177,7 +177,6 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
}}
label={Language.startTimeLabel}
type="time"
variant="standard"
/>

<TextField
Expand All @@ -195,7 +194,6 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
shrink: true,
}}
label={Language.timezoneLabel}
variant="standard"
/>

<FormControl component="fieldset" error={Boolean(form.errors.monday)}>
Expand All @@ -212,6 +210,9 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
disabled={!form.values.startTime || form.isSubmitting || isLoading}
onChange={form.handleChange}
name={checkbox.name}
color="primary"
size="small"
disableRipple
/>
}
key={checkbox.name}
Expand All @@ -229,7 +230,6 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({
inputProps={{ min: 0, step: 1 }}
label={Language.ttlLabel}
type="number"
variant="standard"
/>

<FormFooter onCancel={onCancel} isLoading={form.isSubmitting || isLoading} />
Expand All @@ -241,21 +241,10 @@ export const WorkspaceScheduleForm: FC<WorkspaceScheduleFormProps> = ({

const useStyles = makeStyles({
form: {
display: "flex",
justifyContent: "center",

"& input": {
colorScheme: "dark",
},
},
stack: {
// REMARK: 360 is 'arbitrary' in that it gives the helper text enough room
// to render on one line. If we change the text, we might want to
// adjust these. Without constraining the width, the date picker
// and number inputs aren't visually appealing or maximally usable.
maxWidth: 360,
minWidth: 360,
},
daysOfWeekLabel: {
fontSize: 12,
},
Expand Down
Loading