Skip to content

Commit

Permalink
Remove table name from column names (#2914)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamakase committed Apr 30, 2021
1 parent 5823eec commit c9db920
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 70 deletions.
2 changes: 1 addition & 1 deletion airbyte-webapp/src/components/MainView/MainView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import styled from "styled-components";
import SideBar from "components/SideBar";
import SideBar from "views/layout/SideBar";

const MainContainer = styled.div`
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,33 +122,30 @@ const TreeViewSection: React.FC<TreeViewRowProps> = ({
}
),
})),
[stream.supportedSyncModes, formatMessage]
[stream.supportedSyncModes, destinationSupportedSyncModes, formatMessage]
);

const pkPaths = useMemo(
() =>
new Set(
config.primaryKey.map((pkPath) => `${stream.name}.${pkPath.join(".")}`)
),
[config, stream]
() => new Set(config.primaryKey.map((pkPath) => pkPath.join("."))),
[config]
);

const onPkSelect = (field: SyncSchemaField) => {
const pkPath = field.name.replace(`${stream.name}.`, "").split(".");
const pkPath = field.name.split(".");

let newPrimaryKey: string[][];

if (pkPaths.has(field.name)) {
updateStreamWithConfig({
primaryKey: config.primaryKey.filter((key) => !equal(key, pkPath)),
});
newPrimaryKey = config.primaryKey.filter((key) => !equal(key, pkPath));
} else {
updateStreamWithConfig({ primaryKey: [...config.primaryKey, pkPath] });
newPrimaryKey = [...config.primaryKey, pkPath];
}
};

const selectedCursorPath = `${stream.name}.${config.cursorField.join(".")}`;
updateStreamWithConfig({ primaryKey: newPrimaryKey });
};

const onCursorSelect = (field: SyncSchemaField) => {
const cursorPath = field.name.replace(`${stream.name}.`, "").split(".");
const cursorPath = field.name.split(".");

updateStreamWithConfig({ cursorField: cursorPath });
};
Expand All @@ -161,6 +158,7 @@ const TreeViewSection: React.FC<TreeViewRowProps> = ({
const showCursor = !stream.sourceDefinedCursor;

const pkKeyItems = config.primaryKey.map((k) => k.join("."));
const selectedCursorPath = config.cursorField.join(".");

return (
<>
Expand Down
12 changes: 9 additions & 3 deletions airbyte-webapp/src/core/domain/catalog/fieldUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export const traverseSchemaToField = (
const traverseJsonSchemaProperties = (
jsonSchema: JSONSchema7Definition,
key: string,
path: string = key
path: string = key,
depth = 0
): SyncSchemaField[] => {
if (typeof jsonSchema === "boolean") {
return [];
Expand All @@ -42,15 +43,20 @@ const traverseJsonSchemaProperties = (
if (jsonSchema.properties) {
fields = Object.entries(jsonSchema.properties)
.flatMap(([k, schema]) =>
traverseJsonSchemaProperties(schema, k, `${path}.${k}`)
traverseJsonSchemaProperties(
schema,
k,
depth === 0 ? k : `${path}.${k}`,
depth + 1
)
)
.flat(2);
}

return [
{
cleanedName: key,
name: path || key,
name: path,
key,
fields,
type:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export enum EntityStepsTypes {
}

const CreationFormPage: React.FC<IProps> = ({ type }) => {
const [currentStep, setCurrentStep] = useState(StepsTypes.CREATE_ENTITY);
const [currentEntityStep, setCurrentEntityStep] = useState(
EntityStepsTypes.SOURCE
);

const { location, push } = useRouter();
const source = useResource(
SourceResource.detailShape(),
Expand All @@ -51,52 +56,6 @@ const CreationFormPage: React.FC<IProps> = ({ type }) => {
: null
);

const steps =
type === "connection"
? [
{
id: StepsTypes.CREATE_ENTITY,
name: <FormattedMessage id={"onboarding.createSource"} />,
},
{
id: StepsTypes.CREATE_CONNECTOR,
name: <FormattedMessage id={"onboarding.createDestination"} />,
},
{
id: StepsTypes.CREATE_CONNECTION,
name: <FormattedMessage id={"onboarding.setUpConnection"} />,
},
]
: [
{
id: StepsTypes.CREATE_ENTITY,
name:
type === "destination" ? (
<FormattedMessage id={"onboarding.createDestination"} />
) : (
<FormattedMessage id={"onboarding.createSource"} />
),
},
{
id: StepsTypes.CREATE_CONNECTION,
name: <FormattedMessage id={"onboarding.setUpConnection"} />,
},
];
const [currentStep, setCurrentStep] = useState(StepsTypes.CREATE_ENTITY);
const [currentEntityStep, setCurrentEntityStep] = useState(
EntityStepsTypes.SOURCE
);

const afterSubmitConnection = () => {
if (type === "destination") {
push(`${Routes.Source}/${source?.sourceId}`);
} else if (type === "source") {
push(`${Routes.Destination}/${destination?.destinationId}`);
} else {
push(`${Routes.Connections}`);
}
};

const renderStep = () => {
if (
currentStep === StepsTypes.CREATE_ENTITY ||
Expand Down Expand Up @@ -151,6 +110,16 @@ const CreationFormPage: React.FC<IProps> = ({ type }) => {
}
}

const afterSubmitConnection = () => {
if (type === "destination") {
push(`${Routes.Source}/${source?.sourceId}`);
} else if (type === "source") {
push(`${Routes.Destination}/${destination?.destinationId}`);
} else {
push(`${Routes.Connections}`);
}
};

return (
<CreateConnectionContent
source={source!}
Expand All @@ -160,6 +129,38 @@ const CreationFormPage: React.FC<IProps> = ({ type }) => {
);
};

const steps =
type === "connection"
? [
{
id: StepsTypes.CREATE_ENTITY,
name: <FormattedMessage id={"onboarding.createSource"} />,
},
{
id: StepsTypes.CREATE_CONNECTOR,
name: <FormattedMessage id={"onboarding.createDestination"} />,
},
{
id: StepsTypes.CREATE_CONNECTION,
name: <FormattedMessage id={"onboarding.setUpConnection"} />,
},
]
: [
{
id: StepsTypes.CREATE_ENTITY,
name:
type === "destination" ? (
<FormattedMessage id={"onboarding.createDestination"} />
) : (
<FormattedMessage id={"onboarding.createSource"} />
),
},
{
id: StepsTypes.CREATE_CONNECTION,
name: <FormattedMessage id={"onboarding.setUpConnection"} />,
},
];

return (
<MainPageWithScroll
title={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ import { faSlack } from "@fortawesome/free-brands-svg-icons";
import { FormattedMessage } from "react-intl";
import { NavLink } from "react-router-dom";

import Link from "../Link";
import { Routes } from "pages/routes";
import config from "config";

import useNotification from "components/hooks/services/useNotification";
import Link from "components/Link";
import Version from "components/Version";
import Indicator from "components/Indicator";
import Source from "./components/Source";
import Connections from "./components/Connections";
import Version from "../Version";
import Destination from "./components/Destination";
import { Routes } from "pages/routes";
import config from "config";
import Indicator from "../Indicator";
import useNotification from "../hooks/services/useNotification";

const Bar = styled.nav`
width: 100px;
Expand Down

0 comments on commit c9db920

Please sign in to comment.