Skip to content

Commit

Permalink
🪟 🐛 Namespace changes should be reflected in sync catalog table (#16643)
Browse files Browse the repository at this point in the history
* bug fix for custom namespace

* cleanup types and returns
  • Loading branch information
teallarson authored Sep 14, 2022
1 parent 144d1ec commit 5687cef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
26 changes: 9 additions & 17 deletions airbyte-webapp/src/core/domain/catalog/fieldUtil.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { JSONSchema7Definition } from "json-schema";

import { NamespaceDefinitionType } from "../../request/AirbyteClient";
import { SOURCE_NAMESPACE_TAG } from "../connector/source";
import { SyncSchemaField } from "./models";

type AirbyteJsonSchema = JSONSchema7Definition & {
Expand Down Expand Up @@ -49,28 +48,21 @@ const traverseJsonSchemaProperties = (
};

interface NamespaceOptions {
namespaceDefinition: typeof NamespaceDefinitionType.source | typeof NamespaceDefinitionType.destination;
sourceNamespace?: string;
}
interface NamespaceOptionsCustomFormat {
namespaceDefinition: typeof NamespaceDefinitionType.customformat;
namespaceFormat: string;
sourceNamespace?: string;
namespaceDefinition:
| typeof NamespaceDefinitionType.source
| typeof NamespaceDefinitionType.destination
| typeof NamespaceDefinitionType.customformat;
namespaceFormat?: string;
}

function getDestinationNamespace(opt: NamespaceOptions | NamespaceOptionsCustomFormat) {
const destinationSetting = "<destination schema>";
function getDestinationNamespace(opt: NamespaceOptions) {
switch (opt.namespaceDefinition) {
case NamespaceDefinitionType.source:
return opt.sourceNamespace ?? destinationSetting;
return "<source schema>";
case NamespaceDefinitionType.destination:
return destinationSetting;
return "<destination schema>";
case NamespaceDefinitionType.customformat:
default: // Default is never hit, but typescript prefers it declared
if (!opt.sourceNamespace?.trim()) {
return destinationSetting;
}
return opt.namespaceFormat.replace(SOURCE_NAMESPACE_TAG, opt.sourceNamespace);
return opt.namespaceFormat;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ const CatalogSectionInner: React.FC<CatalogSectionInnerProps> = ({
const destNamespace = getDestinationNamespace({
namespaceDefinition,
namespaceFormat,
sourceNamespace: stream?.namespace,
});

const fields = useMemo(() => {
Expand All @@ -133,7 +132,7 @@ const CatalogSectionInner: React.FC<CatalogSectionInnerProps> = ({
<div className={styles.catalogSection}>
<StreamHeader
stream={streamNode}
destNamespace={destNamespace}
destNamespace={destNamespace ?? ""}
destName={prefix + (streamNode.stream?.name ?? "")}
availableSyncModes={availableSyncModes}
onSelectStream={onSelectStream}
Expand Down

0 comments on commit 5687cef

Please sign in to comment.