Skip to content

Commit 07618a0

Browse files
author
Joey Marshment-Howell
authored
🪟 🎉 Add temporary dropdown component for geography selection (#19127)
* add temporary data geography dropdown * remove commented code * adjust comment * remove console.log * avoid any type
1 parent 804af5d commit 07618a0

File tree

8 files changed

+97
-33
lines changed

8 files changed

+97
-33
lines changed

airbyte-webapp/src/components/CreateConnection/DataResidency.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Field, FieldProps, useFormikContext } from "formik";
22
import { FormattedMessage, useIntl } from "react-intl";
33

4+
import { DataGeographyDropdown } from "components/common/DataGeographyDropdown";
45
import { ControlLabels } from "components/LabeledControl";
5-
import { DropDown } from "components/ui/DropDown";
66

7+
import { Geography } from "core/request/AirbyteClient";
78
import { useAvailableGeographies } from "packages/cloud/services/geographies/GeographiesService";
89
import { links } from "utils/links";
910
import { Section } from "views/Connection/ConnectionForm/components/Section";
@@ -22,7 +23,7 @@ export const DataResidency: React.FC<DataResidencyProps> = ({ name = "geography"
2223
return (
2324
<Section title={formatMessage({ id: "connection.geographyTitle" })}>
2425
<Field name={name}>
25-
{({ field, form }: FieldProps<string>) => (
26+
{({ field, form }: FieldProps<Geography>) => (
2627
<div className={styles.flexRow}>
2728
<div className={styles.leftFieldCol}>
2829
<ControlLabels
@@ -43,17 +44,11 @@ export const DataResidency: React.FC<DataResidencyProps> = ({ name = "geography"
4344
/>
4445
</div>
4546
<div className={styles.rightFieldCol}>
46-
<DropDown
47+
<DataGeographyDropdown
4748
isDisabled={form.isSubmitting}
48-
options={geographies.map((geography) => ({
49-
label: formatMessage({
50-
id: `connection.geography.${geography}`,
51-
defaultMessage: geography.toUpperCase(),
52-
}),
53-
value: geography,
54-
}))}
49+
geographies={geographies}
5550
value={field.value}
56-
onChange={(geography) => setFieldValue(name, geography.value)}
51+
onChange={(geography) => setFieldValue(name, geography)}
5752
/>
5853
</div>
5954
</div>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@use "scss/colors";
2+
@use "scss/variables";
3+
4+
.requestLink {
5+
padding: variables.$spacing-md variables.$spacing-lg;
6+
color: colors.$blue-400;
7+
text-decoration: none;
8+
display: block;
9+
border-top: 1px solid colors.$grey-100;
10+
11+
&:hover {
12+
background: colors.$grey-100;
13+
}
14+
}
15+
16+
.linkText {
17+
margin-left: variables.$spacing-md;
18+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { faPlus } from "@fortawesome/free-solid-svg-icons";
2+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
3+
import { FormattedMessage, useIntl } from "react-intl";
4+
import { components, MenuListProps } from "react-select";
5+
6+
import { DropDown } from "components/ui/DropDown";
7+
8+
import { Geography } from "core/request/AirbyteClient";
9+
import { links } from "utils/links";
10+
11+
import styles from "./DataGeographyDropdown.module.scss";
12+
13+
interface DataGeographyDropdownProps {
14+
geographies: Geography[];
15+
isDisabled?: boolean;
16+
onChange: (value: Geography) => void;
17+
value: Geography;
18+
}
19+
20+
const CustomMenuList: React.FC<MenuListProps> = ({ children, ...rest }) => {
21+
return (
22+
<components.MenuList {...rest}>
23+
{children}
24+
<a href={links.dataResidencySurvey} target="_blank" rel="noreferrer" className={styles.requestLink}>
25+
<FontAwesomeIcon icon={faPlus} />
26+
<span className={styles.linkText}>
27+
<FormattedMessage id="connection.requestNewGeography" />
28+
</span>
29+
</a>
30+
</components.MenuList>
31+
);
32+
};
33+
34+
export const DataGeographyDropdown: React.FC<DataGeographyDropdownProps> = ({
35+
geographies,
36+
isDisabled = false,
37+
onChange,
38+
value,
39+
}) => {
40+
const { formatMessage } = useIntl();
41+
42+
return (
43+
<DropDown
44+
isDisabled={isDisabled}
45+
options={geographies.map((geography) => ({
46+
label: formatMessage({
47+
id: `connection.geography.${geography}`,
48+
defaultMessage: geography.toUpperCase(),
49+
}),
50+
value: geography,
51+
}))}
52+
value={value}
53+
onChange={(option) => onChange(option.value)}
54+
components={{
55+
MenuList: CustomMenuList,
56+
}}
57+
/>
58+
);
59+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { DataGeographyDropdown } from "./DataGeographyDropdown";

airbyte-webapp/src/components/connection/UpdateConnectionDataResidency/UpdateConnectionDataResidency.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, { useState } from "react";
22
import { FormattedMessage, useIntl } from "react-intl";
33

4+
import { DataGeographyDropdown } from "components/common/DataGeographyDropdown";
45
import { ControlLabels } from "components/LabeledControl";
56
import { Card } from "components/ui/Card";
6-
import { DropDown } from "components/ui/DropDown";
77
import { Spinner } from "components/ui/Spinner";
88

99
import { Geography } from "core/request/AirbyteClient";
@@ -22,7 +22,7 @@ export const UpdateConnectionDataResidency: React.FC = () => {
2222

2323
const { geographies } = useAvailableGeographies();
2424

25-
const handleSubmit = async ({ value }: { value: Geography }) => {
25+
const handleSubmit = async (value: Geography) => {
2626
try {
2727
setSelectedValue(value);
2828
await updateConnection({
@@ -63,16 +63,10 @@ export const UpdateConnectionDataResidency: React.FC = () => {
6363
<div className={styles.dropdownWrapper}>
6464
<div className={styles.spinner}>{connectionUpdating && <Spinner small />}</div>
6565
<div className={styles.dropdown}>
66-
<DropDown
66+
<DataGeographyDropdown
6767
isDisabled={connectionUpdating}
68-
options={geographies.map((geography) => ({
69-
label: formatMessage({
70-
id: `connection.geography.${geography}`,
71-
defaultMessage: geography.toUpperCase(),
72-
}),
73-
value: geography,
74-
}))}
75-
value={selectedValue || connection.geography}
68+
geographies={geographies}
69+
value={selectedValue || connection.geography || geographies[0]}
7670
onChange={handleSubmit}
7771
/>
7872
</div>

airbyte-webapp/src/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@
370370
"connection.catalogTree.destinationSchema": "'<destination schema>",
371371

372372
"connection.geographyTitle": "Data residency",
373+
"connection.requestNewGeography": "Request a new geography",
373374
"connection.geographyDescription": "Depending on your network configuration, you may need to <lnk>add IP addresses</lnk> to your allowlist.",
374375
"connection.geography.auto": "Airbyte Default",
375376
"connection.geography.us": "United States",
@@ -523,6 +524,7 @@
523524
"settings.defaultDataResidency": "Default Data Residency",
524525
"settings.defaultGeography": "Geography",
525526
"settings.defaultDataResidencyDescription": "Choose the default preferred data processing location for all of your connections. The default data residency setting only affects new connections. Existing connections will retain their data residency setting. <lnk>Learn more</lnk>.",
527+
"settings.defaultDataResidencyUpdateError": "There was an error updating the default data residency for this workspace.",
526528

527529
"connector.requestConnectorBlock": "Request a new connector",
528530
"connector.requestConnector": "Request a new connector",

airbyte-webapp/src/packages/cloud/views/workspaces/DataResidencyView/DataResidencyView.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import React from "react";
33
import { FormattedMessage, useIntl } from "react-intl";
44

55
import { ControlLabels } from "components";
6+
import { DataGeographyDropdown } from "components/common/DataGeographyDropdown";
67
import { Button } from "components/ui/Button";
7-
import { DropDown } from "components/ui/DropDown";
88
import { Text } from "components/ui/Text";
99

1010
import { Geography } from "core/request/AirbyteClient";
@@ -44,7 +44,7 @@ export const DataResidencyView: React.FC = () => {
4444
} catch (e) {
4545
registerNotification({
4646
id: "workspaceSettings.defaultGeographyError",
47-
title: formatMessage({ id: "connection.geographyUpdateError" }),
47+
title: formatMessage({ id: "settings.defaultDataResidencyUpdateError" }),
4848
isError: true,
4949
});
5050
}
@@ -92,16 +92,10 @@ export const DataResidencyView: React.FC = () => {
9292
}
9393
/>
9494
<div className={styles.defaultGeographyDropdown}>
95-
<DropDown
96-
options={geographies.map((geography) => ({
97-
label: formatMessage({
98-
id: `connection.geography.${geography}`,
99-
defaultMessage: geography.toUpperCase(),
100-
}),
101-
value: geography,
102-
}))}
95+
<DataGeographyDropdown
96+
geographies={geographies}
10397
value={field.value}
104-
onChange={(option) => form.setFieldValue("defaultGeography", option.value)}
98+
onChange={(geography) => form.setFieldValue("defaultGeography", geography)}
10599
/>
106100
</div>
107101
</div>

airbyte-webapp/src/utils/links.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const links = {
3030
webhookGuideLink: `${BASE_DOCS_LINK}/operator-guides/configuring-sync-notifications/`,
3131
cronReferenceLink: "http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html",
3232
cloudAllowlistIPsLink: `${BASE_DOCS_LINK}/cloud/getting-started-with-airbyte-cloud/#allowlist-ip-address`,
33+
dataResidencySurvey: "https://forms.gle/Dr7MPTdt9k3xTinL8",
3334
} as const;
3435

3536
export type OutboundLinks = typeof links;

0 commit comments

Comments
 (0)