Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pipeline-builder): prevent user create duplicated field on start and end operator #963

Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading