mirror of
https://github.com/rowyio/rowy.git
synced 2026-02-24 04:01:17 +01:00
connector branding
This commit is contained in:
5
src/components/CodeEditor/rowy.d.ts
vendored
5
src/components/CodeEditor/rowy.d.ts
vendored
@@ -48,7 +48,10 @@ interface Rowy {
|
||||
/**
|
||||
* Get an existing secret from the secret manager.
|
||||
*/
|
||||
get: (name: SecretNames, version?: string) => Promise<string | undefined>;
|
||||
get: (
|
||||
name: SecretNames,
|
||||
version?: string
|
||||
) => Promise<string | any | undefined>;
|
||||
};
|
||||
/**
|
||||
* Gives access to the Cloud Storage.
|
||||
|
||||
@@ -19,15 +19,16 @@ import {
|
||||
} from "@mui/material";
|
||||
import SearchIcon from "@mui/icons-material/Search";
|
||||
|
||||
import { IConnectServiceSelectProps } from ".";
|
||||
import { IConnectorSelectProps } from ".";
|
||||
import useStyles from "./styles";
|
||||
import Loading from "@src/components/Loading";
|
||||
import { useProjectContext } from "@src/contexts/ProjectContext";
|
||||
import { replacer } from "@src/utils/fns";
|
||||
import { getLabel } from "../utils";
|
||||
import { useSnackbar } from "notistack";
|
||||
|
||||
export interface IPopupContentsProps
|
||||
extends Omit<IConnectServiceSelectProps, "className" | "TextFieldProps"> {}
|
||||
extends Omit<IConnectorSelectProps, "className" | "TextFieldProps"> {}
|
||||
|
||||
// TODO: Implement infinite scroll here
|
||||
export default function PopupContents({
|
||||
@@ -37,6 +38,8 @@ export default function PopupContents({
|
||||
docRef,
|
||||
}: IPopupContentsProps) {
|
||||
const { rowyRun, tableState } = useProjectContext();
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
// const url = config.url ;
|
||||
const { config } = column;
|
||||
const elementId = config.elementId;
|
||||
@@ -48,16 +51,28 @@ export default function PopupContents({
|
||||
const [query, setQuery] = useState("");
|
||||
// Webservice response
|
||||
const [response, setResponse] = useState<any | null>(null);
|
||||
const [hits, setHits] = useState<any[]>([]);
|
||||
|
||||
const hits: any["hits"] = response;
|
||||
useEffect(() => {
|
||||
console.log(response);
|
||||
if (response?.success === false) {
|
||||
enqueueSnackbar(response.message, { variant: "error" });
|
||||
} else if (Array.isArray(response?.hits)) {
|
||||
setHits(response.hits);
|
||||
} else {
|
||||
setHits([]);
|
||||
//enqueueSnackbar("response is not any array", { variant: "error" });
|
||||
}
|
||||
}, [response]);
|
||||
const [search] = useDebouncedCallback(
|
||||
async (query: string) => {
|
||||
const resp = await rowyRun!({
|
||||
route: { method: "POST", path: "/connect" },
|
||||
route: { method: "POST", path: "/connector" },
|
||||
body: {
|
||||
columnKey: column.key,
|
||||
query: query,
|
||||
schemaDocPath: tableState?.config.tableConfig.path,
|
||||
rowDocPath: docRef.path,
|
||||
},
|
||||
});
|
||||
setResponse(resp);
|
||||
|
||||
@@ -13,7 +13,7 @@ export type ServiceValue = {
|
||||
[prop: string]: any;
|
||||
};
|
||||
|
||||
export interface IConnectServiceSelectProps {
|
||||
export interface IConnectorSelectProps {
|
||||
value: ServiceValue[];
|
||||
onChange: (value: ServiceValue[]) => void;
|
||||
column: any;
|
||||
@@ -26,13 +26,13 @@ export interface IConnectServiceSelectProps {
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export default function ConnectServiceSelect({
|
||||
export default function ConnectorSelect({
|
||||
value = [],
|
||||
className,
|
||||
TextFieldProps = {},
|
||||
disabled,
|
||||
...props
|
||||
}: IConnectServiceSelectProps) {
|
||||
}: IConnectorSelectProps) {
|
||||
const classes = useStyles();
|
||||
|
||||
const sanitisedValue = Array.isArray(value) ? value : [];
|
||||
|
||||
@@ -66,14 +66,14 @@ export default function Settings({ config, onChange }) {
|
||||
steps={[
|
||||
{
|
||||
id: "function",
|
||||
title: "Connect Function",
|
||||
title: "Connector Function",
|
||||
content: (
|
||||
<Stack>
|
||||
<Suspense fallback={<FieldSkeleton height={300} />}>
|
||||
<CodeEditor
|
||||
minHeight={200}
|
||||
value={config.connectFn ?? baseFunction}
|
||||
onChange={onChange("connectFn")}
|
||||
value={config.connectorFn ?? baseFunction}
|
||||
onChange={onChange("connectorFn")}
|
||||
diagnosticsOptions={diagnosticsOptions}
|
||||
extraLibs={[connectorDefs]}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user