mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-29 19:35:20 +02:00
refactor: enhance connector card and status badge components
- Updated `ConnectorCard` to prioritize displaying status messages over indexed dates and warnings. - Modified `ConnectorStatusBadge` to use a span instead of a div for better inline flexibility. - Adjusted styles in `ConnectorAccountsListView` for improved layout and spacing. - Cleaned up example status messages in the configuration file for clarity.
This commit is contained in:
parent
924d18896a
commit
207595bb33
4 changed files with 19 additions and 21 deletions
|
|
@ -140,13 +140,14 @@ export const ConnectorCard: FC<ConnectorCardProps> = ({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show status message if available and connector is not connected
|
// Priority 1: Show status message if available (for both connected and disconnected connectors)
|
||||||
if (!isConnected && statusMessage) {
|
// This takes precedence over indexed dates and warnings
|
||||||
|
if (statusMessage) {
|
||||||
return <span className="text-[10px] text-muted-foreground">{statusMessage}</span>;
|
return <span className="text-[10px] text-muted-foreground">{statusMessage}</span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isConnected) {
|
if (isConnected) {
|
||||||
// Show last indexed date for connected connectors
|
// Show last indexed date for connected connectors (only if no status message)
|
||||||
if (lastIndexedAt) {
|
if (lastIndexedAt) {
|
||||||
return (
|
return (
|
||||||
<span className="whitespace-nowrap text-[10px]">
|
<span className="whitespace-nowrap text-[10px]">
|
||||||
|
|
@ -158,7 +159,7 @@ export const ConnectorCard: FC<ConnectorCardProps> = ({
|
||||||
return <span className="whitespace-nowrap text-[10px]">Never indexed</span>;
|
return <span className="whitespace-nowrap text-[10px]">Never indexed</span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show warning message if available and warnings are enabled
|
// Show warning message if available and warnings are enabled (only if no status message)
|
||||||
if (warning && showWarnings) {
|
if (warning && showWarnings) {
|
||||||
return <span className="text-[10px] text-yellow-600 dark:text-yellow-500">{warning}</span>;
|
return <span className="text-[10px] text-yellow-600 dark:text-yellow-500">{warning}</span>;
|
||||||
}
|
}
|
||||||
|
|
@ -196,10 +197,10 @@ export const ConnectorCard: FC<ConnectorCardProps> = ({
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-1.5">
|
||||||
<span className="text-[14px] font-semibold leading-tight truncate">{title}</span>
|
<span className="text-[14px] font-semibold leading-tight truncate">{title}</span>
|
||||||
{showWarnings && status.status !== "active" && (
|
{showWarnings && status.status !== "active" && (
|
||||||
<ConnectorStatusBadge status={status.status} />
|
<ConnectorStatusBadge status={status.status} className="flex-shrink-0" />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-[10px] text-muted-foreground mt-1">{getStatusContent()}</div>
|
<div className="text-[10px] text-muted-foreground mt-1">{getStatusContent()}</div>
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,11 @@ export const ConnectorStatusBadge: FC<ConnectorStatusBadgeProps> = ({ status, cl
|
||||||
const Icon = config.icon;
|
const Icon = config.icon;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<span
|
||||||
className={cn("flex items-center justify-center shrink-0", className)}
|
className={cn("inline-flex items-center justify-center shrink-0", className)}
|
||||||
title={config.title}
|
title={config.title}
|
||||||
>
|
>
|
||||||
<Icon className={cn("size-3.5", config.className)} />
|
<Icon className={cn("size-3.5", config.className)} />
|
||||||
</div>
|
</span>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -48,23 +48,20 @@ export type ConnectorStatusConfigFile = z.infer<typeof connectorStatusConfigFile
|
||||||
*/
|
*/
|
||||||
const rawConnectorStatusConfig = {
|
const rawConnectorStatusConfig = {
|
||||||
connectorStatuses: {
|
connectorStatuses: {
|
||||||
// Example: Disabled connector
|
|
||||||
// "SLACK_CONNECTOR": {
|
// "SLACK_CONNECTOR": {
|
||||||
// enabled: false,
|
// enabled: false,
|
||||||
// status: "disabled",
|
// status: "disabled",
|
||||||
// warning: null,
|
// warning: null,
|
||||||
// statusMessage: "Slack connector is currently unavailable due to API changes",
|
// statusMessage: "Unavailable due to API changes",
|
||||||
// disableReason: "maintenance",
|
// disableReason: "maintenance",
|
||||||
// },
|
// },
|
||||||
// Example: Connector with warning
|
|
||||||
// "NOTION_CONNECTOR": {
|
// "NOTION_CONNECTOR": {
|
||||||
// enabled: true,
|
// enabled: true,
|
||||||
// status: "warning",
|
// status: "warning",
|
||||||
// warning: "Rate limits may apply",
|
// warning: "Rate limits may apply",
|
||||||
// statusMessage: "Notion API rate limits are currently active. Some requests may be delayed.",
|
// statusMessage: "Some requests may be delayed due to Notion API rate limits",
|
||||||
// disableReason: null,
|
// disableReason: null,
|
||||||
// },
|
// },
|
||||||
// Example: Connector in maintenance
|
|
||||||
// "TEAMS_CONNECTOR": {
|
// "TEAMS_CONNECTOR": {
|
||||||
// enabled: false,
|
// enabled: false,
|
||||||
// status: "maintenance",
|
// status: "maintenance",
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ export const ConnectorAccountsListView: FC<ConnectorAccountsListViewProps> = ({
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-full">
|
<div className="flex flex-col h-full">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="px-6 sm:px-12 pt-8 sm:pt-10 pb-4 border-b border-border/50 bg-muted">
|
<div className="px-6 sm:px-12 pt-8 sm:pt-10 pb-1 sm:pb-4 border-b border-border/50 bg-muted">
|
||||||
{/* Back button */}
|
{/* Back button */}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|
@ -114,21 +114,21 @@ export const ConnectorAccountsListView: FC<ConnectorAccountsListViewProps> = ({
|
||||||
onClick={onAddAccount}
|
onClick={onAddAccount}
|
||||||
disabled={isConnecting || !isEnabled}
|
disabled={isConnecting || !isEnabled}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex items-center gap-2 px-3 py-2 rounded-lg border-2 border-dashed text-left transition-all duration-200 shrink-0 self-center sm:self-auto sm:w-auto",
|
"flex items-center gap-1.5 sm:gap-2 px-2 sm:px-3 py-1.5 sm:py-2 rounded-lg border-2 border-dashed text-left transition-all duration-200 shrink-0 self-center sm:self-auto sm:w-auto",
|
||||||
!isEnabled
|
!isEnabled
|
||||||
? "border-border/30 opacity-50 cursor-not-allowed"
|
? "border-border/30 opacity-50 cursor-not-allowed"
|
||||||
: "border-primary/50 hover:bg-primary/5",
|
: "border-primary/50 hover:bg-primary/5",
|
||||||
isConnecting && "opacity-50 cursor-not-allowed"
|
isConnecting && "opacity-50 cursor-not-allowed"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="flex h-6 w-6 items-center justify-center rounded-md bg-primary/10 shrink-0">
|
<div className="flex h-5 w-5 sm:h-6 sm:w-6 items-center justify-center rounded-md bg-primary/10 shrink-0">
|
||||||
{isConnecting ? (
|
{isConnecting ? (
|
||||||
<Loader2 className="size-3.5 animate-spin text-primary" />
|
<Loader2 className="size-3 sm:size-3.5 animate-spin text-primary" />
|
||||||
) : (
|
) : (
|
||||||
<Plus className="size-3.5 text-primary" />
|
<Plus className="size-3 sm:size-3.5 text-primary" />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<span className="text-[12px] font-medium">
|
<span className="text-[11px] sm:text-[12px] font-medium">
|
||||||
{isConnecting ? "Connecting..." : "Add Account"}
|
{isConnecting ? "Connecting..." : "Add Account"}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -136,7 +136,7 @@ export const ConnectorAccountsListView: FC<ConnectorAccountsListViewProps> = ({
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Content */}
|
{/* Content */}
|
||||||
<div className="flex-1 overflow-y-auto px-6 sm:px-12 py-6 sm:py-8">
|
<div className="flex-1 overflow-y-auto px-6 sm:px-12 pt-0 sm:pt-6 pb-6 sm:pb-8">
|
||||||
{/* Warning Banner */}
|
{/* Warning Banner */}
|
||||||
{warning && showWarnings && (
|
{warning && showWarnings && (
|
||||||
<ConnectorWarningBanner warning={warning} statusMessage={statusMessage} />
|
<ConnectorWarningBanner warning={warning} statusMessage={statusMessage} />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue