Skip to content

Commit

Permalink
fix(pipeline-builder): prevent user create duplicated field on start …
Browse files Browse the repository at this point in the history
…and end operator (#963)

Because

- relates issue https://github.com/instill-ai/community/issues/559

This commit

- prevent user create duplicated field on start and end operator
  • Loading branch information
EiffelFly committed Feb 15, 2024
1 parent bd624a6 commit a96b0a0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@instill-ai/toolkit",
"version": "0.80.4-rc.7",
"version": "0.80.4-rc.8",
"description": "Instill AI's frontend toolkit",
"repository": "https://github.com/instill-ai/design-system.git",
"bugs": "https://github.com/instill-ai/design-system/issues",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ export const EndOperatorNode = ({ data, id }: NodeProps<EndNodeData>) => {
const onCreateFreeFormField = (
formData: z.infer<typeof EndOperatorFreeFormSchema>
) => {
if (
data.component.configuration.metadata &&
Object.keys(data.component.configuration.metadata).includes(formData.key)
) {
form.setError("key", {
type: "manual",
message: "Key already exists",
});
return;
}

const newNodes = nodes.map((node) => {
if (node.data.nodeType === "end") {
if (prevFieldKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,22 @@ export const StartOperatorNode = ({ data, id }: NodeProps<StartNodeData>) => {
updatePipelineRecipeIsDirty(() => true);
};

const onCreateFreeFormField = (
function onCreateFreeFormField(
formData: z.infer<typeof StartOperatorFreeFormSchema>
) => {
) {
let configuraton: Nullable<StartOperatorInput> = null;

if (
data.component.configuration.metadata &&
Object.keys(data.component.configuration.metadata).includes(formData.key)
) {
form.setError("key", {
type: "manual",
message: "Key already exists",
});
return;
}

switch (selectedType) {
case "string": {
configuraton = {
Expand Down Expand Up @@ -313,7 +324,7 @@ export const StartOperatorNode = ({ data, id }: NodeProps<StartNodeData>) => {
title: "",
description: "",
});
};
}

function onCancelFreeForm() {
setEnableEdit((prev) => !prev);
Expand Down

0 comments on commit a96b0a0

Please sign in to comment.