This is an automated email from the ASF dual-hosted git repository.
dhanak pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git
The following commit(s) were added to refs/heads/main by this push:
new 9b19b531f37 kie-tools#3316: [sonataflow-deployment-webapp] generated
inputs are sent only if are touched (#3367)
9b19b531f37 is described below
commit 9b19b531f370fb87d8dfb52d3694e2abf2ad831a
Author: Kumar Aditya Raj <[email protected]>
AuthorDate: Mon Feb 23 14:03:29 2026 +0530
kie-tools#3316: [sonataflow-deployment-webapp] generated inputs are sent
only if are touched (#3367)
Co-authored-by: kumaradityaraj <[email protected]>
---
.../src/components/FormRenderer/FormRenderer.tsx | 5 +-
.../src/utils/ModelConversionTool.ts | 13 ++
.../tests/CodeEditorTextField.test.tsx.bak | 203 ---------------------
3 files changed, 17 insertions(+), 204 deletions(-)
diff --git
a/packages/runtime-tools-components/src/components/FormRenderer/FormRenderer.tsx
b/packages/runtime-tools-components/src/components/FormRenderer/FormRenderer.tsx
index 6afc77200e0..4034ccd4f13 100644
---
a/packages/runtime-tools-components/src/components/FormRenderer/FormRenderer.tsx
+++
b/packages/runtime-tools-components/src/components/FormRenderer/FormRenderer.tsx
@@ -58,7 +58,10 @@ export const FormRenderer =
React.forwardRef<FormRendererApi, IOwnProps & OUIAPr
});
// Converting Dates that are in string format into JS Dates so they can be
correctly bound to the uniforms DateField
- const formData = ModelConversionTool.convertStringToDate(model,
formSchema);
+ const formData = ModelConversionTool.applySchemaDefaults(
+ ModelConversionTool.convertStringToDate(model, formSchema),
+ formSchema
+ );
const submitFormData = (): void => {
formApiRef!.submit();
diff --git a/packages/runtime-tools-components/src/utils/ModelConversionTool.ts
b/packages/runtime-tools-components/src/utils/ModelConversionTool.ts
index e88623295ad..eb63f0b92dd 100644
--- a/packages/runtime-tools-components/src/utils/ModelConversionTool.ts
+++ b/packages/runtime-tools-components/src/utils/ModelConversionTool.ts
@@ -25,6 +25,19 @@ export class ModelConversionTool {
public static convertStringToDate = (model: any, schema: Record<string,
any>): any => {
return doConvert(model, schema, (value) => new Date(value));
};
+
+ public static applySchemaDefaults(model: any, schema: Record<string, any>):
any {
+ const newModel = { ...model };
+ if (schema.properties) {
+ Object.keys(schema.properties).forEach((key) => {
+ const prop = schema.properties[key];
+ if (prop.type === "boolean" && newModel[key] === undefined) {
+ newModel[key] = prop.default ?? false;
+ }
+ });
+ }
+ return newModel;
+ }
}
interface ContextInitArgs {
diff --git
a/packages/sonataflow-uniforms/tests/CodeEditorTextField.test.tsx.bak
b/packages/sonataflow-uniforms/tests/CodeEditorTextField.test.tsx.bak
deleted file mode 100644
index af6cabb94a2..00000000000
--- a/packages/sonataflow-uniforms/tests/CodeEditorTextField.test.tsx.bak
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import * as React from "react";
-import CodeEditorTextField from "../src/CodeEditorTextField";
-import { fireEvent, render, screen } from "@testing-library/react";
-// import { usingUniformsContext } from "./test-utils";
-import { Language } from
"@patternfly/react-code-editor/dist/js/components/CodeEditor";
-
-const jsonMock = JSON.stringify({ first_name: "John", last_name: "Doe" });
-
-// test("<CodeEditorTextField> - renders an editor", () => {
-// render(
-// usingUniformsContext(<CodeEditorTextField name="x"
language={Language.json} />, {
-// x: { type: String, uniforms: { language: "json" } },
-// })
-// );
-//
-// expect(screen.getByTestId("wrapper-field")).toBeInTheDocument();
-// });
-//
-// test("<CodeEditorTextField> - renders an editor with correct disabled
state", () => {
-// render(
-// usingUniformsContext(<CodeEditorTextField name="x" disabled
language={Language.json} />, {
-// x: { type: String, uniforms: { language: "json" } },
-// })
-// );
-//
-// expect(screen.getByTestId("wrapper-field")).toBeInTheDocument();
-//
expect(screen.getByTestId("code-editor-textarea").getAttribute("readOnly")).not.toBe(null);
-// });
-//
-// test("<CodeEditorTextField> - renders an editor with correct name", () => {
-// render(
-// usingUniformsContext(<CodeEditorTextField name="x" disabled
language={Language.json} />, {
-// x: { type: String, uniforms: { language: "json" } },
-// })
-// );
-//
-// expect(screen.getByTestId("wrapper-field")).toBeInTheDocument();
-//
expect(screen.getByTestId("code-editor-hidden-field").getAttribute("name")).toBe("x");
-// });
-//
-// test("<CodeEditorTextField> - renders an editor with correct value
(default)", () => {
-// render(
-// usingUniformsContext(<CodeEditorTextField name="x"
language={Language.json} />, {
-// x: { type: String, uniforms: { language: "json" } },
-// })
-// );
-//
-// expect(screen.getByTestId("wrapper-field")).toBeInTheDocument();
-// const editor = screen.getByTestId("code-editor-textarea") as
HTMLTextAreaElement;
-// expect(editor.value).toBe("");
-//
expect(screen.getByTestId("code-editor-hidden-field").getAttribute("value")).toBe("");
-// });
-//
-// test("<CodeEditorTextField> - renders an editor with correct value
(model)", () => {
-// render(
-// usingUniformsContext(
-// <CodeEditorTextField name="x" language={Language.json} />,
-// { x: { type: String, uniforms: { language: "json" } } },
-// { model: { x: jsonMock } }
-// )
-// );
-//
-// expect(screen.getByTestId("wrapper-field")).toBeInTheDocument();
-// expect(screen.getByText(jsonMock)).toBeInTheDocument();
-//
expect(screen.getByTestId("code-editor-hidden-field").getAttribute("value")).toBe(jsonMock);
-// });
-//
-// test("<CodeEditorTextField> - renders an editor with correct value
(specified)", () => {
-// render(
-// usingUniformsContext(<CodeEditorTextField name="x"
language={Language.json} value="y" />, {
-// x: { type: String, uniforms: { language: "json" } },
-// })
-// );
-//
-// expect(screen.getByTestId("wrapper-field")).toBeInTheDocument();
-// expect(screen.getByText("y")).toBeInTheDocument();
-//
expect(screen.getByTestId("code-editor-hidden-field").getAttribute("value")).toBe("y");
-// });
-//
-// test("<CodeEditorTextField> - renders an editor which correctly reacts on
change", () => {
-// const onChange = jest.fn();
-//
-// render(
-// usingUniformsContext(
-// <CodeEditorTextField name="x" language={Language.json} />,
-// { x: { type: String, uniforms: { language: "json" } } },
-// { onChange }
-// )
-// );
-//
-// expect(screen.getByTestId("wrapper-field")).toBeInTheDocument();
-// const editor = screen.getByTestId("code-editor-textarea");
-// fireEvent.change(editor, { target: { value: "y" } });
-// expect(onChange).toHaveBeenLastCalledWith("x", "y");
-//
expect(screen.getByTestId("code-editor-hidden-field").getAttribute("value")).toBe("y");
-// });
-//
-// test("<CodeEditorTextField> - renders an editor which correctly reacts on
change (empty)", () => {
-// const onChange = jest.fn();
-//
-// render(
-// usingUniformsContext(
-// <CodeEditorTextField name="x" language={Language.json} />,
-// { x: { type: String, uniforms: { language: "json" } } },
-// { onChange }
-// )
-// );
-//
-// expect(screen.getByTestId("wrapper-field")).toBeInTheDocument();
-// const editor = screen.getByTestId("code-editor-textarea");
-// fireEvent.change(editor, { target: { value: "" } });
-// expect(onChange).not.toHaveBeenCalled();
-// });
-//
-// test("<CodeEditorTextField> - renders an editor which correctly reacts on
change (same value)", () => {
-// const onChange = jest.fn();
-//
-// render(
-// usingUniformsContext(
-// <CodeEditorTextField name="x" language={Language.json} />,
-// { x: { type: String, uniforms: { language: "json" } } },
-// { model: { x: "y" }, onChange }
-// )
-// );
-//
-// expect(screen.getByTestId("wrapper-field")).toBeInTheDocument();
-// const editor = screen.getByTestId("code-editor-textarea");
-// fireEvent.change(editor, { target: { value: "y" } });
-// expect(screen.getByText("y")).toBeInTheDocument();
-// expect(onChange).not.toHaveBeenCalled();
-// });
-//
-// test("<CodeEditorTextField> - renders a label", () => {
-// render(
-// usingUniformsContext(<CodeEditorTextField name="x" label="y"
language={Language.json} />, {
-// x: { type: String, uniforms: { language: "json" } },
-// })
-// );
-//
-// expect(screen.getByTestId("wrapper-field")).toBeInTheDocument();
-// expect(screen.getByText("y")).toBeInTheDocument();
-// });
-//
-// test("<CodeEditorTextField> - renders an editor with correct height
(default)", () => {
-// render(
-// usingUniformsContext(<CodeEditorTextField name="x"
language={Language.json} />, {
-// x: { type: String, uniforms: { language: "json" } },
-// })
-// );
-//
-// expect(screen.getByTestId("wrapper-field")).toBeInTheDocument();
-//
expect(screen.getByTestId("code-editor-textarea").style.height).toBe("200px");
-// });
-//
-// test("<CodeEditorTextField> - renders an editor with correct height
(specified)", () => {
-// render(
-// usingUniformsContext(<CodeEditorTextField name="x" height="300px"
language={Language.json} />, {
-// x: { type: String, uniforms: { language: "json" } },
-// })
-// );
-//
-// expect(screen.getByTestId("wrapper-field")).toBeInTheDocument();
-//
expect(screen.getByTestId("code-editor-textarea").style.height).toBe("300px");
-// });
-//
-// test("<CodeEditorTextField> - renders an editor with correct language
(default)", () => {
-// render(
-// usingUniformsContext(<CodeEditorTextField name="x" />, { x: { type:
String, uniforms: { language: "json" } } })
-// );
-//
-// expect(screen.getByTestId("wrapper-field")).toBeInTheDocument();
-//
expect(screen.getByTestId("code-editor-textarea").getAttribute("data-language")).toBe("json");
-// });
-//
-// test("<CodeEditorTextField> - renders an editor with correct language
(specified)", () => {
-// render(
-// usingUniformsContext(<CodeEditorTextField name="x"
language={Language.graphql} />, {
-// x: { type: String, uniforms: { language: "json" } },
-// })
-// );
-//
-// expect(screen.getByTestId("wrapper-field")).toBeInTheDocument();
-//
expect(screen.getByTestId("code-editor-textarea").getAttribute("data-language")).toBe("graphql");
-// });
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]