Skip to content

Commit

Permalink
Merge pull request #1291 from DalgoT4D/mongo-db-connector-issue
Browse files Browse the repository at this point in the history
mongo db connector issue.
  • Loading branch information
Ishankoradia authored Nov 2, 2024
2 parents 5cdf810 + 889c1d6 commit 03b04ca
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
36 changes: 36 additions & 0 deletions src/components/ConfigInput/ConfigInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,42 @@ export const ConfigInput = ({ specs, control, setFormValue, entity }: ConfigInpu
/>
<Box sx={{ m: 2 }} />
</React.Fragment>
) : spec?.enum &&
spec?.enum.length > 0 &&
(spec?.specs == null || spec?.specs === undefined) ? (
//usually parent object containing enum has type object. but in the case of mongodb connector the type was string.
<>
<React.Fragment key={spec.field}>
<Controller
name={spec.field}
control={control}
rules={{ required: spec.required && 'Required' }}
render={({ field, fieldState }) => (
<Autocomplete
disabled={false}
data-testid="autocomplete"
id={spec.field}
value={field.value}
options={spec.enum as any}
onChange={(e, data: any) => {
handleObjectFieldOnChange(data, spec.field, field);
}}
renderInput={(params) => (
<Input
name={spec.field}
error={!!fieldState.error}
helperText={fieldState.error?.message}
{...params}
variant="outlined"
label={`${spec.title}${spec.required ? '*' : ''}`}
/>
)}
/>
)}
/>
<Box sx={{ m: 2 }} />
</React.Fragment>
</>
) : (
<React.Fragment key={spec.field}>
<Controller
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/ConnectorConfigInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ class ConnectorConfigInput {
if (value['oneOf'] && value['oneOf'].length > 1) {
value['oneOf']?.forEach((ele: any) => {
if (commonField.length > 0) {
commonField = Object.keys(ele?.properties).filter((value: any) =>
commonField.includes(value)
);
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.
.filter((value: any) => commonField.includes(value));
} else {
commonField = Object.keys(ele?.properties);
}
Expand Down

0 comments on commit 03b04ca

Please sign in to comment.