Skip to content

feat(site): Ask for missing template variables in the template editor #7108

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 8 commits into from
Apr 17, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix default variable values
  • Loading branch information
BrunoQuaresma committed Apr 14, 2023
commit fdf0896126e9640db039c872e3897ccf4fd33d3f
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import DialogContent from "@material-ui/core/DialogContent"
import DialogContentText from "@material-ui/core/DialogContentText"
import DialogTitle from "@material-ui/core/DialogTitle"
import { DialogProps } from "components/Dialogs/Dialog"
import { FC, useState } from "react"
import { FC, useEffect, useState } from "react"
import { FormFields, VerticalForm } from "components/Form/Form"
import { TemplateVersionVariable, VariableValue } from "api/typesGenerated"
import DialogActions from "@material-ui/core/DialogActions"
Expand All @@ -27,6 +27,16 @@ export const MissingTemplateVariablesDialog: FC<
const styles = useStyles()
const [variableValues, setVariableValues] = useState<VariableValue[]>([])

// Pre-fill the form with the default values when missing variables are loaded
useEffect(() => {
if (!missingVariables) {
return
}
setVariableValues(
missingVariables.map((v) => ({ name: v.name, value: v.value })),
)
}, [missingVariables])

return (
<Dialog
{...dialogProps}
Expand Down