jscheffl commented on code in PR #45790:
URL: https://github.com/apache/airflow/pull/45790#discussion_r1929593863
##########
airflow/ui/src/components/FlexibleForm/FieldObject.tsx:
##########
@@ -16,37 +16,63 @@
* specific language governing permissions and limitations
* under the License.
*/
+import { Text } from "@chakra-ui/react";
import { json } from "@codemirror/lang-json";
import { githubLight, githubDark } from "@uiw/codemirror-themes-all";
import CodeMirror from "@uiw/react-codemirror";
+import { useState } from "react";
import { useColorMode } from "src/context/colorMode";
import type { FlexibleFormElementProps } from ".";
+import { paramPlaceholder, useParamStore } from "../TriggerDag/useParamStore";
-export const FieldObject = ({ name, param }: FlexibleFormElementProps) => {
+export const FieldObject = ({ name }: FlexibleFormElementProps) => {
const { colorMode } = useColorMode();
+ const { paramsDict, setParamsDict } = useParamStore();
+ const param = paramsDict[name] ?? paramPlaceholder;
+ const [error, setError] = useState<unknown>(undefined);
+
+ const handleChange = (value: string) => {
+ setError(undefined);
+ try {
+ const parsedValue = JSON.parse(value) as JSON;
Review Comment:
JSON parsing fails at empty field, we need to fix the null handling as well
```suggestion
// "undefined" values are removed from params, so we set it to null to
avoid falling back to DAG defaults.
// eslint-disable-next-line unicorn/no-null
const parsedValue = value === "" ? null : (JSON.parse(value) as JSON);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]