connector branding

This commit is contained in:
shamsmosowi
2022-03-31 18:37:32 +02:00
parent b306a1cd6d
commit d2c300f08e
4 changed files with 29 additions and 11 deletions

View File

@@ -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.

View File

@@ -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);

View File

@@ -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 : [];

View File

@@ -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]}
/>