From c9163845ea599701014a8bae51a392c188c00779 Mon Sep 17 00:00:00 2001 From: Sakshi Bobade Date: Wed, 14 Aug 2024 12:55:34 +0530 Subject: [PATCH] updating the jsonforms --- src/renderer/components/common/JsonForms.tsx | 47 ++++++++------------ src/services/ResolveRef.ts | 9 ++++ 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/renderer/components/common/JsonForms.tsx b/src/renderer/components/common/JsonForms.tsx index 655ae56d..5ad08e65 100644 --- a/src/renderer/components/common/JsonForms.tsx +++ b/src/renderer/components/common/JsonForms.tsx @@ -177,18 +177,12 @@ export default function JsonForm(props: any) { let requiredSchema = schema; const isFormDataEmpty = formData === null || formData === undefined || Object.keys(formData).length < 1; - // const [reqSchema, setReqSchema] = useState(schema); - // const [reqFormData, setReqFormData] = useState(isFormDataEmpty ? getDefaultFormData(schema, {}) : formData); const [selectedSchemaIndex, setSelectedSchemaIndex] = useState(0); let formDataToUse = isFormDataEmpty ? getDefaultFormData(schema, {}) : formData; useEffect(() => { if (schema?.oneOf) { const initialSchemaIndex = handleOneOfSchema(schema, formData); - // setSelectedSchemaIndex(initialSchemaIndex); - // setReqSchema(schema.oneOf[initialSchemaIndex]); - // setReqFormData(filterFormData(formData, schema.oneOf[initialSchemaIndex])); - requiredSchema = schema.oneOf[initialSchemaIndex]; formDataToUse = filterFormData(formData, requiredSchema); } @@ -197,9 +191,6 @@ export default function JsonForm(props: any) { const handleSchemaChange = (event: any) => { const schemaIndex = parseInt(event.target.value); setSelectedSchemaIndex(schemaIndex); - // setReqSchema(schema.oneOf[schemaIndex]); - // setReqFormData(filterFormData(formData, schema.oneOf[schemaIndex])); - requiredSchema = schema.oneOf[schemaIndex]; formDataToUse = (filterFormData(formData, schema.oneOf[schemaIndex])); } @@ -209,29 +200,29 @@ export default function JsonForm(props: any) { { schema.oneOf &&
- - { schema.oneOf.map((_: any, index: number) => ( - } label={`Certificate ${index}`} /> - ))} - + + { schema.oneOf.map((_: any, index: number) => ( + } label={`Certificate ${index}`} /> + ))} +
} - { onChange(data) }} - /> + { onChange(data) }} + /> ); } \ No newline at end of file diff --git a/src/services/ResolveRef.ts b/src/services/ResolveRef.ts index 604627d6..72c37dc2 100644 --- a/src/services/ResolveRef.ts +++ b/src/services/ResolveRef.ts @@ -11,6 +11,15 @@ export const updateSchemaReferences = (schema: any, serverCommon: any): void => } catch(error){ console.error("Error resolving reference:", error.message); } + } else if (key === "pattern" && typeof node[key] === "string") { + // Sanitize pattern for use in RegExp + try { + new RegExp(node[key]); + console.log("trying----------------------------------------------------"); + } catch (error) { + console.error("Invalid regular expression pattern:", node[key]); + continue; + } } else { traverseAndUpdate(node[key]); }