OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
fix: issue 2043, revising connector cards display and ui for better user understanding. (#2105)
Richard Zhang0d0b67145a25
diff --git a/docker-compose.yml b/docker-compose.ymlindex 7d9cf6868..3fbdd9a66 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -243,4 +243,4 @@ services:volumes:opensearch-data:- azurite-data:+ azurite-data:\ No newline at end of filediff --git a/frontend/app/api/queries/useGetConnectorsQuery.ts b/frontend/app/api/queries/useGetConnectorsQuery.tsindex 18417f06b..152d37b40 100644--- a/frontend/app/api/queries/useGetConnectorsQuery.ts+++ b/frontend/app/api/queries/useGetConnectorsQuery.ts@@ -133,7 +133,7 @@ export interface Connector {name: string;description: string;icon: string; // The icon name from the API- status: "not_connected" | "connected" | "error";+ status: "not_connected" | "configured" | "connected" | "error";type: string;connectionId?: string;clientId?: string;@@ -141,6 +141,7 @@ export interface Connector {access_token?: string;selectedFiles?: GoogleDriveFile[] | OneDriveFile[];available?: boolean;+ requiresOAuth?: boolean;}interface Connection {@@ -189,6 +190,11 @@ export const useGetConnectorsQuery = (let status: Connector["status"] = "not_connected";let connectionId: string | undefined;+ // Determine if this connector requires OAuth based on connector kind+ // "oauth" connectors require OAuth flow (Google Drive, OneDrive, SharePoint)+ // "bucket" connectors use credential-based auth (Azure Blob, S3, IBM COS)+ const requiresOAuth = connectorData.kind === "oauth";+if (statusResponse.ok) {const statusData = await statusResponse.json();const connections = statusData.connections || [];@@ -210,8 +216,14 @@ export const useGetConnectorsQuery = (clientId: activeConnection.client_id,baseUrl: activeConnection.base_url,available: connectorData.available,+ requiresOAuth,} as Connector;}++ // For OAuth connectors: check if credentials are configured in .env+ if (requiresOAuth && statusData.has_env_credentials) {+ status = "configured";+ }}return {@@ -223,6 +235,7 @@ export const useGetConnectorsQuery = (type,connectionId,available: connectorData.available,+ requiresOAuth,} as Connector;}),);diff --git a/frontend/app/settings/_components/connector-card.tsx b/frontend/app/settings/_components/connector-card.tsxindex 0584aae0b..7f97f7352 100644--- a/frontend/app/settings/_components/connector-card.tsx+++ b/frontend/app/settings/_components/connector-card.tsx@@ -24,6 +24,7 @@ export interface Connector {available?: boolean;status?: string;connectionId?: string;+ requiresOAuth?: boolean;}interface ConnectorCardProps {@@ -56,6 +57,7 @@ export default function ConnectorCard({const canUpload = can("knowledge:upload");const isConnected =connector.status === "connected" && connector.connectionId;+ const isConfigured = connector.status === "configured";return (<Card@@ -102,9 +104,13 @@ export default function ConnectorCard({isCloudBrand && "!text-layer-contextual-foreground",)}>- {isConnected || connector?.available- ? `${connector.name} is configured.`- : "Allowed for this workspace — OAuth credentials not configured yet."}+ {isConnected+ ? `${connector.name} is connected.`+ : isConfigured+ ? `${connector.name} is configured.`+ : connector?.available && !connector.requiresOAuth+ ? `${connector.name} is available to connect.`+ : "Allowed for this workspace — OAuth credentials not configured yet."}</CardDescription></div></div>diff --git a/frontend/app/settings/_components/connector-cards.tsx b/frontend/app/settings/_components/connector-cards.tsxindex d0896694c..3084fc202 100644--- a/frontend/app/settings/_components/connector-cards.tsx+++ b/frontend/app/settings/_components/connector-cards.tsx@@ -50,10 +50,17 @@ export default function ConnectorCards() {return <Icon />;}, []);- const connectors = queryConnectors.map((c) => ({- ...c,- icon: getConnectorIcon(c.type),- })) as Connector[];+ const connectors = queryConnectors.reduce<Connector[]>((acc, c) => {+ // Keep OAuth connectors regardless of availability+ // Only hide credential-based connectors when unavailable+ if (c.requiresOAuth || c.available !== false) {+ acc.push({+ ...c,+ icon: getConnectorIcon(c.type),+ } as Connector);+ }+ return acc;+ }, []);const handleConnect = async (connector: Connector) => {connectMutation.mutate({@@ -94,36 +101,82 @@ export default function ConnectorCards() {(d) => d.SettingsDialog,);+ // Split connectors into OAuth and credential-based+ const oauthConnectors = connectors.filter((c) => c.requiresOAuth);+ const credentialConnectors = connectors.filter((c) => !c.requiresOAuth);+return (<>- <div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">- {connectorsLoading ? (- <>- <ConnectorsSkeleton />- <ConnectorsSkeleton />- <ConnectorsSkeleton />- </>- ) : (- connectors.map((connector) => (- <ConnectorCard- key={connector.id}- connector={connector}- isConnecting={- connectMutation.isPending &&- connectMutation.variables?.connector.id === connector.id- }- isDisconnecting={- disconnectMutation.isPending &&- (disconnectMutation.variables as any)?.type === connector.type- }- onConnect={handleConnect}- onDisconnect={handleDisconnect}- onNavigateToKnowledge={navigateToKnowledgePage}- onConfigure={getConfigureHandler(connector)}- />- ))- )}- </div>+ {/* OAuth Connectors Section */}+ {(connectorsLoading || oauthConnectors.length > 0) && (+ <div className="space-y-4">+ <h3 className="text-lg font-semibold">OAuth Connectors</h3>+ <div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">+ {connectorsLoading ? (+ <>+ <ConnectorsSkeleton />+ <ConnectorsSkeleton />+ <ConnectorsSkeleton />+ </>+ ) : (+ oauthConnectors.map((connector) => (+ <ConnectorCard+ key={connector.id}+ connector={connector}+ isConnecting={+ connectMutation.isPending &&+ connectMutation.variables?.connector.id === connector.id+ }+ isDisconnecting={+ disconnectMutation.isPending &&+ (disconnectMutation.variables as any)?.type ===+ connector.type+ }+ onConnect={handleConnect}+ onDisconnect={handleDisconnect}+ onNavigateToKnowledge={navigateToKnowledgePage}+ onConfigure={getConfigureHandler(connector)}+ />+ ))+ )}+ </div>+ </div>+ )}++ {/* Credential-Based Connectors Section */}+ {(connectorsLoading || credentialConnectors.length > 0) && (+ <div className="space-y-4">+ <h3 className="text-lg font-semibold">Credential-Based Connectors</h3>+ <div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">+ {connectorsLoading ? (+ <>+ <ConnectorsSkeleton />+ <ConnectorsSkeleton />+ </>+ ) : (+ credentialConnectors.map((connector) => (+ <ConnectorCard+ key={connector.id}+ connector={connector}+ isConnecting={+ connectMutation.isPending &&+ connectMutation.variables?.connector.id === connector.id+ }+ isDisconnecting={+ disconnectMutation.isPending &&+ (disconnectMutation.variables as any)?.type ===+ connector.type+ }+ onConnect={handleConnect}+ onDisconnect={handleDisconnect}+ onNavigateToKnowledge={navigateToKnowledgePage}+ onConfigure={getConfigureHandler(connector)}+ />+ ))+ )}+ </div>+ </div>+ )}{dialogDescriptors.map((descriptor) => {// Render only while open so the component unmounts on close, whichdiff --git a/src/api/connectors.py b/src/api/connectors.pyindex 79b1377b8..7251537a3 100644--- a/src/api/connectors.py+++ b/src/api/connectors.py@@ -1406,11 +1406,15 @@ async def connector_status(# Only count connections that are both active AND actually authenticatedhas_authenticated_connection = len(verified_active_connections) > 0+ # Check if OAuth credentials are configured in environment (for OAuth connectors only)+ has_env_credentials = connector_service.connection_manager.has_env_credentials(connector_type)+return JSONResponse({"connector_type": connector_type,"authenticated": has_authenticated_connection,"status": "connected" if has_authenticated_connection else "not_connected",+ "has_env_credentials": has_env_credentials,"connections": [{"connection_id": conn.connection_id,diff --git a/src/connectors/connection_manager.py b/src/connectors/connection_manager.pyindex 31ec577a5..8e95e73db 100644--- a/src/connectors/connection_manager.py+++ b/src/connectors/connection_manager.py@@ -476,6 +476,7 @@ class ConnectionManager:"description": cls.CONNECTOR_DESCRIPTION,"icon": cls.CONNECTOR_ICON,"available": cls.is_available(self, user_id),+ "kind": cls.CONNECTOR_KIND,}return result@@ -511,6 +512,24 @@ class ConnectionManager:continuereturn False+ def has_env_credentials(self, connector_type: str) -> bool:+ """Check if OAuth connector has credentials configured in environment.++ Returns True if the connector is OAuth-based and has valid environment+ credentials (CLIENT_ID and CLIENT_SECRET), False otherwise.+ """+ try:+ connector_cls = get_connector_class(connector_type)+ if not connector_cls or connector_cls.CONNECTOR_KIND != "oauth":+ return False+ # Try to instantiate and check for credentials+ test_connector = connector_cls({})+ test_connector.get_client_id()+ test_connector.get_client_secret()+ return True+ except Exception:+ return False+def _create_connector(self, config: ConnectionConfig) -> BaseConnector:"""Factory method to create connector instances via the registry."""try: