feat: added UI and fixed added elasticsearch at the edit page

This commit is contained in:
Anish Sarkar 2025-10-10 02:12:19 +05:30
parent 31236f3fc6
commit 849cc91093
14 changed files with 244 additions and 606 deletions

View file

@ -271,6 +271,16 @@ export default function EditConnectorPage() {
placeholder="API Key..."
/>
)}
{/* == Elasticsearch == */}
{connector.connector_type === "ELASTICSEARCH_CONNECTOR" && (
<EditSimpleTokenForm
control={editForm.control}
fieldName="ELASTICSEARCH_API_KEY"
fieldLabel="Elasticsearch API Key"
fieldDescription="Update your Elasticsearch API Key if needed."
placeholder="Your Elasticsearch API Key"
/>
)}
</CardContent>
<CardFooter className="border-t pt-6">
<Button type="submit" disabled={isSaving} className="w-full sm:w-auto">

View file

@ -54,6 +54,7 @@ const getConnectorTypeDisplay = (type: string): string => {
GOOGLE_GMAIL_CONNECTOR: "Google Gmail Connector",
AIRTABLE_CONNECTOR: "Airtable Connector",
LUMA_CONNECTOR: "Luma Connector",
ELASTICSEARCH_CONNECTOR: "Elasticsearch Connector",
// Add other connector types here as needed
};
return typeMap[type] || type;
@ -73,6 +74,7 @@ const getApiKeyFieldName = (connectorType: string): string => {
DISCORD_CONNECTOR: "DISCORD_BOT_TOKEN",
LINKUP_API: "LINKUP_API_KEY",
LUMA_CONNECTOR: "LUMA_API_KEY",
ELASTICSEARCH_CONNECTOR: "ELASTICSEARCH_API_KEY",
};
return fieldMap[connectorType] || "";
};
@ -233,7 +235,9 @@ export default function EditConnectorPage() {
? "GitHub Personal Access Token (PAT)"
: connector?.connector_type === "LINKUP_API"
? "Linkup API Key"
: "API Key"}
: connector?.connector_type === "ELASTICSEARCH_CONNECTOR"
? "Elasticsearch API Key"
: "API Key"}
</FormLabel>
<FormControl>
<Input
@ -247,7 +251,9 @@ export default function EditConnectorPage() {
? "Enter new GitHub PAT (optional)"
: connector?.connector_type === "LINKUP_API"
? "Enter new Linkup API Key (optional)"
: "Enter new API key (optional)"
: connector?.connector_type === "ELASTICSEARCH_CONNECTOR"
? "Enter new Elasticsearch API Key (optional)"
: "Enter new API key (optional)"
}
{...field}
/>
@ -261,7 +267,9 @@ export default function EditConnectorPage() {
? "Enter a new GitHub PAT or leave blank to keep your existing token."
: connector?.connector_type === "LINKUP_API"
? "Enter a new Linkup API Key or leave blank to keep your existing key."
: "Enter a new API key or leave blank to keep your existing key."}
: connector?.connector_type === "ELASTICSEARCH_CONNECTOR"
? "Enter a new Elasticsearch API Key or leave blank to keep your existing key."
: "Enter a new API key or leave blank to keep your existing key."}
</FormDescription>
<FormMessage />
</FormItem>

View file

@ -55,7 +55,7 @@ const elasticsearchConnectorFormSchema = z
auth_method: z.enum(["basic", "api_key"]).default("api_key"),
username: z.string().optional(),
password: z.string().optional(),
api_key: z.string().optional(),
ELASTICSEARCH_API_KEY: z.string().optional(),
indices: z.string().optional(),
query: z.string().default("*"),
search_fields: z.string().optional(),
@ -67,7 +67,7 @@ const elasticsearchConnectorFormSchema = z
return Boolean(data.username?.trim() && data.password?.trim());
}
if (data.auth_method === "api_key") {
return Boolean(data.api_key?.trim());
return Boolean(data.ELASTICSEARCH_API_KEY?.trim());
}
return true;
},
@ -100,7 +100,7 @@ export default function ElasticsearchConnectorPage() {
auth_method: "api_key",
username: "",
password: "",
api_key: "",
ELASTICSEARCH_API_KEY: "",
indices: "",
query: "*",
search_fields: "",
@ -137,7 +137,7 @@ export default function ElasticsearchConnectorPage() {
config.username = values.username;
config.password = values.password;
} else if (values.auth_method === "api_key") {
config.api_key = values.api_key;
config.ELASTICSEARCH_API_KEY = values.ELASTICSEARCH_API_KEY;
}
if (values.indices?.trim()) {
@ -156,7 +156,8 @@ export default function ElasticsearchConnectorPage() {
// Ensure the connector payload has the correct structure
const connectorPayload = {
name: values.name,
connector_type: "ELASTICSEARCH_CONNECTOR",
// connector_type: "ELASTICSEARCH_CONNECTOR",
connector_type: EnumConnectorName.ELASTICSEARCH_CONNECTOR,
is_indexable: true,
config,
};
@ -401,7 +402,7 @@ export default function ElasticsearchConnectorPage() {
{form.watch("auth_method") === "api_key" && (
<FormField
control={form.control}
name="api_key"
name="ELASTICSEARCH_API_KEY"
render={({ field }) => (
<FormItem>
<FormLabel>API Key</FormLabel>

View file

@ -44,5 +44,6 @@ export const editConnectorSchema = z.object({
GOOGLE_CALENDAR_REFRESH_TOKEN: z.string().optional(),
GOOGLE_CALENDAR_CALENDAR_IDS: z.string().optional(),
LUMA_API_KEY: z.string().optional(),
ELASTICSEARCH_API_KEY: z.string().optional(),
});
export type EditConnectorFormValues = z.infer<typeof editConnectorSchema>;

View file

@ -14,4 +14,5 @@ export enum EnumConnectorName {
GOOGLE_GMAIL_CONNECTOR = "GOOGLE_GMAIL_CONNECTOR",
AIRTABLE_CONNECTOR = "AIRTABLE_CONNECTOR",
LUMA_CONNECTOR = "LUMA_CONNECTOR",
ELASTICSEARCH_CONNECTOR = "ELASTICSEARCH_CONNECTOR",
}

View file

@ -53,6 +53,7 @@ export function useConnectorEditPage(connectorId: number, searchSpaceId: string)
JIRA_EMAIL: "",
JIRA_API_TOKEN: "",
LUMA_API_KEY: "",
ELASTICSEARCH_API_KEY: "",
},
});
@ -80,6 +81,7 @@ export function useConnectorEditPage(connectorId: number, searchSpaceId: string)
JIRA_EMAIL: config.JIRA_EMAIL || "",
JIRA_API_TOKEN: config.JIRA_API_TOKEN || "",
LUMA_API_KEY: config.LUMA_API_KEY || "",
ELASTICSEARCH_API_KEY: config.ELASTICSEARCH_API_KEY || "",
});
if (currentConnector.connector_type === "GITHUB_CONNECTOR") {
const savedRepos = config.repo_full_names || [];
@ -315,6 +317,16 @@ export function useConnectorEditPage(connectorId: number, searchSpaceId: string)
newConfig = { LUMA_API_KEY: formData.LUMA_API_KEY };
}
break;
case "ELASTICSEARCH_CONNECTOR":
if (formData.ELASTICSEARCH_API_KEY !== originalConfig.ELASTICSEARCH_API_KEY) {
if (!formData.ELASTICSEARCH_API_KEY) {
toast.error("Elasticsearch API Key cannot be empty.");
setIsSaving(false);
return;
}
newConfig = { ELASTICSEARCH_API_KEY: formData.ELASTICSEARCH_API_KEY };
}
break;
}
if (newConfig !== null) {
@ -379,6 +391,11 @@ export function useConnectorEditPage(connectorId: number, searchSpaceId: string)
editForm.setValue("JIRA_API_TOKEN", newlySavedConfig.JIRA_API_TOKEN || "");
} else if (connector.connector_type === "LUMA_CONNECTOR") {
editForm.setValue("LUMA_API_KEY", newlySavedConfig.LUMA_API_KEY || "");
} else if (connector.connector_type === "ELASTICSEARCH_CONNECTOR") {
editForm.setValue(
"ELASTICSEARCH_API_KEY",
newlySavedConfig.ELASTICSEARCH_API_KEY || ""
);
}
}
if (connector.connector_type === "GITHUB_CONNECTOR") {

View file

@ -35,7 +35,8 @@ export type DocumentType =
| "CLICKUP_CONNECTOR"
| "GOOGLE_CALENDAR_CONNECTOR"
| "GOOGLE_GMAIL_CONNECTOR"
| "LUMA_CONNECTOR";
| "LUMA_CONNECTOR"
| "ELASTICSEARCH_CONNECTOR";
export function useDocumentByChunk() {
const [document, setDocument] = useState<DocumentWithChunks | null>(null);

View file

@ -29,7 +29,8 @@ export type DocumentType =
| "GOOGLE_CALENDAR_CONNECTOR"
| "GOOGLE_GMAIL_CONNECTOR"
| "AIRTABLE_CONNECTOR"
| "LUMA_CONNECTOR";
| "LUMA_CONNECTOR"
| "ELASTICSEARCH_CONNECTOR";
export interface UseDocumentsOptions {
page?: number;

View file

@ -16,6 +16,7 @@ export const getConnectorTypeDisplay = (type: string): string => {
GOOGLE_GMAIL_CONNECTOR: "Google Gmail",
AIRTABLE_CONNECTOR: "Airtable",
LUMA_CONNECTOR: "Luma",
ELASTICSEARCH_CONNECTOR: "Elasticsearch",
};
return typeMap[type] || type;
};