Skip to content

feat: add the ability to hide preset parameters #17168

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 9 commits into from
Apr 1, 2025
Prev Previous commit
Next Next commit
make lint
  • Loading branch information
SasSwart committed Mar 31, 2025
commit 464e2e705cf54efe8c9679d7f662d7a42a288424
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ export const WithPreset: Story = {
id: "project_name",
parameter: createTemplateVersionParameter({
name: "project_name",
description: "Customize the name of a Google Cloud project that will be created!",
description:
"Customize the name of a Google Cloud project that will be created!",
}),
isPreset: true,
},
Expand All @@ -393,7 +394,8 @@ export const WithPresetAndImmutable: Story = {
id: "project_name",
parameter: createTemplateVersionParameter({
name: "project_name",
description: "Customize the name of a Google Cloud project that will be created!",
description:
"Customize the name of a Google Cloud project that will be created!",
mutable: false,
}),
isPreset: true,
Expand All @@ -406,7 +408,8 @@ export const WithPresetAndOptional: Story = {
id: "project_name",
parameter: createTemplateVersionParameter({
name: "project_name",
description: "Customize the name of a Google Cloud project that will be created!",
description:
"Customize the name of a Google Cloud project that will be created!",
required: false,
}),
isPreset: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Interpolation, Theme } from "@emotion/react";
import ErrorOutline from "@mui/icons-material/ErrorOutline";
import SettingsIcon from "@mui/icons-material/Settings";
import Button from "@mui/material/Button";
import FormControlLabel from "@mui/material/FormControlLabel";
import FormHelperText from "@mui/material/FormHelperText";
Expand All @@ -19,7 +20,6 @@ import type {
AutofillSource,
} from "utils/richParameters";
import { MultiTextField } from "./MultiTextField";
import SettingsIcon from "@mui/icons-material/Settings";

const isBoolean = (parameter: TemplateVersionParameter) => {
return parameter.type === "bool";
Expand Down
20 changes: 15 additions & 5 deletions site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Interpolation, Theme } from "@emotion/react";
import FormControlLabel from "@mui/material/FormControlLabel";
import FormHelperText from "@mui/material/FormHelperText";
import TextField from "@mui/material/TextField";
import FormControlLabel from "@mui/material/FormControlLabel";
import type * as TypesGen from "api/typesGenerated";
import { Alert } from "components/Alert/Alert";
import { ErrorAlert } from "components/Alert/ErrorAlert";
Expand All @@ -25,6 +25,7 @@ import { Pill } from "components/Pill/Pill";
import { RichParameterInput } from "components/RichParameterInput/RichParameterInput";
import { Spinner } from "components/Spinner/Spinner";
import { Stack } from "components/Stack/Stack";
import { Switch } from "components/Switch/Switch";
import { UserAutocomplete } from "components/UserAutocomplete/UserAutocomplete";
import { type FormikContextType, useFormik } from "formik";
import { generateWorkspaceName } from "modules/workspaces/generateWorkspaceName";
Expand All @@ -46,7 +47,6 @@ import type {
} from "./CreateWorkspacePage";
import { ExternalAuthButton } from "./ExternalAuthButton";
import type { CreateWSPermissions } from "./permissions";
import { Switch } from "components/Switch/Switch";

export const Language = {
duplicationWarning:
Expand Down Expand Up @@ -200,7 +200,13 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
value: presetParameter.Value,
});
}
}, [presetOptions, selectedPresetIndex, presets, parameters, form.setFieldValue]);
}, [
presetOptions,
selectedPresetIndex,
presets,
parameters,
form.setFieldValue,
]);

return (
<Margins size="medium">
Expand Down Expand Up @@ -296,7 +302,9 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
selectedOption={presetOptions[selectedPresetIndex]}
/>
</Stack>
<div css={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
<div
css={{ display: "flex", alignItems: "center", gap: "8px" }}
>
<Switch
checked={showPresetParameters}
onCheckedChange={setShowPresetParameters}
Expand Down Expand Up @@ -382,7 +390,9 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
{parameters.map((parameter, index) => {
const parameterField = `rich_parameter_values.${index}`;
const parameterInputName = `${parameterField}.value`;
const isPresetParameter = presetParameterNames.includes(parameter.name);
const isPresetParameter = presetParameterNames.includes(
parameter.name,
);
const isDisabled =
disabledParams?.includes(
parameter.name.toLowerCase().replace(/ /g, "_"),
Expand Down
Loading