-
+ // Apply advanced configuration-specific transforms.
+ const advancedConfiguration: any = {
+ pruneFreq: pruneFreq * 60 * 60 * 24,
+ indexingStart: convertStringToDateTime(indexingStart),
+ refreshFreq: refreshFreq * 60,
+ };
+
+ // Google sites-specific handling
+ if (connector == "google_sites") {
+ const response = await submitGoogleSite(
+ selectedFiles,
+ values?.base_url,
+ setPopup,
+ advancedConfiguration.refreshFreq,
+ advancedConfiguration.pruneFreq,
+ advancedConfiguration.indexingStart,
+ name
+ );
+ if (response) {
+ onSuccess();
+ }
+ return;
+ }
+
+ // File-specific handling
+ if (connector == "file" && selectedFiles.length > 0) {
+ const response = await submitFiles(
+ selectedFiles,
+ setPopup,
+ setSelectedFiles,
+ name,
+ isPublic,
+ groups
+ );
+ if (response) {
+ onSuccess();
+ }
+ return;
+ }
+
+ const { message, isSuccess, response } = await submitConnector
(
+ {
+ connector_specific_config: transformedConnectorSpecificConfig,
+ input_type: connector == "web" ? "load_state" : "poll", // single case
+ name: name,
+ source: connector,
+ refresh_freq: advancedConfiguration.refreshFreq || null,
+ prune_freq: advancedConfiguration.pruneFreq || null,
+ indexing_start: advancedConfiguration.indexingStart || null,
+ is_public: isPublic,
+ groups: groups,
+ },
+ undefined,
+ credentialActivated ? false : true,
+ isPublic
+ );
+ // If no credential
+ if (!credentialActivated) {
+ if (isSuccess) {
+ onSuccess();
+ } else {
+ setPopup({ message: message, type: "error" });
+ }
+ }
+
+ // Without credential
+ if (credentialActivated && isSuccess && response) {
+ const credential =
+ currentCredential || liveGDriveCredential || liveGmailCredential;
+ const linkCredentialResponse = await linkCredential(
+ response.id,
+ credential?.id!,
+ name,
+ isPublic,
+ groups
+ );
+ if (linkCredentialResponse.ok) {
+ onSuccess();
+ } else {
+ const errorData = await linkCredentialResponse.json();
+ setPopup({
+ message: errorData.message,
+ type: "error",
+ });
+ }
+ } else if (isSuccess) {
+ onSuccess();
+ } else {
+ setPopup({ message: message, type: "error" });
+ }
+ return;
+ }}
+ >
+ {(formikProps) => {
+ return (
+
+ {popup}
+
+
+
- >
- ) : connector == "gmail" ? (
- <>
-
- Select a credential
-
-
-
-
-
- >
- ) : (
- <>
-
- Select a credential
-
- {!createConnectorToggle && (
-
- )}
- {/* NOTE: connector will never be google_drive, since the ternary above will
- prevent that, but still keeping this here for safety in case the above changes. */}
- {(connector as ValidSources) !== "google_drive" &&
- createConnectorToggle && (
- setCreateConnectorToggle(false)}
- >
- <>
-
- Create a {getSourceDisplayName(connector)} credential
-
- setCreateConnectorToggle(false)}
- />
- >
-
- )}
-
-
-
-
- >
- ))}
+
}
+ title={displayName}
+ />
- {formStep == 1 && (
- <>
-
- {
- // Can be utilized for logging purposes
- }}
- >
- {(formikProps) => {
- setFormValues(formikProps.values);
- handleFormStatusChange(
- formikProps.isValid && isFormSubmittable(formikProps.values)
- );
- setAllowAdvanced(
- formikProps.isValid && isFormSubmittable(formikProps.values)
- );
+ {formStep == 0 && (
+
+ Select a credential
- return (
-
-
- {isPaidEnterpriseFeaturesEnabled && (
- <>
-
- >
- )}
-
- );
- }}
-
-
-
- {!noCredentials ? (
-
- ) : (
-
- )}
-
-
- {!(connector == "file") && (
-
-
-
- )}
-
- >
- )}
-
- {formStep === 2 && (
- <>
-
- {}}
- >
- {(formikProps) => {
- setAdvancedSettings(formikProps.values);
-
- return (
+ {connector == "google_drive" ? (
+
+ ) : connector == "gmail" ? (
+
+ ) : (
<>
-
-
+
+ {!createConnectorToggle && (
-
+ )}
+
+ {/* NOTE: connector will never be google_drive, since the ternary above will
+ prevent that, but still keeping this here for safety in case the above changes. */}
+ {(connector as ValidSources) !== "google_drive" &&
+ createConnectorToggle && (
+ setCreateConnectorToggle(false)}
+ >
+ <>
+
+ Create a {getSourceDisplayName(connector)}{" "}
+ credential
+
+ setCreateConnectorToggle(false)}
+ />
+ >
+
+ )}
>
- );
- }}
-
-
-
-
-
+ )}
+
+ )}
+
+ {formStep == 1 && (
+
+
+
+
+
+ )}
+
+ {formStep === 2 && (
+
+
+
+ )}
+
+
- >
- )}
-
+ );
+ }}
+
);
}
diff --git a/web/src/app/admin/connectors/[connector]/NavigationRow.tsx b/web/src/app/admin/connectors/[connector]/NavigationRow.tsx
new file mode 100644
index 000000000000..933e4c9d06ff
--- /dev/null
+++ b/web/src/app/admin/connectors/[connector]/NavigationRow.tsx
@@ -0,0 +1,91 @@
+import { useFormContext } from "@/components/context/FormContext";
+import { ArrowLeft, ArrowRight } from "@phosphor-icons/react";
+import { FiPlus } from "react-icons/fi";
+
+const NavigationRow = ({
+ noAdvanced,
+ noCredentials,
+ activatedCredential,
+ onSubmit,
+ isValid,
+}: {
+ isValid: boolean;
+ onSubmit: () => void;
+ noAdvanced: boolean;
+ noCredentials: boolean;
+ activatedCredential: boolean;
+}) => {
+ const { formStep, prevFormStep, nextFormStep } = useFormContext();
+ const SquareNavigationButton = ({
+ onClick,
+ disabled,
+ className,
+ children,
+ }: {
+ onClick: () => void;
+ disabled?: boolean;
+ className: string;
+ children: React.ReactNode;
+ }) => (
+
+ );
+
+ return (
+
+
+ {formStep > 0 && !noCredentials && (
+
+
+ Previous
+
+ )}
+
+
+
+ {(formStep > 0 || noCredentials) && (
+
+ Create Connector
+
+
+ )}
+
+
+
+ {formStep === 0 && (
+
+ Continue
+
+
+ )}
+ {noAdvanced && formStep === 1 && (
+
+ Advanced
+
+
+ )}
+
+
+ );
+};
+export default NavigationRow;
diff --git a/web/src/app/admin/connectors/[connector]/pages/Advanced.tsx b/web/src/app/admin/connectors/[connector]/pages/Advanced.tsx
index 8bb96d54db1c..0f50a7043b8b 100644
--- a/web/src/app/admin/connectors/[connector]/pages/Advanced.tsx
+++ b/web/src/app/admin/connectors/[connector]/pages/Advanced.tsx
@@ -1,66 +1,47 @@
-import React, { Dispatch, forwardRef, SetStateAction } from "react";
-import { Formik, Form, FormikProps } from "formik";
-import * as Yup from "yup";
+import React from "react";
import NumberInput from "./ConnectorInput/NumberInput";
import { TextFormField } from "@/components/admin/connectors/Field";
+import { TrashIcon } from "@/components/icons/icons";
-interface AdvancedFormPageProps {
- formikProps: FormikProps<{
- indexingStart: string | null;
- pruneFreq: number;
- refreshFreq: number;
- }>;
-}
+const AdvancedFormPage = () => {
+ return (
+
+
+ Advanced Configuration
+
-const AdvancedFormPage = forwardRef
, AdvancedFormPageProps>(
- ({ formikProps }, ref) => {
- const { indexingStart, refreshFreq, pruneFreq } = formikProps.values;
+
- return (
-
-
- Advanced Configuration
-
+
-
+
+
- );
- }
-);
+
+ );
+};
-AdvancedFormPage.displayName = "AdvancedFormPage";
export default AdvancedFormPage;
diff --git a/web/src/app/admin/connectors/[connector]/pages/ConnectorInput/NumberInput.tsx b/web/src/app/admin/connectors/[connector]/pages/ConnectorInput/NumberInput.tsx
index a62864495ef8..b7fcb49cf1ea 100644
--- a/web/src/app/admin/connectors/[connector]/pages/ConnectorInput/NumberInput.tsx
+++ b/web/src/app/admin/connectors/[connector]/pages/ConnectorInput/NumberInput.tsx
@@ -3,23 +3,17 @@ import { Field, useFormikContext } from "formik";
export default function NumberInput({
label,
- value,
optional,
description,
name,
showNeverIfZero,
- onChange,
}: {
- value?: number;
label: string;
name: string;
optional?: boolean;
description?: string;
showNeverIfZero?: boolean;
- onChange?: (value: number) => void;
}) {
- const { setFieldValue } = useFormikContext();
-
return (