Skip to content

Commit

Permalink
fix: env variable validation rule in neo session lanuncher (#2110)
Browse files Browse the repository at this point in the history
* validate variable fields of `EnvVarFormList` when `onBlur`

* validate env variable name when `onChange`
  • Loading branch information
yomybaby authored Jan 2, 2024
1 parent c270d18 commit 42ee785
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions react/src/components/EnvVarFormList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const EnvVarFormList: React.FC<EnvVarFormListProps> = ({
}) => {
const inputRef = useRef<InputRef>(null);
const { t } = useTranslation();
const form = Form.useFormInstance();
return (
<Form.List {...props}>
{(fields, { add, remove }) => {
Expand Down Expand Up @@ -51,6 +52,7 @@ const EnvVarFormList: React.FC<EnvVarFormListProps> = ({
);

if (
!_.isEmpty(variableName) &&
variableNames.length > 0 &&
_.filter(variableNames, (i) => i === variableName)
.length > 1
Expand All @@ -72,6 +74,14 @@ const EnvVarFormList: React.FC<EnvVarFormListProps> = ({
<Input
ref={index === fields.length - 1 ? inputRef : null}
placeholder="Variable"
onChange={() => {
const fieldNames = fields.map((field, index) => [
props.name,
index,
'variable',
]);
form.validateFields(fieldNames);
}}
/>
</Form.Item>
<Form.Item
Expand Down

0 comments on commit 42ee785

Please sign in to comment.