Skip to content

feat(site): add support for presets to the create workspace page #16567

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
Feb 18, 2025

Conversation

SasSwart
Copy link
Contributor

@SasSwart SasSwart commented Feb 14, 2025

This pull request adds support for presets to the create workspace page. This behaviour can be seen in the storybook. This will not be visible in dogfood until we merge support for presets in the provisioners.

There is more frontend work to be done before this is ready for a general release, but this should be sufficient for dogfood testing

@SasSwart SasSwart marked this pull request as ready for review February 14, 2025 08:43
@SasSwart SasSwart changed the title feat(site): add support for presets to the coder frontend feat(site): add support for presets to the create workspace page Feb 14, 2025
Copy link
Collaborator

@BrunoQuaresma BrunoQuaresma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just left a few comments.

value: preset.ID,
})),
];
}, [presets]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only use useMemo when really necessary. In this case, it would be ok to compute this on every render.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. I will remove the useMemo. For my own learning: Can you help me understand why not to use useMemo in this case?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s just a matter of adding complexity—caching—in a place where it’s not really needed.

presets,
parameters,
form.setFieldValue,
]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this effect is to set in the form the default values right? If yes, I think the best place to set them is in the form initialValues prop here

.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This effect is not only for default values, but also for if the user chooses a new preset. If they choose a new preset then this effect will autofill the form for them using the new preset values.

@@ -189,6 +245,31 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
</Alert>
)}

{presets.length > 0 && (
<FormSection
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A form section should be used to group similar fields. I'm usually don't like to have sections with a single field 🤔 but I will leave this up to you. I was wondering if this could not be in the General section.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. There is another issue open to consider the UX and design of this entire page. I have made this change as requested, but I would like to request that we defer further design discussions for the mockups.

@dannykopping dannykopping removed their request for review February 18, 2025 08:00
@dannykopping
Copy link
Contributor

Removed myself as a reviewer; this is not my area of expertise. All I'd be able to contribute is vibes or a stamp, neither of which are valuable.

Copy link
Collaborator

@BrunoQuaresma BrunoQuaresma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SasSwart Just check the Chromatic checks pls 🙏

@SasSwart SasSwart merged commit a17cf03 into main Feb 18, 2025
30 checks passed
@SasSwart SasSwart deleted the jjs/presets-fe branch February 18, 2025 13:26
@github-actions github-actions bot locked and limited conversation to collaborators Feb 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants