mirror of
https://github.com/coder/coder.git
synced 2025-07-18 14:17:22 +00:00
fix(site): Do not show template params if there is no param to be displayed (#7263)
This commit is contained in:
@ -135,6 +135,10 @@ export const CreateWorkspacePageView: FC<
|
|||||||
})
|
})
|
||||||
|
|
||||||
const isLoading = props.loadingTemplateSchema || props.loadingTemplates
|
const isLoading = props.loadingTemplateSchema || props.loadingTemplates
|
||||||
|
// We only want to show schema that have redisplay_value equals true
|
||||||
|
const schemaToBeDisplayed = props.templateSchema?.filter(
|
||||||
|
(schema) => schema.redisplay_value,
|
||||||
|
)
|
||||||
|
|
||||||
const getFieldHelpers = getFormHelpers<TypesGen.CreateWorkspaceRequest>(
|
const getFieldHelpers = getFormHelpers<TypesGen.CreateWorkspaceRequest>(
|
||||||
form,
|
form,
|
||||||
@ -271,29 +275,26 @@ export const CreateWorkspacePageView: FC<
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Template params */}
|
{/* Template params */}
|
||||||
{props.templateSchema && props.templateSchema.length > 0 && (
|
{schemaToBeDisplayed && schemaToBeDisplayed.length > 0 && (
|
||||||
<FormSection
|
<FormSection
|
||||||
title="Template params"
|
title="Template params"
|
||||||
description="These values are provided by your template's Terraform configuration."
|
description="These values are provided by your template's Terraform configuration."
|
||||||
>
|
>
|
||||||
<FormFields>
|
<FormFields>
|
||||||
{props.templateSchema
|
{schemaToBeDisplayed.map((schema) => (
|
||||||
// We only want to show schema that have redisplay_value equals true
|
<ParameterInput
|
||||||
.filter((schema) => schema.redisplay_value)
|
disabled={form.isSubmitting}
|
||||||
.map((schema) => (
|
key={schema.id}
|
||||||
<ParameterInput
|
defaultValue={parameterValues[schema.name]}
|
||||||
disabled={form.isSubmitting}
|
onChange={(value) => {
|
||||||
key={schema.id}
|
setParameterValues({
|
||||||
defaultValue={parameterValues[schema.name]}
|
...parameterValues,
|
||||||
onChange={(value) => {
|
[schema.name]: value,
|
||||||
setParameterValues({
|
})
|
||||||
...parameterValues,
|
}}
|
||||||
[schema.name]: value,
|
schema={schema}
|
||||||
})
|
/>
|
||||||
}}
|
))}
|
||||||
schema={schema}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</FormFields>
|
</FormFields>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
)}
|
)}
|
||||||
|
Reference in New Issue
Block a user