diff --git a/surfsense_web/app/dashboard/[search_space_id]/connectors/[connector_id]/edit/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/connectors/[connector_id]/edit/page.tsx deleted file mode 100644 index 4c7bb3a3a..000000000 --- a/surfsense_web/app/dashboard/[search_space_id]/connectors/[connector_id]/edit/page.tsx +++ /dev/null @@ -1,336 +0,0 @@ -"use client"; - -import { ArrowLeft, Check, Loader2 } from "lucide-react"; -import { motion } from "motion/react"; -import { useParams, useRouter } from "next/navigation"; -import { useEffect } from "react"; -import { toast } from "sonner"; -import { EditConnectorLoadingSkeleton } from "@/components/editConnector/EditConnectorLoadingSkeleton"; -import { EditConnectorNameForm } from "@/components/editConnector/EditConnectorNameForm"; -import { EditGitHubConnectorConfig } from "@/components/editConnector/EditGitHubConnectorConfig"; -import { EditSimpleTokenForm } from "@/components/editConnector/EditSimpleTokenForm"; -import { Button } from "@/components/ui/button"; -import { - Card, - CardContent, - CardDescription, - CardFooter, - CardHeader, - CardTitle, -} from "@/components/ui/card"; -import { - Form, - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form"; -import { Textarea } from "@/components/ui/textarea"; -import { getConnectorIcon } from "@/contracts/enums/connectorIcons"; -import { useConnectorEditPage } from "@/hooks/use-connector-edit-page"; -// Import Utils, Types, Hook, and Components -import { getConnectorTypeDisplay } from "@/lib/connectors/utils"; - -export default function EditConnectorPage() { - const router = useRouter(); - const params = useParams(); - const searchSpaceId = params.search_space_id as string; - // Ensure connectorId is parsed safely - const connectorIdParam = params.connector_id as string; - const connectorId = connectorIdParam ? parseInt(connectorIdParam, 10) : NaN; - - // Use the custom hook to manage state and logic - const { - connectorsLoading, - connector, - isSaving, - editForm, - patForm, // Needed for GitHub child component - handleSaveChanges, - // GitHub specific props for the child component - editMode, - setEditMode, // Pass down if needed by GitHub component - originalPat, - currentSelectedRepos, - fetchedRepos, - setFetchedRepos, - newSelectedRepos, - setNewSelectedRepos, - isFetchingRepos, - handleFetchRepositories, - handleRepoSelectionChange, - } = useConnectorEditPage(connectorId, searchSpaceId); - - // Redirect if connectorId is not a valid number after parsing - useEffect(() => { - if (Number.isNaN(connectorId)) { - toast.error("Invalid Connector ID."); - router.push(`/dashboard/${searchSpaceId}/connectors`); - } - }, [connectorId, router, searchSpaceId]); - - // Loading State - if (connectorsLoading || !connector) { - // Handle NaN case before showing skeleton - if (Number.isNaN(connectorId)) return null; - return ; - } - - // Main Render using data/handlers from the hook - return ( -
- - - - - - - {getConnectorIcon(connector.connector_type)} - Edit {getConnectorTypeDisplay(connector.connector_type)} Connector - - Modify connector name and configuration. - - -
- {/* Pass hook's handleSaveChanges */} - - - {/* Pass form control from hook */} - - -
- -

Configuration

- - {/* == GitHub == */} - {connector.connector_type === "GITHUB_CONNECTOR" && ( - - )} - - {/* == Slack == */} - {connector.connector_type === "SLACK_CONNECTOR" && ( - - )} - {/* == Notion == */} - {connector.connector_type === "NOTION_CONNECTOR" && ( - - )} - {/* == Tavily == */} - {connector.connector_type === "TAVILY_API" && ( - - )} - - {/* == Linear == */} - {connector.connector_type === "LINEAR_CONNECTOR" && ( - - )} - - {/* == Jira == */} - {connector.connector_type === "JIRA_CONNECTOR" && ( -
- - - -
- )} - - {/* == Confluence == */} - {connector.connector_type === "CONFLUENCE_CONNECTOR" && ( -
- - - -
- )} - - {/* == ClickUp == */} - {connector.connector_type === "CLICKUP_CONNECTOR" && ( - - )} - - {/* == Linkup == */} - {connector.connector_type === "LINKUP_API" && ( - - )} - - {/* == Discord == */} - {connector.connector_type === "DISCORD_CONNECTOR" && ( - - )} - - {/* == Luma == */} - {connector.connector_type === "LUMA_CONNECTOR" && ( - - )} - - {/* == Elasticsearch == */} - {connector.connector_type === "ELASTICSEARCH_CONNECTOR" && ( - - )} - - {/* == Webcrawler == */} - {connector.connector_type === "WEBCRAWLER_CONNECTOR" && ( -
- - ( - - URLs to Crawl - -