Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(site): set min and max attributes for workspace number parameters#15182

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -99,6 +99,38 @@ export const NumberType: Story = {
},
};

export const NumberTypeWithIncreasingMonotonicity: Story = {
args: {
value: 4,
id: "number_parameter",
parameter: createTemplateVersionParameter({
name: "number_parameter",
type: "number",
description: "Numeric parameter",
default_value: "",
validation_min: 0,
validation_max: 10,
validation_monotonic: "increasing",
}),
},
};

export const NumberTypeWithDecreasingMonotonicity: Story = {
args: {
value: 4,
id: "number_parameter",
parameter: createTemplateVersionParameter({
name: "number_parameter",
type: "number",
description: "Numeric parameter",
default_value: "",
validation_min: 0,
validation_max: 10,
validation_monotonic: "decreasing",
}),
},
};

export const BooleanType: Story = {
args: {
value: "false",
Expand Down
28 changes: 28 additions & 0 deletionssite/src/components/RichParameterInput/RichParameterInput.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ import ErrorOutline from "@mui/icons-material/ErrorOutline";
import Button from "@mui/material/Button";
import FormControlLabel from "@mui/material/FormControlLabel";
import FormHelperText from "@mui/material/FormHelperText";
import type { InputBaseComponentProps } from "@mui/material/InputBase";
import Radio from "@mui/material/Radio";
import RadioGroup from "@mui/material/RadioGroup";
import TextField, { type TextFieldProps } from "@mui/material/TextField";
Expand DownExpand Up@@ -217,6 +218,7 @@ export const RichParameterInput: FC<RichParameterInputProps> = ({
onChange={onChange}
size={size}
parameter={parameter}
parameterAutofill={parameterAutofill}
/>
{!parameter.ephemeral &&
autofillSource === "user_history" &&
Expand DownExpand Up@@ -250,6 +252,7 @@ const RichParameterField: FC<RichParameterInputProps> = ({
disabled,
onChange,
parameter,
parameterAutofill,
value,
size,
...props
Expand DownExpand Up@@ -375,6 +378,30 @@ const RichParameterField: FC<RichParameterInputProps> = ({
);
}

let inputProps: InputBaseComponentProps = {};
if (parameter.type === "number") {
switch (parameter.validation_monotonic) {
case "increasing":
inputProps = {
max: parameter.validation_max,
min: parameterAutofill?.value,
};
break;
case "decreasing":
inputProps = {
max: parameterAutofill?.value,
min: parameter.validation_min,
};
break;
default:
inputProps = {
max: parameter.validation_max,
min: parameter.validation_min,
};
break;
}
}

// A text field can technically handle all cases!
// As other cases become more prominent (like filtering for numbers),
// we should break this out into more finely scoped input fields.
Expand All@@ -389,6 +416,7 @@ const RichParameterField: FC<RichParameterInputProps> = ({
required={parameter.required}
placeholder={parameter.default_value}
value={value}
inputProps={inputProps}
onChange={(event) => {
onChange(event.target.value);
}}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -112,6 +112,9 @@ export const WorkspaceParametersForm: FC<WorkspaceParameterFormProps> = ({
);
}}
parameter={parameter}
parameterAutofill={autofillParams?.find(
({ name }) => name === parameter.name,
)}
/>
) : null,
)}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,7 @@ test("Submit the workspace settings page successfully", async () => {
{ exact: false },
);
await user.clear(parameter2);
await user.type(parameter2, "1");
await user.type(parameter2, "3");
await user.click(
within(form).getByRole("button", { name: "Submit and restart" }),
);
Expand All@@ -70,7 +70,7 @@ test("Submit the workspace settings page successfully", async () => {
transition: "start",
rich_parameter_values: [
{ name: MockTemplateVersionParameter1.name, value: "new-value" },
{ name: MockTemplateVersionParameter2.name, value: "1" },
{ name: MockTemplateVersionParameter2.name, value: "3" },
],
});
});
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp