fix(pipeline-editor): 脚本为空时会提交一个空字符串脚本到后端。

This commit is contained in:
Ivan Li 2021-07-10 19:08:28 +08:00
parent de24645436
commit 2efbad4fe5

View File

@ -17,10 +17,7 @@ import { useConfirm } from "material-ui-confirm";
import { useSnackbar } from "notistack";
import { not, omit } from "ramda";
import { ChangeEvent, FC } from "react";
import {
Pipeline,
PipelineUnits,
} from "../generated/graphql";
import { Pipeline, PipelineUnits } from "../generated/graphql";
import { useHeaderContainer } from "../layouts";
import { CREATE_PIPELINE, DELETE_PIPELINE, UPDATE_PIPELINE } from "./mutations";
import * as Yup from "yup";
@ -269,6 +266,13 @@ const ScriptsField: FC<TextFieldProps> = ({ field, form, meta, ...props }) => {
meta={meta}
field={{
...field,
onBlur: (ev: React.FocusEvent) => {
form.setFieldValue(
field.name,
field.value.filter((it: string) => !!it)
);
return field.onBlur(ev);
},
value: field.value?.join("\n") ?? "",
onChange: (ev: ChangeEvent<HTMLInputElement>) =>
form.setFieldValue(