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 { useSnackbar } from "notistack";
import { not, omit } from "ramda"; import { not, omit } from "ramda";
import { ChangeEvent, FC } from "react"; import { ChangeEvent, FC } from "react";
import { import { Pipeline, PipelineUnits } from "../generated/graphql";
Pipeline,
PipelineUnits,
} from "../generated/graphql";
import { useHeaderContainer } from "../layouts"; import { useHeaderContainer } from "../layouts";
import { CREATE_PIPELINE, DELETE_PIPELINE, UPDATE_PIPELINE } from "./mutations"; import { CREATE_PIPELINE, DELETE_PIPELINE, UPDATE_PIPELINE } from "./mutations";
import * as Yup from "yup"; import * as Yup from "yup";
@ -269,6 +266,13 @@ const ScriptsField: FC<TextFieldProps> = ({ field, form, meta, ...props }) => {
meta={meta} meta={meta}
field={{ field={{
...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") ?? "", value: field.value?.join("\n") ?? "",
onChange: (ev: ChangeEvent<HTMLInputElement>) => onChange: (ev: ChangeEvent<HTMLInputElement>) =>
form.setFieldValue( form.setFieldValue(