feat: Add form to modify managed Template variables#6257
Conversation
|
This Pull Request is becoming stale. In order to minimize WIP, prevent merge conflicts and keep the tracker readable, I'm going close to this PR in 3 days if there isn't more activity. |
|
What are the diff between this form and the settings form? |
I guess that this are the most important parts. |
|
Why create a diff form for the variables and not use them in the settings one? |
|
I'm not sure if I understand your question. Could you please elaborate a bit more? I created the new form/page as there were many changes between both, and variables are submitted using a different endpoint than Template Settings. Variables are strictly Terraform vars. |
| } = templateState.context | ||
| const permissions = usePermissions() | ||
|
|
||
| if (!template || !templatePermissions) { |
There was a problem hiding this comment.
I think those only should be loaded in the page form. You can also use react-query for them. Way easier IMO. But not a blocker.
| } | ||
| const organizationId = useOrganizationId() | ||
| const navigate = useNavigate() | ||
| const [state, send] = useMachine(templateVariablesMachine, { |
There was a problem hiding this comment.
I said that previously but maybe would be interesting to use react-query but no big deal.
There was a problem hiding this comment.
I think that I will leave it for further improvement as I'd like to deliver this PR as is, as it just works. I will try to frame more time for react-query to play with it.
BrunoQuaresma
left a comment
There was a problem hiding this comment.
There are a few things in the FE we could improve but not blockers.
About react-query, you can see how we are using it here
coder/site/src/pages/WorkspacesPage/WorkspacesPage.tsx
Lines 13 to 16 in 6304bfb
Related: #5980
As this PR is growing, I will keep introducing follow-ups in separate PRs.
This PR introduces a form to modify the Terraform variables. Once a user submits the form, the browser will check the status of the provisioning job every 2 secs, and if the job succeeds, it will redirect to the template view.
Button:

Sample form:

Template:
Follow-ups: