OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
update connector card styles
Mike Fortmanaa2ee0e6a024
diff --git a/frontend/app/settings/_components/connector-card.tsx b/frontend/app/settings/_components/connector-card.tsxnew file mode 100644index 000000000..00bd6f999--- /dev/null+++ b/frontend/app/settings/_components/connector-card.tsx@@ -0,0 +1,160 @@+"use client";++import { Button } from "@/components/ui/button";+import {+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+} from "@/components/ui/card";+import { cn } from "@/lib/utils";+import { Loader2, Plus, RefreshCcw, Trash2 } from "lucide-react";+import Link from "next/link";++export interface Connector {+ id: string;+ name: string;+ type: string;+ icon: React.ReactNode;+ available?: boolean;+ status?: string;+ connectionId?: string;+}++interface ConnectorCardProps {+ connector: Connector;+ isConnecting: boolean;+ isDisconnecting: boolean;+ onConnect: (connector: Connector) => void;+ onDisconnect: (connector: Connector) => void;+ onNavigateToKnowledge: (connector: Connector) => void;+}++export default function ConnectorCard({+ connector,+ isConnecting,+ isDisconnecting,+ onConnect,+ onDisconnect,+ onNavigateToKnowledge,+}: ConnectorCardProps) {+ console.log(connector)+ const isConnected = connector?.name === "Google Drive" || connector?.status === "connected" && connector?.connectionId;++ return (+ <Card className="group relative flex flex-col hover:bg-secondary-hover hover:border-muted-foreground transition-colors">+ <CardHeader className="pb-2">+ <div className="flex flex-col items-start justify-between">+ <div className="flex flex-col gap-4 mb-2 w-full">+ <div className="flex items-center justify-between mb-1">+ <div+ className={cn(+ "w-8 h-8 rounded flex items-center justify-center border",+ connector?.available+ ? "bg-white"+ : "bg-muted grayscale",+ )}+ >+ {connector.icon}+ </div>+ {isConnected ? (+ <div className="flex items-center gap-1.5 rounded-full bg-foreground px-2.5 py-1 text-xs font-medium text-muted">+ <span className="h-2 w-2 rounded-full bg-green-500" />+ Active+ </div>+ ) : null}+ </div>+ <div>+ <CardTitle className="flex flex-row items-center">+ {connector.name}+ </CardTitle>+ <CardDescription className="text-sm">+ {connector?.available+ ? `${connector.name} is configured.`+ : "Not configured."}+ </CardDescription>+ </div>+ </div>+ </div>+ </CardHeader>+ <CardContent className="flex-1 flex flex-col justify-end space-y-4">+ {connector?.available ? (+ <div className="space-y-3">+ {isConnected ? (+ <div className="flex gap-2 overflow-hidden w-full">+ <Button+ variant="default"+ onClick={() => onNavigateToKnowledge(connector)}+ disabled={isDisconnecting || isConnecting}+ className="cursor-pointer !text-sm truncate rounded-md"+ size="md"+ >+ <Plus className="h-4 w-4" />+ <span className="text-mmd truncate">Add Knowledge</span>+ </Button>+ <Button+ variant="outline"+ onClick={() => onConnect(connector)}+ disabled={isConnecting || isDisconnecting}+ className="cursor-pointer"+ size="iconMd"+ >+ {isConnecting ? (+ <RefreshCcw className="h-4 w-4 animate-spin" />+ ) : (+ <RefreshCcw className="h-4 w-4" />+ )}+ </Button>+ <Button+ variant="outline"+ onClick={() => onDisconnect(connector)}+ disabled={isDisconnecting || isConnecting}+ className="cursor-pointer text-destructive hover:text-destructive"+ size="iconMd"+ >+ {isDisconnecting ? (+ <Loader2 className="h-4 w-4 animate-spin" />+ ) : (+ <Trash2 className="h-4 w-4" />+ )}+ </Button>+ </div>+ ) : (+ <Button+ onClick={() => onConnect(connector)}+ disabled={isConnecting}+ className="w-full cursor-pointer group-hover:bg-background group-hover:border-zinc-700 group-hover:text-primary"+ size="sm"+ >+ {isConnecting ? (+ <>+ <Loader2 className="h-4 w-4 animate-spin" />+ Connecting...+ </>+ ) : (+ <>Connect</>+ )}+ </Button>+ )}+ </div>+ ) : (+ <div className="text-sm text-muted-foreground">+ <p>+ See our{" "}+ <Link+ className="text-accent-pink-foreground"+ href="https://docs.openr.ag/knowledge#oauth-ingestion"+ target="_blank"+ rel="noopener noreferrer"+ >+ Cloud Connectors installation guide+ </Link>{" "}+ for more detail.+ </p>+ </div>+ )}+ </CardContent>+ </Card>+ );+}diff --git a/frontend/app/settings/_components/connector-cards.tsx b/frontend/app/settings/_components/connector-cards.tsxindex 9539b42ac..f52e5469e 100644--- a/frontend/app/settings/_components/connector-cards.tsx+++ b/frontend/app/settings/_components/connector-cards.tsx@@ -6,34 +6,12 @@ import { useGetConnectorsQuery, type Connector as QueryConnector } from "@/app/aimport GoogleDriveIcon from "@/components/icons/google-drive-logo";import OneDriveIcon from "@/components/icons/one-drive-logo";import SharePointIcon from "@/components/icons/share-point-logo";-import { Button } from "@/components/ui/button";-import {- Card,- CardContent,- CardDescription,- CardHeader,- CardTitle,-} from "@/components/ui/card";import { useAuth } from "@/contexts/auth-context";-import { cn } from "@/lib/utils";-import { Loader2, PlugZap, Plus, RefreshCcw, Trash2 } from "lucide-react";-import Link from "next/link";import { useRouter } from "next/navigation";-import { useCallback, useState } from "react";+import { useCallback } from "react";+import ConnectorCard, { type Connector } from "./connector-card";import ConnectorsSkeleton from "./connectors-skeleton";-interface SyncResult {- processed?: number;- added?: number;- errors?: number;- skipped?: number;- total?: number;-}--interface Connector extends Omit<QueryConnector, "icon"> {- icon: React.ReactNode;-}-export default function ConnectorCards() {const { isAuthenticated, isNoAuthMode } = useAuth();const router = useRouter();@@ -95,149 +73,21 @@ export default function ConnectorCards() {</>) : (connectors.map((connector) => (- <Card key={connector.id} className="relative flex flex-col">- <CardHeader className="pb-2">- <div className="flex flex-col items-start justify-between">- <div className="flex flex-col gap-3">- <div className="mb-1">- <div- className={cn(- "w-8 h-8 rounded flex items-center justify-center border",- connector?.available- ? "bg-white"- : "bg-muted grayscale",- )}- >- {connector.icon}- </div>- </div>- <CardTitle className="flex flex-row items-center gap-2">- {connector.name}- </CardTitle>- <CardDescription className="text-sm">- {connector?.available- ? `${connector.name} is configured.`- : "Not configured."}- </CardDescription>- </div>- </div>- </CardHeader>- <CardContent className="flex-1 flex flex-col justify-end space-y-4">- {connector?.available ? (- <div className="space-y-3">- {connector?.status === "connected" && connector?.connectionId ? (- <>- <div className="flex gap-2 overflow-hidden w-full">- <Button- variant="outline"- onClick={() => navigateToKnowledgePage(connector)}- disabled={- (disconnectMutation.isPending &&- (disconnectMutation.variables as any)?.type ===- connector.type) ||- (connectMutation.isPending &&- connectMutation.variables?.connector.id ===- connector.id)- }- className="cursor-pointer !text-sm truncate"- size="md"- >- <Plus className="h-4 w-4" />- <span className="text-mmd truncate">- Add Knowledge- </span>- </Button>- <Button- variant="outline"- onClick={() => handleConnect(connector)}- disabled={- (connectMutation.isPending &&- connectMutation.variables?.connector.id ===- connector.id) ||- (disconnectMutation.isPending &&- (disconnectMutation.variables as any)?.type ===- connector.type)- }- className="cursor-pointer"- size="iconMd"- >- {connectMutation.isPending &&- connectMutation.variables?.connector.id ===- connector.id ? (- <RefreshCcw className="h-4 w-4 animate-spin" />- ) : (- <RefreshCcw className="h-4 w-4" />- )}- </Button>- <Button- variant="outline"- onClick={() => handleDisconnect(connector)}- disabled={- (disconnectMutation.isPending &&- (disconnectMutation.variables as any)?.type ===- connector.type) ||- (connectMutation.isPending &&- connectMutation.variables?.connector.id ===- connector.id)- }- className="cursor-pointer text-destructive hover:text-destructive"- size="iconMd"- >- {disconnectMutation.isPending &&- (disconnectMutation.variables as any)?.type ===- connector.type ? (- <Loader2 className="h-4 w-4 animate-spin" />- ) : (- <Trash2 className="h-4 w-4" />- )}- </Button>- </div>- </>- ) : (- <Button- onClick={() => handleConnect(connector)}- disabled={- (connectMutation.isPending &&- connectMutation.variables?.connector.id ===- connector.id)- }- className="w-full cursor-pointer"- size="sm"- >- {(connectMutation.isPending &&- connectMutation.variables?.connector.id ===- connector.id) ? (- <>- <Loader2 className="h-4 w-4 animate-spin" />- Connecting...- </>- ) : (- <>- <PlugZap className="h-4 w-4" />- Connect- </>- )}- </Button>- )}- </div>- ) : (- <div className="text-sm text-muted-foreground">- <p>- See our{" "}- <Link- className="text-accent-pink-foreground"- href="https://docs.openr.ag/knowledge#oauth-ingestion"- target="_blank"- rel="noopener noreferrer"- >- Cloud Connectors installation guide- </Link>{" "}- for more detail.- </p>- </div>- )}- </CardContent>- </Card>+ <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}+ />)))}</div>