diff --git a/airbyte-webapp/src/core/domain/catalog/fieldUtil.ts b/airbyte-webapp/src/core/domain/catalog/fieldUtil.ts index 626ec955a0f0..ad4f92065958 100644 --- a/airbyte-webapp/src/core/domain/catalog/fieldUtil.ts +++ b/airbyte-webapp/src/core/domain/catalog/fieldUtil.ts @@ -1,13 +1,12 @@ import { JSONSchema7Definition } from "json-schema"; -import { NamespaceDefinitionType } from "../../request/AirbyteClient"; import { SyncSchemaField } from "./models"; type AirbyteJsonSchema = JSONSchema7Definition & { airbyte_type?: string; }; -const traverseSchemaToField = ( +export const traverseSchemaToField = ( jsonSchema: AirbyteJsonSchema | undefined, key: string | undefined ): SyncSchemaField[] => { @@ -46,24 +45,3 @@ const traverseJsonSchemaProperties = ( }, ]; }; - -interface NamespaceOptions { - namespaceDefinition: - | typeof NamespaceDefinitionType.source - | typeof NamespaceDefinitionType.destination - | typeof NamespaceDefinitionType.customformat; - namespaceFormat?: string; -} - -function getDestinationNamespace(opt: NamespaceOptions) { - switch (opt.namespaceDefinition) { - case NamespaceDefinitionType.source: - return ""; - case NamespaceDefinitionType.destination: - return ""; - case NamespaceDefinitionType.customformat: - return opt.namespaceFormat; - } -} - -export { getDestinationNamespace, traverseSchemaToField }; diff --git a/airbyte-webapp/src/hooks/connection/useDestinationNamespace.ts b/airbyte-webapp/src/hooks/connection/useDestinationNamespace.ts new file mode 100644 index 000000000000..07966801e321 --- /dev/null +++ b/airbyte-webapp/src/hooks/connection/useDestinationNamespace.ts @@ -0,0 +1,24 @@ +import { useIntl } from "react-intl"; + +import { NamespaceDefinitionType } from "core/request/AirbyteClient"; + +interface NamespaceOptions { + namespaceDefinition: + | typeof NamespaceDefinitionType.source + | typeof NamespaceDefinitionType.destination + | typeof NamespaceDefinitionType.customformat; + namespaceFormat?: string; +} + +export const useDestinationNamespace = (opt: NamespaceOptions): string | undefined => { + const { formatMessage } = useIntl(); + + switch (opt.namespaceDefinition) { + case NamespaceDefinitionType.source: + return formatMessage({ id: "connection.catalogTree.sourceSchema" }); + case NamespaceDefinitionType.destination: + return formatMessage({ id: "connection.catalogTree.destinationSchema" }); + case NamespaceDefinitionType.customformat: + return opt.namespaceFormat; + } +}; diff --git a/airbyte-webapp/src/locales/en.json b/airbyte-webapp/src/locales/en.json index 6546305001e3..d4636f70dbe4 100644 --- a/airbyte-webapp/src/locales/en.json +++ b/airbyte-webapp/src/locales/en.json @@ -346,6 +346,10 @@ "connection.updateSchema.namespace": "Namespace", "connection.updateSchema.dataType": "Data type", + "connection.catalogTree.sourceDefined": "", + "connection.catalogTree.sourceSchema": "", + "connection.catalogTree.destinationSchema": "", + "connection.newConnection": "+ New connection", "connection.newConnectionTitle": "New connection", "connection.noConnections": "Connection list is empty", diff --git a/airbyte-webapp/src/views/Connection/CatalogTree/CatalogSection.tsx b/airbyte-webapp/src/views/Connection/CatalogTree/CatalogSection.tsx index 9c3db3db1e2d..64d637cc30c9 100644 --- a/airbyte-webapp/src/views/Connection/CatalogTree/CatalogSection.tsx +++ b/airbyte-webapp/src/views/Connection/CatalogTree/CatalogSection.tsx @@ -4,8 +4,9 @@ import { useToggle } from "react-use"; import { DropDownRow } from "components"; -import { getDestinationNamespace, SyncSchemaField, SyncSchemaFieldObject, SyncSchemaStream } from "core/domain/catalog"; +import { SyncSchemaField, SyncSchemaFieldObject, SyncSchemaStream } from "core/domain/catalog"; import { traverseSchemaToField } from "core/domain/catalog/fieldUtil"; +import { useDestinationNamespace } from "hooks/connection/useDestinationNamespace"; import { useConnectionFormService } from "hooks/services/Connection/ConnectionFormService"; import { equal, naturalComparatorBy } from "utils/objects"; import { ConnectionFormValues, SUPPORTED_MODES } from "views/Connection/ConnectionForm/formConfig"; @@ -106,7 +107,7 @@ const CatalogSectionInner: React.FC = ({ [stream?.supportedSyncModes, supportedDestinationSyncModes] ); - const destNamespace = getDestinationNamespace({ + const destNamespace = useDestinationNamespace({ namespaceDefinition, namespaceFormat, }); diff --git a/airbyte-webapp/src/views/Connection/CatalogTree/components/PathPopout.tsx b/airbyte-webapp/src/views/Connection/CatalogTree/components/PathPopout.tsx index 3b142d4cb60f..09790601d277 100644 --- a/airbyte-webapp/src/views/Connection/CatalogTree/components/PathPopout.tsx +++ b/airbyte-webapp/src/views/Connection/CatalogTree/components/PathPopout.tsx @@ -1,4 +1,5 @@ import React from "react"; +import { FormattedMessage } from "react-intl"; import { Popout } from "components"; import { Tooltip } from "components/base/Tooltip"; @@ -36,12 +37,8 @@ type PathPopoutProps = PathPopoutBaseProps & (PathMultiProps | PathProps); export const PathPopout: React.FC = (props) => { if (props.pathType === "sourceDefined") { - if (props.path) { - const text = props.path - ? props.isMulti - ? props.path.map(pathDisplayName).join(", ") - : pathDisplayName(props.path) - : ""; + if (props.path && props.path.length > 0) { + const text = props.isMulti ? props.path.map(pathDisplayName).join(", ") : pathDisplayName(props.path); return ( {text}}> @@ -49,7 +46,8 @@ export const PathPopout: React.FC = (props) => { ); } - return <>{""}; + + return ; } const text = props.path