Skip to content

Commit

Permalink
Update wayfinder and improve advanced mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeprins committed Nov 2, 2023
1 parent 1ddc07d commit 8c12fc4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@apideck/components": "^0.12.9",
"@apideck/wayfinder": "^0.1.9",
"@apideck/wayfinder": "^0.2.2",
"formik": "^2.2.9",
"fuse.js": "^6.5.3",
"jwt-decode": "^3.1.2",
Expand Down
2 changes: 1 addition & 1 deletion src/components/FieldMappingForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useConnections } from '../utils/useConnections';
import { useSession } from '../utils/useSession';
import FieldSelector from './FieldSelector';

const findByDescription = (obj: any, description: string): any => {
export const findByDescription = (obj: any, description: string): any => {
for (const key in obj) {
if (obj[key] instanceof Object) {
const result = findByDescription(obj[key], description);
Expand Down
12 changes: 10 additions & 2 deletions src/components/FieldSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import React, {
useState,
} from 'react';
import useSWR from 'swr';
import { extractLastAttribute } from '../utils/extractLastAttribute';
import { useConnections } from '../utils/useConnections';
import { findByDescription } from './FieldMappingForm';

interface Props {
onSelect: (field: any) => void;
Expand Down Expand Up @@ -408,11 +410,16 @@ const FieldSelector = ({
onSelect={(jsonPath) => {
if (jsonPath) {
setFieldMappingString(jsonPath);
const mappingObject = findByDescription(
properties,
jsonPath
);
onSelect({
title: jsonPath,
title: extractLastAttribute(jsonPath),
mode: 'manual',
type: 'Advanced',
type: mappingObject?.type || 'Advanced',
description: jsonPath,
example: mappingObject?.example,
});
}
removeModal();
Expand All @@ -423,6 +430,7 @@ const FieldSelector = ({
null,
2
)}
defaultJsonPath={fieldMappingString}
/>,
{
className: '!max-w-5xl !p-0',
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
postinstall-postinstall "^2.1.0"
use-clipboard-copy "^0.2.0"

"@apideck/wayfinder@^0.1.9":
version "0.1.9"
resolved "https://registry.yarnpkg.com/@apideck/wayfinder/-/wayfinder-0.1.9.tgz#bfaa55d632236a0341adadb95ffecd4d8d62ca12"
integrity sha512-MkOMqKD6YuVPnBWZCkYMi080AmzaAYiJ4J7VvHy8iIK1Ilo/2qJwNtYQVErhBgtqUA7GRqojQp3hxwwEZDvTmw==
"@apideck/wayfinder@^0.2.2":
version "0.2.2"
resolved "https://registry.yarnpkg.com/@apideck/wayfinder/-/wayfinder-0.2.2.tgz#7b9debda5048b26e25802f7f0ce44d76efd16b1e"
integrity sha512-OzjX7zgvINch+C4jrj80XEs7Fmt4W45CGz3uryUqhf9grzL3RA6wvqXjoehFROmdXN5FXts2XQmNiPHcP7HQww==
dependencies:
"@monaco-editor/react" "^4.6.0"
classnames "2.3.2"
Expand Down

0 comments on commit 8c12fc4

Please sign in to comment.