mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-20 23:21:06 +02:00
refactor: reorganize connector tab layout and improve component logic
- Swapped the sections for "Content Sources" and "More Integrations" in the AllConnectorsTab for better clarity. - Streamlined the mapping logic for filtered connectors and crawlers, enhancing readability and maintainability. - Updated the AppSidebar to replace the workspace switch icon for improved visual consistency. - Modified the submit button text in the localization file for better clarity in user actions.
This commit is contained in:
parent
3227c6c043
commit
afe4254f74
3 changed files with 60 additions and 94 deletions
|
|
@ -3,8 +3,8 @@
|
||||||
import type { FC } from "react";
|
import type { FC } from "react";
|
||||||
import type { SearchSourceConnector } from "@/contracts/types/connector.types";
|
import type { SearchSourceConnector } from "@/contracts/types/connector.types";
|
||||||
import type { LogActiveTask, LogSummary } from "@/contracts/types/log.types";
|
import type { LogActiveTask, LogSummary } from "@/contracts/types/log.types";
|
||||||
import { OAUTH_CONNECTORS, CRAWLERS, OTHER_CONNECTORS } from "../constants/connector-constants";
|
|
||||||
import { ConnectorCard } from "../components/connector-card";
|
import { ConnectorCard } from "../components/connector-card";
|
||||||
|
import { CRAWLERS, OAUTH_CONNECTORS, OTHER_CONNECTORS } from "../constants/connector-constants";
|
||||||
import { getDocumentCountForConnector } from "../utils/connector-document-mapping";
|
import { getDocumentCountForConnector } from "../utils/connector-document-mapping";
|
||||||
|
|
||||||
interface AllConnectorsTabProps {
|
interface AllConnectorsTabProps {
|
||||||
|
|
@ -118,6 +118,62 @@ export const AllConnectorsTab: FC<AllConnectorsTabProps> = ({
|
||||||
</section>
|
</section>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* More Integrations */}
|
||||||
|
{filteredOther.length > 0 && (
|
||||||
|
<section>
|
||||||
|
<div className="flex items-center gap-2 mb-4">
|
||||||
|
<h3 className="text-sm font-semibold text-muted-foreground">More Integrations</h3>
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||||
|
{filteredOther.map((connector) => {
|
||||||
|
const isConnected = connectedTypes.has(connector.connectorType);
|
||||||
|
const isConnecting = connectingId === connector.id;
|
||||||
|
|
||||||
|
// Find the actual connector object if connected
|
||||||
|
const actualConnector =
|
||||||
|
isConnected && allConnectors
|
||||||
|
? allConnectors.find(
|
||||||
|
(c: SearchSourceConnector) => c.connector_type === connector.connectorType
|
||||||
|
)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
const documentCount = getDocumentCountForConnector(
|
||||||
|
connector.connectorType,
|
||||||
|
documentTypeCounts
|
||||||
|
);
|
||||||
|
const isIndexing = actualConnector && indexingConnectorIds?.has(actualConnector.id);
|
||||||
|
const activeTask = actualConnector
|
||||||
|
? getActiveTaskForConnector(actualConnector.id)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
const handleConnect = onConnectNonOAuth
|
||||||
|
? () => onConnectNonOAuth(connector.connectorType)
|
||||||
|
: () => {}; // Fallback - connector popup should handle all connector types
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ConnectorCard
|
||||||
|
key={connector.id}
|
||||||
|
id={connector.id}
|
||||||
|
title={connector.title}
|
||||||
|
description={connector.description}
|
||||||
|
connectorType={connector.connectorType}
|
||||||
|
isConnected={isConnected}
|
||||||
|
isConnecting={isConnecting}
|
||||||
|
documentCount={documentCount}
|
||||||
|
lastIndexedAt={actualConnector?.last_indexed_at}
|
||||||
|
isIndexing={isIndexing}
|
||||||
|
activeTask={activeTask}
|
||||||
|
onConnect={handleConnect}
|
||||||
|
onManage={
|
||||||
|
actualConnector && onManage ? () => onManage(actualConnector) : undefined
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Content Sources */}
|
{/* Content Sources */}
|
||||||
{filteredCrawlers.length > 0 && (
|
{filteredCrawlers.length > 0 && (
|
||||||
<section>
|
<section>
|
||||||
|
|
@ -187,97 +243,6 @@ export const AllConnectorsTab: FC<AllConnectorsTabProps> = ({
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* More Integrations */}
|
|
||||||
{filteredOther.length > 0 && (
|
|
||||||
<section>
|
|
||||||
<div className="flex items-center gap-2 mb-4">
|
|
||||||
<h3 className="text-sm font-semibold text-muted-foreground">More Integrations</h3>
|
|
||||||
</div>
|
|
||||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
|
||||||
{filteredOther.map((connector) => {
|
|
||||||
// Special handling for connectors that can be created in popup
|
|
||||||
const isTavily = connector.id === "tavily-api";
|
|
||||||
const isSearxng = connector.id === "searxng";
|
|
||||||
const isLinkup = connector.id === "linkup-api";
|
|
||||||
const isBaidu = connector.id === "baidu-search-api";
|
|
||||||
const isLinear = connector.id === "linear-connector";
|
|
||||||
const isElasticsearch = connector.id === "elasticsearch-connector";
|
|
||||||
const isSlack = connector.id === "slack-connector";
|
|
||||||
const isDiscord = connector.id === "discord-connector";
|
|
||||||
const isNotion = connector.id === "notion-connector";
|
|
||||||
const isConfluence = connector.id === "confluence-connector";
|
|
||||||
const isBookStack = connector.id === "bookstack-connector";
|
|
||||||
const isGithub = connector.id === "github-connector";
|
|
||||||
const isJira = connector.id === "jira-connector";
|
|
||||||
const isClickUp = connector.id === "clickup-connector";
|
|
||||||
const isLuma = connector.id === "luma-connector";
|
|
||||||
const isCircleback = connector.id === "circleback-connector";
|
|
||||||
|
|
||||||
const isConnected = connectedTypes.has(connector.connectorType);
|
|
||||||
const isConnecting = connectingId === connector.id;
|
|
||||||
|
|
||||||
// Find the actual connector object if connected
|
|
||||||
const actualConnector =
|
|
||||||
isConnected && allConnectors
|
|
||||||
? allConnectors.find(
|
|
||||||
(c: SearchSourceConnector) => c.connector_type === connector.connectorType
|
|
||||||
)
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const documentCount = getDocumentCountForConnector(
|
|
||||||
connector.connectorType,
|
|
||||||
documentTypeCounts
|
|
||||||
);
|
|
||||||
const isIndexing = actualConnector && indexingConnectorIds?.has(actualConnector.id);
|
|
||||||
const activeTask = actualConnector
|
|
||||||
? getActiveTaskForConnector(actualConnector.id)
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const handleConnect =
|
|
||||||
(isTavily ||
|
|
||||||
isSearxng ||
|
|
||||||
isLinkup ||
|
|
||||||
isBaidu ||
|
|
||||||
isLinear ||
|
|
||||||
isElasticsearch ||
|
|
||||||
isSlack ||
|
|
||||||
isDiscord ||
|
|
||||||
isNotion ||
|
|
||||||
isConfluence ||
|
|
||||||
isBookStack ||
|
|
||||||
isGithub ||
|
|
||||||
isJira ||
|
|
||||||
isClickUp ||
|
|
||||||
isLuma ||
|
|
||||||
isCircleback) &&
|
|
||||||
onConnectNonOAuth
|
|
||||||
? () => onConnectNonOAuth(connector.connectorType)
|
|
||||||
: () => {}; // Fallback - connector popup should handle all connector types
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ConnectorCard
|
|
||||||
key={connector.id}
|
|
||||||
id={connector.id}
|
|
||||||
title={connector.title}
|
|
||||||
description={connector.description}
|
|
||||||
connectorType={connector.connectorType}
|
|
||||||
isConnected={isConnected}
|
|
||||||
isConnecting={isConnecting}
|
|
||||||
documentCount={documentCount}
|
|
||||||
lastIndexedAt={actualConnector?.last_indexed_at}
|
|
||||||
isIndexing={isIndexing}
|
|
||||||
activeTask={activeTask}
|
|
||||||
onConnect={handleConnect}
|
|
||||||
onManage={
|
|
||||||
actualConnector && onManage ? () => onManage(actualConnector) : undefined
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
import { useAtomValue } from "jotai";
|
import { useAtomValue } from "jotai";
|
||||||
import {
|
import {
|
||||||
AlertCircle,
|
AlertCircle,
|
||||||
|
ArrowLeftRight,
|
||||||
BookOpen,
|
BookOpen,
|
||||||
Cable,
|
Cable,
|
||||||
ChevronsUpDown,
|
ChevronsUpDown,
|
||||||
|
|
@ -417,7 +418,7 @@ export const AppSidebar = memo(function AppSidebar({
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<DropdownMenuItem onClick={() => router.push("/dashboard")}>
|
<DropdownMenuItem onClick={() => router.push("/dashboard")}>
|
||||||
<SquareLibrary className="mr-2 h-4 w-4" />
|
<ArrowLeftRight className="mr-2 h-4 w-4" />
|
||||||
Switch workspace
|
Switch workspace
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenuGroup>
|
</DropdownMenuGroup>
|
||||||
|
|
|
||||||
|
|
@ -374,7 +374,7 @@
|
||||||
"tip_4": "Processing may take some time depending on video length",
|
"tip_4": "Processing may take some time depending on video length",
|
||||||
"preview": "Preview",
|
"preview": "Preview",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"submit": "Submit YouTube Videos",
|
"submit": "Add",
|
||||||
"processing": "Processing...",
|
"processing": "Processing...",
|
||||||
"error_no_video": "Please add at least one YouTube video URL",
|
"error_no_video": "Please add at least one YouTube video URL",
|
||||||
"error_invalid_urls": "Invalid YouTube URLs detected: {urls}",
|
"error_invalid_urls": "Invalid YouTube URLs detected: {urls}",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue