diff --git a/airbyte-webapp/src/components/YamlEditor/YamlEditor.tsx b/airbyte-webapp/src/components/YamlEditor/YamlEditor.tsx index a8dc12f0de92d4..94bfc7a0249c40 100644 --- a/airbyte-webapp/src/components/YamlEditor/YamlEditor.tsx +++ b/airbyte-webapp/src/components/YamlEditor/YamlEditor.tsx @@ -7,21 +7,23 @@ import { useDebounce, useLocalStorage } from "react-use"; import { CodeEditor } from "components/ui/CodeEditor"; import { StreamsListRequestBodyManifest } from "core/request/ConnectorBuilderClient"; -import { useConnectorBuilderState } from "services/connectorBuilder/ConnectorBuilderStateService"; import { DownloadYamlButton } from "./DownloadYamlButton"; import styles from "./YamlEditor.module.scss"; import { template } from "./YamlTemplate"; -export const YamlEditor: React.FC = () => { +interface YamlEditorProps { + localStorageKey: string; + setJsonValue: (value: Record) => void; +} + +export const YamlEditor: React.FC = ({ localStorageKey, setJsonValue }) => { const yamlEditorRef = useRef(); - const [locallyStoredYaml, setLocallyStoredYaml] = useLocalStorage("connectorBuilderYaml", template); + const [locallyStoredYaml, setLocallyStoredYaml] = useLocalStorage(localStorageKey, template); const [yamlValue, setYamlValue] = useState(locallyStoredYaml ?? template); useDebounce(() => setLocallyStoredYaml(yamlValue), 500, [yamlValue]); - const { setJsonManifest } = useConnectorBuilderState(); - const monaco = useMonaco(); useEffect(() => { @@ -32,7 +34,7 @@ export const YamlEditor: React.FC = () => { try { const json = load(yamlValue) as StreamsListRequestBodyManifest; - setJsonManifest(json); + setJsonValue(json); // clear editor errors if (yamlEditorModel) { @@ -57,7 +59,7 @@ export const YamlEditor: React.FC = () => { } } } - }, [yamlValue, monaco, setJsonManifest]); + }, [yamlValue, monaco, setJsonValue]); return (
diff --git a/airbyte-webapp/src/pages/ConnectorBuilderPage/ConnectorBuilderPage.tsx b/airbyte-webapp/src/pages/ConnectorBuilderPage/ConnectorBuilderPage.tsx index e432d8c40f4f16..8c6a94bb92ab93 100644 --- a/airbyte-webapp/src/pages/ConnectorBuilderPage/ConnectorBuilderPage.tsx +++ b/airbyte-webapp/src/pages/ConnectorBuilderPage/ConnectorBuilderPage.tsx @@ -12,13 +12,13 @@ import { import styles from "./ConnectorBuilderPage.module.scss"; const ConnectorBuilderPageInner: React.FC = () => { - const { selectedStream } = useConnectorBuilderState(); + const { selectedStream, setJsonManifest } = useConnectorBuilderState(); return ( , + children: , className: styles.leftPanel, minWidth: 400, }}