-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ai-assist): add header modal (#13639)
Co-authored-by: lmossman <lake@airbyte.io>
- Loading branch information
Showing
19 changed files
with
175 additions
and
94 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
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
21 changes: 21 additions & 0 deletions
21
airbyte-webapp/src/components/connectorBuilder/Builder/Assist/AssistConfigButton.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,21 @@ | ||
@use "scss/variables"; | ||
@use "scss/colors"; | ||
@use "scss/z-indices"; | ||
|
||
.popoverPanel { | ||
background-color: colors.$foreground; | ||
z-index: z-indices.$modal; | ||
border-radius: variables.$border-radius-md; | ||
box-shadow: variables.$box-shadow-popup; | ||
border: 1px solid colors.$yellow-600; | ||
} | ||
|
||
.assistConfigPanel { | ||
width: variables.$width-modal-md; | ||
max-width: 100%; | ||
padding: variables.$spacing-xl; | ||
} | ||
|
||
.assistForm { | ||
margin-top: variables.$spacing-md; | ||
} |
122 changes: 122 additions & 0 deletions
122
airbyte-webapp/src/components/connectorBuilder/Builder/Assist/AssistConfigButton.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,122 @@ | ||
import { useFloating, offset, flip, autoUpdate } from "@floating-ui/react-dom"; | ||
import { Popover, PopoverButton, PopoverPanel } from "@headlessui/react"; | ||
import { useIntl } from "react-intl"; | ||
|
||
import { Button, ButtonProps } from "components/ui/Button"; | ||
import { FlexContainer } from "components/ui/Flex"; | ||
import { Switch } from "components/ui/Switch"; | ||
import { Text } from "components/ui/Text"; | ||
|
||
import { useExperiment } from "hooks/services/Experiment"; | ||
import { useConnectorBuilderFormState } from "services/connectorBuilder/ConnectorBuilderStateService"; | ||
|
||
import styles from "./AssistConfigButton.module.scss"; | ||
import { BuilderField } from "../BuilderField"; | ||
|
||
type ChangeEventFunction = (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
|
||
export const AssistForm: React.FC = () => { | ||
const { formatMessage } = useIntl(); | ||
|
||
return ( | ||
<FlexContainer direction="column" gap="lg" className={styles.assistForm}> | ||
<BuilderField | ||
type="string" | ||
optional | ||
label={formatMessage({ id: "connectorBuilder.globalConfiguration.assist.docsUrl" })} | ||
placeholder={formatMessage({ id: "connectorBuilder.globalConfiguration.assist.docsUrl.placeholder" })} | ||
manifestPath="metadata.assist.docsUrl" | ||
path="formValues.assist.docsUrl" | ||
/> | ||
<BuilderField | ||
type="string" | ||
optional | ||
label={formatMessage({ id: "connectorBuilder.globalConfiguration.assist.openApiSpecUrl" })} | ||
placeholder={formatMessage({ id: "connectorBuilder.globalConfiguration.assist.openApiSpecUrl.placeholder" })} | ||
manifestPath="metadata.assist.openApiSpecUrl" | ||
path="formValues.assist.openApiSpecUrl" | ||
/> | ||
</FlexContainer> | ||
); | ||
}; | ||
|
||
const AssistSwitch: React.FC = () => { | ||
const { assistEnabled, setAssistEnabled } = useConnectorBuilderFormState(); | ||
const onChange: ChangeEventFunction = (e) => { | ||
setAssistEnabled(e.currentTarget.checked); | ||
}; | ||
|
||
return <Switch checked={assistEnabled} onChange={onChange} />; | ||
}; | ||
|
||
const AssistConfigPanel = () => { | ||
const { formatMessage } = useIntl(); | ||
const { setAssistEnabled, assistEnabled } = useConnectorBuilderFormState(); | ||
|
||
return ( | ||
<FlexContainer direction="column" gap="lg" className={styles.assistConfigPanel}> | ||
<FlexContainer direction="row" justifyContent="space-between" alignItems="center"> | ||
<AIButton onClick={() => setAssistEnabled(!assistEnabled)} /> | ||
<AssistSwitch /> | ||
</FlexContainer> | ||
<Text as="span" color="grey400" size="sm"> | ||
{formatMessage({ id: "connectorBuilder.assist.configModal.description" })} | ||
</Text> | ||
<AssistForm /> | ||
</FlexContainer> | ||
); | ||
}; | ||
|
||
const AIButton = (props: ButtonProps) => { | ||
const { formatMessage } = useIntl(); | ||
const { assistEnabled } = useConnectorBuilderFormState(); | ||
|
||
const variant = assistEnabled ? "highlight" : "secondary"; | ||
|
||
return ( | ||
<Button variant={variant} icon="aiStars" {...props}> | ||
{formatMessage({ id: "connectorBuilder.assist.configModal.button" })} | ||
</Button> | ||
); | ||
}; | ||
|
||
const AssistConfigButton = () => { | ||
const isAIEnabled = useExperiment("connectorBuilder.aiAssist.enabled", false); | ||
|
||
const { x, y, reference, floating, strategy } = useFloating({ | ||
middleware: [offset(5), flip()], | ||
whileElementsMounted: autoUpdate, | ||
placement: "bottom", | ||
}); | ||
|
||
if (!isAIEnabled) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Popover> | ||
{({ open }) => ( | ||
<> | ||
<PopoverButton ref={reference} as="div"> | ||
<AIButton /> | ||
</PopoverButton> | ||
{open && ( | ||
<PopoverPanel | ||
ref={floating} | ||
className={styles.popoverPanel} | ||
style={{ | ||
position: strategy, | ||
top: y ?? 0, | ||
left: x ?? 0, | ||
}} | ||
> | ||
<AssistConfigPanel /> | ||
</PopoverPanel> | ||
)} | ||
</> | ||
)} | ||
</Popover> | ||
); | ||
}; | ||
|
||
export default AssistConfigButton; |
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...src/components/connectorBuilder/assist.ts → ...connectorBuilder/Builder/Assist/assist.ts
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
File renamed without changes
71 changes: 0 additions & 71 deletions
71
airbyte-webapp/src/components/connectorBuilder/Builder/AssistSection.tsx
This file was deleted.
Oops, something went wrong.
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
3 changes: 2 additions & 1 deletion
3
airbyte-webapp/src/components/connectorBuilder/Builder/RecordSelectorSection.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
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
Oops, something went wrong.