Skip to content

Commit

Permalink
Show "source defined" as cursor for CDC streams, move strings to i18n (
Browse files Browse the repository at this point in the history
…#16999)

* Update check on PathPopout to ensure source defined appears when the path provided is empty

* i18n source defined message

* Update source defined message format
Move destination namespace names to i18n
  • Loading branch information
edmundito authored Sep 23, 2022
1 parent 68cae56 commit c943b8d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 32 deletions.
24 changes: 1 addition & 23 deletions airbyte-webapp/src/core/domain/catalog/fieldUtil.ts
Original file line number Diff line number Diff line change
@@ -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[] => {
Expand Down Expand Up @@ -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 "<source schema>";
case NamespaceDefinitionType.destination:
return "<destination schema>";
case NamespaceDefinitionType.customformat:
return opt.namespaceFormat;
}
}

export { getDestinationNamespace, traverseSchemaToField };
24 changes: 24 additions & 0 deletions airbyte-webapp/src/hooks/connection/useDestinationNamespace.ts
Original file line number Diff line number Diff line change
@@ -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;
}
};
4 changes: 4 additions & 0 deletions airbyte-webapp/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@
"connection.updateSchema.namespace": "Namespace",
"connection.updateSchema.dataType": "Data type",

"connection.catalogTree.sourceDefined": "<source defined>",
"connection.catalogTree.sourceSchema": "<source schema>",
"connection.catalogTree.destinationSchema": "<destination schema>",

"connection.newConnection": "+ New connection",
"connection.newConnectionTitle": "New connection",
"connection.noConnections": "Connection list is empty",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -106,7 +107,7 @@ const CatalogSectionInner: React.FC<CatalogSectionInnerProps> = ({
[stream?.supportedSyncModes, supportedDestinationSyncModes]
);

const destNamespace = getDestinationNamespace({
const destNamespace = useDestinationNamespace({
namespaceDefinition,
namespaceFormat,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import { FormattedMessage } from "react-intl";

import { Popout } from "components";
import { Tooltip } from "components/base/Tooltip";
Expand Down Expand Up @@ -36,20 +37,17 @@ type PathPopoutProps = PathPopoutBaseProps & (PathMultiProps | PathProps);

export const PathPopout: React.FC<PathPopoutProps> = (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 (
<Tooltip placement="bottom-start" control={<div className={styles.text}>{text}</div>}>
{text}
</Tooltip>
);
}
return <>{"<sourceDefined>"}</>;

return <FormattedMessage id="connection.catalogTree.sourceDefined" />;
}

const text = props.path
Expand Down

0 comments on commit c943b8d

Please sign in to comment.