Skip to content

Commit acfb5dd

Browse files
committed
Add template card
1 parent 042910d commit acfb5dd

File tree

1 file changed

+65
-24
lines changed

1 file changed

+65
-24
lines changed

site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx

Lines changed: 65 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,28 @@ export const CreateWorkspacePageView: FC<
179179
spacing={1}
180180
className={styles.formSectionFields}
181181
>
182-
<TextField
183-
disabled
184-
fullWidth
185-
label={t("templateLabel")}
186-
value={props.selectedTemplate?.name || props.templateName}
187-
variant="outlined"
188-
/>
182+
{props.selectedTemplate && (
183+
<Stack
184+
direction="row"
185+
spacing={2}
186+
className={styles.template}
187+
alignItems="center"
188+
>
189+
<div className={styles.templateIcon}>
190+
<img src={props.selectedTemplate.icon} alt="" />
191+
</div>
192+
<Stack direction="column" spacing={0.5}>
193+
<span className={styles.templateName}>
194+
{props.selectedTemplate.name}
195+
</span>
196+
{props.selectedTemplate.description && (
197+
<span className={styles.templateDescription}>
198+
{props.selectedTemplate.description}
199+
</span>
200+
)}
201+
</Stack>
202+
</Stack>
203+
)}
189204

190205
<TextField
191206
{...getFieldHelpers("name")}
@@ -238,22 +253,22 @@ export const CreateWorkspacePageView: FC<
238253
)}
239254

240255
{/* Template params */}
241-
<div className={styles.formSection}>
242-
<div className={styles.formSectionInfo}>
243-
<h2 className={styles.formSectionInfoTitle}>Template params</h2>
244-
<p className={styles.formSectionInfoDescription}>
245-
Those values are provided by your template&lsquo;s Terraform
246-
configuration.
247-
</p>
248-
</div>
256+
{props.templateSchema && props.templateSchema.length > 0 && (
257+
<div className={styles.formSection}>
258+
<div className={styles.formSectionInfo}>
259+
<h2 className={styles.formSectionInfoTitle}>Template params</h2>
260+
<p className={styles.formSectionInfoDescription}>
261+
Those values are provided by your template&lsquo;s Terraform
262+
configuration.
263+
</p>
264+
</div>
249265

250-
<Stack
251-
direction="column"
252-
spacing={3} // Spacing here is diff because the fields here don't have the MUI floating label spacing
253-
className={styles.formSectionFields}
254-
>
255-
{props.templateSchema &&
256-
props.templateSchema.map((schema) => (
266+
<Stack
267+
direction="column"
268+
spacing={3} // Spacing here is diff because the fields here don't have the MUI floating label spacing
269+
className={styles.formSectionFields}
270+
>
271+
{props.templateSchema.map((schema) => (
257272
<ParameterInput
258273
disabled={form.isSubmitting}
259274
key={schema.id}
@@ -266,8 +281,9 @@ export const CreateWorkspacePageView: FC<
266281
schema={schema}
267282
/>
268283
))}
269-
</Stack>
270-
</div>
284+
</Stack>
285+
</div>
286+
)}
271287

272288
<FormFooter
273289
styles={formFooterStyles}
@@ -312,6 +328,31 @@ const useStyles = makeStyles((theme) => ({
312328
formSectionFields: {
313329
width: "100%",
314330
},
331+
332+
template: {
333+
padding: theme.spacing(2.5, 3),
334+
borderRadius: theme.shape.borderRadius,
335+
backgroundColor: theme.palette.background.paper,
336+
border: `1px solid ${theme.palette.divider}`,
337+
},
338+
339+
templateName: {
340+
fontSize: 16,
341+
},
342+
343+
templateDescription: {
344+
fontSize: 14,
345+
color: theme.palette.text.secondary,
346+
},
347+
348+
templateIcon: {
349+
width: theme.spacing(5),
350+
lineHeight: 1,
351+
352+
"& img": {
353+
width: "100%",
354+
},
355+
},
315356
}))
316357

317358
const useFormFooterStyles = makeStyles((theme) => ({

0 commit comments

Comments
 (0)