Add support for sandboxed salesforce (#4252)

This commit is contained in:
Chris Weaver 2025-03-11 17:21:24 -07:00 committed by GitHub
parent a918a84e7b
commit 997f40500d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 15 deletions

View File

@ -48,10 +48,12 @@ class SalesforceConnector(LoadConnector, PollConnector, SlimConnector):
self,
credentials: dict[str, Any],
) -> dict[str, Any] | None:
domain = "test" if credentials.get("is_sandbox") else None
self._sf_client = Salesforce(
username=credentials["sf_username"],
password=credentials["sf_password"],
security_token=credentials["sf_security_token"],
domain=domain,
)
return None

View File

@ -3,7 +3,10 @@ import { Button } from "@/components/ui/button";
import { ValidSources } from "@/lib/types";
import { FaAccusoft } from "react-icons/fa";
import { submitCredential } from "@/components/admin/connectors/CredentialForm";
import { TextFormField } from "@/components/admin/connectors/Field";
import {
BooleanFormField,
TextFormField,
} from "@/components/admin/connectors/Field";
import { Form, Formik, FormikHelpers } from "formik";
import { PopupSpec } from "@/components/admin/connectors/Popup";
import { getSourceDocLink } from "@/lib/sources";
@ -206,20 +209,31 @@ export default function CreateCredential({
placeholder="(Optional) credential name.."
label="Name:"
/>
{Object.entries(credentialTemplate).map(([key, val]) => (
<TextFormField
key={key}
name={key}
placeholder={val}
label={getDisplayNameForCredentialKey(key)}
type={
key.toLowerCase().includes("token") ||
key.toLowerCase().includes("password")
? "password"
: "text"
}
/>
))}
{Object.entries(credentialTemplate).map(([key, val]) => {
if (typeof val === "boolean") {
return (
<BooleanFormField
key={key}
name={key}
label={getDisplayNameForCredentialKey(key)}
/>
);
}
return (
<TextFormField
key={key}
name={key}
placeholder={val}
label={getDisplayNameForCredentialKey(key)}
type={
key.toLowerCase().includes("token") ||
key.toLowerCase().includes("password")
? "password"
: "text"
}
/>
);
})}
{!swapConnector && (
<div className="mt-4 flex w-full flex-col sm:flex-row justify-between items-end">
<div className="w-full sm:w-3/4 mb-4 sm:mb-0">

View File

@ -171,6 +171,7 @@ export interface SalesforceCredentialJson {
sf_username: string;
sf_password: string;
sf_security_token: string;
is_sandbox: boolean;
}
export interface SharepointCredentialJson {
@ -270,6 +271,7 @@ export const credentialTemplates: Record<ValidSources, any> = {
sf_username: "",
sf_password: "",
sf_security_token: "",
is_sandbox: false,
} as SalesforceCredentialJson,
sharepoint: {
sp_client_id: "",
@ -452,6 +454,7 @@ export const credentialDisplayNames: Record<string, string> = {
sf_username: "Salesforce Username",
sf_password: "Salesforce Password",
sf_security_token: "Salesforce Security Token",
is_sandbox: "Is Sandbox Environment",
// Sharepoint
sp_client_id: "SharePoint Client ID",