From e9554d8f08930d1cd3e32995ec8532b43cb19c5b Mon Sep 17 00:00:00 2001 From: himanshudube97 Date: Tue, 17 Dec 2024 13:07:07 +0530 Subject: [PATCH] temp fix, need to figure out the order of HMAC key fields --- src/helpers/ConnectorConfigInput.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/helpers/ConnectorConfigInput.tsx b/src/helpers/ConnectorConfigInput.tsx index 61946ece..98d518fd 100644 --- a/src/helpers/ConnectorConfigInput.tsx +++ b/src/helpers/ConnectorConfigInput.tsx @@ -65,6 +65,7 @@ class ConnectorConfigInput { prepareSpecsToRender() { this.specsToRender = ConnectorConfigInput.traverseSpecs([], this.specsData, 'config', [], []); + console.log(this.specsToRender, 'specs to render'); return this.specsToRender; } @@ -164,8 +165,11 @@ class ConnectorConfigInput { let commonField: string[] = []; // Find common property among all array elements of 'oneOf' array + if (value['oneOf'] && value['oneOf'].length > 1) { + // Works for more than one element, because for 1 element we cannot find one commonField. The array would be filled with all the properties. value['oneOf']?.forEach((ele: any) => { + //Fills the common array with all fields in 1st iteration and filters the uncommon fields with subsequent iterations. if (commonField.length > 0) { commonField = Object.keys(ele?.properties) .filter((key: any) => 'const' in ele?.properties[key]) // mongodb connector case. Only cluster type had const property and was not at the top level but with the other properties that were to be rendered if a cluster type is selected. @@ -174,6 +178,12 @@ class ConnectorConfigInput { commonField = Object.keys(ele?.properties); } }); + } else if (value['oneOf'] && value['oneOf'].length == 1) { + value['oneOf']?.forEach((ele: any) => { + commonField = Object.keys(ele?.properties).filter( + (key: any) => 'const' in ele.properties[key] + ); + }); } // an object type can either have oneOf or properties