Skip to content

Commit 1134e78

Browse files
fix(site): Do not show template params if there is no param to be displayed (#7263)
1 parent 9afad82 commit 1134e78

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ export const CreateWorkspacePageView: FC<
135135
})
136136

137137
const isLoading = props.loadingTemplateSchema || props.loadingTemplates
138+
// We only want to show schema that have redisplay_value equals true
139+
const schemaToBeDisplayed = props.templateSchema?.filter(
140+
(schema) => schema.redisplay_value,
141+
)
138142

139143
const getFieldHelpers = getFormHelpers<TypesGen.CreateWorkspaceRequest>(
140144
form,
@@ -271,29 +275,26 @@ export const CreateWorkspacePageView: FC<
271275
)}
272276

273277
{/* Template params */}
274-
{props.templateSchema && props.templateSchema.length > 0 && (
278+
{schemaToBeDisplayed && schemaToBeDisplayed.length > 0 && (
275279
<FormSection
276280
title="Template params"
277281
description="These values are provided by your template's Terraform configuration."
278282
>
279283
<FormFields>
280-
{props.templateSchema
281-
// We only want to show schema that have redisplay_value equals true
282-
.filter((schema) => schema.redisplay_value)
283-
.map((schema) => (
284-
<ParameterInput
285-
disabled={form.isSubmitting}
286-
key={schema.id}
287-
defaultValue={parameterValues[schema.name]}
288-
onChange={(value) => {
289-
setParameterValues({
290-
...parameterValues,
291-
[schema.name]: value,
292-
})
293-
}}
294-
schema={schema}
295-
/>
296-
))}
284+
{schemaToBeDisplayed.map((schema) => (
285+
<ParameterInput
286+
disabled={form.isSubmitting}
287+
key={schema.id}
288+
defaultValue={parameterValues[schema.name]}
289+
onChange={(value) => {
290+
setParameterValues({
291+
...parameterValues,
292+
[schema.name]: value,
293+
})
294+
}}
295+
schema={schema}
296+
/>
297+
))}
297298
</FormFields>
298299
</FormSection>
299300
)}

0 commit comments

Comments
 (0)