-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🪟 🎉 Add sync mode, primary key, cursor select components to new strea…
…ms table (#18627) * Add SyncModeSelect component Add button type to pill button and stop propagation Stop propagation on popoout outside click listener and migrate to scss module * Update DropDown option to handle click event directly and stop propagation * Add StreamPathSelect component to select the primary key and cursor paths Update PillSelect to handle nil values * Add SyncMode, Primary Key, and Cursor selects to CatalogTreeTableRow * Replace popup click catcher with Overlay component Add Overlay color variant and onClick handler option Fix Overlay import
- Loading branch information
Showing
13 changed files
with
181 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
airbyte-webapp/src/components/connection/CatalogTree/next/StreamDetailsPanel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
airbyte-webapp/src/components/connection/CatalogTree/next/StreamPathSelect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React from "react"; | ||
import { FormattedMessage } from "react-intl"; | ||
|
||
import { PillSelect } from "components/ui/PillSelect"; | ||
import { Tooltip } from "components/ui/Tooltip"; | ||
|
||
import { Path } from "core/domain/catalog"; | ||
|
||
export const pathDisplayName = (path: Path): string => path.join("."); | ||
|
||
export type IndexerType = null | "required" | "sourceDefined"; | ||
|
||
interface StreamPathSelectBaseProps { | ||
paths: Path[]; | ||
pathType: "required" | "sourceDefined"; | ||
placeholder?: React.ReactNode; | ||
} | ||
|
||
interface StreamPathSelectMultiProps { | ||
path?: Path[]; | ||
onPathChange: (pkPath: Path[]) => void; | ||
isMulti: true; | ||
} | ||
|
||
interface StreamPathSelectProps { | ||
path?: Path; | ||
onPathChange: (pkPath: Path) => void; | ||
isMulti?: false; | ||
} | ||
|
||
type PathPopoutProps = StreamPathSelectBaseProps & (StreamPathSelectMultiProps | StreamPathSelectProps); | ||
|
||
export const StreamPathSelect: React.FC<PathPopoutProps> = (props) => { | ||
if (props.pathType === "sourceDefined") { | ||
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={text}> | ||
{text} | ||
</Tooltip> | ||
); | ||
} | ||
|
||
return <FormattedMessage id="connection.catalogTree.sourceDefined" />; | ||
} | ||
|
||
const options = props.paths.map((path) => ({ | ||
value: path, | ||
label: pathDisplayName(path), | ||
})); | ||
|
||
return ( | ||
<PillSelect | ||
options={options} | ||
value={props.path} | ||
isMulti={props.isMulti} | ||
onChange={(options: PathPopoutProps["isMulti"] extends true ? Array<{ value: Path }> : { value: Path }) => { | ||
const finalValues = Array.isArray(options) ? options.map((op) => op.value) : options.value; | ||
props.onPathChange(finalValues); | ||
}} | ||
/> | ||
); | ||
}; |
3 changes: 3 additions & 0 deletions
3
airbyte-webapp/src/components/connection/CatalogTree/next/SyncModeSelect.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.pillSelect { | ||
width: 100%; | ||
} |
44 changes: 44 additions & 0 deletions
44
airbyte-webapp/src/components/connection/CatalogTree/next/SyncModeSelect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useMemo } from "react"; | ||
import { FormattedMessage } from "react-intl"; | ||
|
||
import { DropDownOptionDataItem } from "components/ui/DropDown"; | ||
import { PillSelect } from "components/ui/PillSelect"; | ||
|
||
import { DestinationSyncMode, SyncMode } from "core/request/AirbyteClient"; | ||
|
||
import styles from "./SyncModeSelect.module.scss"; | ||
|
||
interface SyncModeValue { | ||
syncMode: SyncMode; | ||
destinationSyncMode: DestinationSyncMode; | ||
} | ||
|
||
interface SyncModeOption { | ||
value: SyncModeValue; | ||
} | ||
|
||
interface SyncModeSelectProps { | ||
options: SyncModeOption[]; | ||
value: Partial<SyncModeValue>; | ||
onChange?: (option: DropDownOptionDataItem<SyncModeValue>) => void; | ||
} | ||
|
||
export const SyncModeSelect: React.FC<SyncModeSelectProps> = ({ options, onChange, value }) => { | ||
const pillSelectOptions = useMemo(() => { | ||
return options.map(({ value }) => { | ||
const { syncMode, destinationSyncMode } = value; | ||
return { | ||
label: ( | ||
<> | ||
<FormattedMessage id={`syncMode.${syncMode}`} /> | ||
{` | `} | ||
<FormattedMessage id={`destinationSyncMode.${destinationSyncMode}`} /> | ||
</> | ||
), | ||
value, | ||
}; | ||
}); | ||
}, [options]); | ||
|
||
return <PillSelect options={pillSelectOptions} value={value} onChange={onChange} className={styles.pillSelect} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
import classNames from "classnames"; | ||
|
||
import styles from "./Overlay.module.scss"; | ||
|
||
export const Overlay: React.FC = () => <div className={styles.container} aria-hidden="true" />; | ||
interface OverlayProps { | ||
onClick?: React.MouseEventHandler<HTMLDivElement>; | ||
variant?: "dark" | "transparent"; | ||
} | ||
|
||
export const Overlay: React.FC<OverlayProps> = ({ variant = "dark", onClick }) => ( | ||
<div | ||
className={classNames(styles.container, { | ||
[styles.dark]: variant === "dark", | ||
})} | ||
role={onClick ? "button" : undefined} | ||
onClick={onClick} | ||
aria-hidden="true" | ||
/> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./Overlay"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters