|
1 | 1 | import styles from "./ServicesCatalog.module.css";
|
2 | 2 |
|
3 |
| -import { FaCloud, FaDatabase } from "react-icons/fa"; |
| 3 | +import { FaDatabase, FaDocker } from "react-icons/fa"; |
4 | 4 | import { useApi } from "../../lib/useApi";
|
5 | 5 | import { SourceType } from "../../pages/api/sources";
|
6 | 6 | import capitalize from "lodash/capitalize";
|
7 | 7 | import { LoadingAnimation } from "../GlobalLoader/GlobalLoader";
|
8 | 8 | import React from "react";
|
9 | 9 | import { ErrorCard } from "../GlobalError/GlobalError";
|
10 |
| -import { Input } from "antd"; |
| 10 | +import { Button, Input, Popover } from "antd"; |
11 | 11 | import { useAppConfig, useWorkspace } from "../../lib/context";
|
12 | 12 |
|
13 | 13 | function groupByType(sources: SourceType[]): Record<string, SourceType[]> {
|
@@ -50,15 +50,19 @@ export function getServiceIcon(source: SourceType, icons: Record<string, string>
|
50 | 50 | ) : connectorSubtype === "database" ? (
|
51 | 51 | <FaDatabase className={"w-full h-full"} />
|
52 | 52 | ) : (
|
53 |
| - <FaCloud className={"w-full h-full"} /> |
| 53 | + <FaDocker className={"w-full h-full"} /> |
54 | 54 | );
|
55 | 55 | }
|
56 | 56 |
|
57 |
| -export const ServicesCatalog: React.FC<{ onClick: (packageType, packageId: string) => void }> = ({ onClick }) => { |
| 57 | +export const ServicesCatalog: React.FC<{ onClick: (packageType, packageId: string, version?: string) => void }> = ({ |
| 58 | + onClick, |
| 59 | +}) => { |
58 | 60 | const { data, isLoading, error } = useApi<{ sources: SourceType[] }>(`/api/sources?mode=meta`);
|
59 | 61 | const sourcesIconsLoader = useApi<{ sources: SourceType[] }>(`/api/sources?mode=icons-only`);
|
60 | 62 | const workspace = useWorkspace();
|
61 | 63 | const [filter, setFilter] = React.useState("");
|
| 64 | + const [customImage, setCustomImage] = React.useState(""); |
| 65 | + const [customPopupOpen, setCustomPopupOpen] = React.useState(false); |
62 | 66 | const appconfig = useAppConfig();
|
63 | 67 | const sourcesIcons: Record<string, string> = sourcesIconsLoader.data
|
64 | 68 | ? sourcesIconsLoader.data.sources.reduce(
|
@@ -135,6 +139,52 @@ export const ServicesCatalog: React.FC<{ onClick: (packageType, packageId: strin
|
135 | 139 | </div>
|
136 | 140 | );
|
137 | 141 | })}
|
| 142 | + <div key={"custom-connector"} className=""> |
| 143 | + <div className="text-3xl text-textLight px-4 pb-0 pt-3">Advanced</div> |
| 144 | + <div className="flex flex-wrap"> |
| 145 | + <Popover |
| 146 | + content={ |
| 147 | + <div className={"flex flex-row gap-1.5"}> |
| 148 | + <Input onChange={e => setCustomImage(e.target.value)} /> |
| 149 | + <Button |
| 150 | + type={"primary"} |
| 151 | + onClick={() => { |
| 152 | + const [packageId, packageVersion] = (customImage || "").trim().split(":"); |
| 153 | + if (!packageId) { |
| 154 | + return; |
| 155 | + } |
| 156 | + onClick("airbyte", packageId, packageVersion); |
| 157 | + setCustomPopupOpen(false); |
| 158 | + setCustomImage(""); |
| 159 | + }} |
| 160 | + > |
| 161 | + Add |
| 162 | + </Button> |
| 163 | + </div> |
| 164 | + } |
| 165 | + onOpenChange={setCustomPopupOpen} |
| 166 | + open={customPopupOpen} |
| 167 | + title="Enter docker image name" |
| 168 | + placement={"right"} |
| 169 | + trigger="click" |
| 170 | + > |
| 171 | + <div |
| 172 | + key="custom-connector" |
| 173 | + className={`flex items-center cursor-pointer relative w-72 border border-textDisabled ${"hover:scale-105 hover:border-primary"} transition ease-in-out rounded-lg px-4 py-4 space-x-4 m-4`} |
| 174 | + > |
| 175 | + <div className={`${styles.icon} flex`}> |
| 176 | + <FaDocker /> |
| 177 | + </div> |
| 178 | + <div> |
| 179 | + <div> |
| 180 | + <div className={`text-xl`}>Custom connector</div> |
| 181 | + </div> |
| 182 | + <div className="text-xs text-textLight">Custom docker image</div> |
| 183 | + </div> |
| 184 | + </div> |
| 185 | + </Popover> |
| 186 | + </div> |
| 187 | + </div> |
138 | 188 | </div>
|
139 | 189 | </div>
|
140 | 190 | );
|
|
0 commit comments