mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-04 21:32:39 +02:00
refactor: streamline connector status handling and remove warnings
- Removed the warning message handling from `useConnectorStatus` and related components to simplify status management. - Updated `ConnectorCard` and `ConnectorAccountsListView` to eliminate warning displays, focusing on status messages instead. - Adjusted the connector status configuration to remove warning properties, enhancing clarity and reducing complexity.
This commit is contained in:
parent
207595bb33
commit
b0043b6446
4 changed files with 18 additions and 51 deletions
|
|
@ -110,14 +110,12 @@ export const ConnectorCard: FC<ConnectorCardProps> = ({
|
|||
const {
|
||||
getConnectorStatus,
|
||||
isConnectorEnabled,
|
||||
getConnectorWarning,
|
||||
getConnectorStatusMessage,
|
||||
shouldShowWarnings,
|
||||
} = useConnectorStatus();
|
||||
|
||||
const status = getConnectorStatus(connectorType);
|
||||
const isEnabled = isConnectorEnabled(connectorType);
|
||||
const warning = getConnectorWarning(connectorType);
|
||||
const statusMessage = getConnectorStatusMessage(connectorType);
|
||||
const showWarnings = shouldShowWarnings();
|
||||
|
||||
|
|
@ -159,11 +157,6 @@ export const ConnectorCard: FC<ConnectorCardProps> = ({
|
|||
return <span className="whitespace-nowrap text-[10px]">Never indexed</span>;
|
||||
}
|
||||
|
||||
// Show warning message if available and warnings are enabled (only if no status message)
|
||||
if (warning && showWarnings) {
|
||||
return <span className="text-[10px] text-yellow-600 dark:text-yellow-500">{warning}</span>;
|
||||
}
|
||||
|
||||
return description;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* Connector Status Configuration
|
||||
*
|
||||
* This configuration allows managing connector statuses in the frontend without backend changes.
|
||||
* Statuses control warnings, disabling connectors, and displaying status messages.
|
||||
* This configuration allows managing connector statuses.
|
||||
* Statuses control disabling connectors and displaying status messages.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
|
|
@ -19,9 +19,7 @@ export const connectorStatusSchema = z.enum([
|
|||
export const connectorStatusConfigSchema = z.object({
|
||||
enabled: z.boolean(),
|
||||
status: connectorStatusSchema,
|
||||
warning: z.string().nullable().optional(),
|
||||
statusMessage: z.string().nullable().optional(),
|
||||
disableReason: z.string().nullable().optional(),
|
||||
});
|
||||
|
||||
export const connectorStatusMapSchema = z.record(z.string(), connectorStatusConfigSchema);
|
||||
|
|
@ -48,27 +46,21 @@ export type ConnectorStatusConfigFile = z.infer<typeof connectorStatusConfigFile
|
|||
*/
|
||||
const rawConnectorStatusConfig = {
|
||||
connectorStatuses: {
|
||||
// "SLACK_CONNECTOR": {
|
||||
// enabled: false,
|
||||
// status: "disabled",
|
||||
// warning: null,
|
||||
// statusMessage: "Unavailable due to API changes",
|
||||
// disableReason: "maintenance",
|
||||
// },
|
||||
// "NOTION_CONNECTOR": {
|
||||
// enabled: true,
|
||||
// status: "warning",
|
||||
// warning: "Rate limits may apply",
|
||||
// statusMessage: "Some requests may be delayed due to Notion API rate limits",
|
||||
// disableReason: null,
|
||||
// },
|
||||
// "TEAMS_CONNECTOR": {
|
||||
// enabled: false,
|
||||
// status: "maintenance",
|
||||
// warning: "Under maintenance",
|
||||
// statusMessage: "Temporarily unavailable for maintenance",
|
||||
// disableReason: "maintenance",
|
||||
// },
|
||||
"SLACK_CONNECTOR": {
|
||||
enabled: false,
|
||||
status: "disabled",
|
||||
statusMessage: "Unavailable due to API changes",
|
||||
},
|
||||
"NOTION_CONNECTOR": {
|
||||
enabled: true,
|
||||
status: "warning",
|
||||
statusMessage: "Rate limits may apply",
|
||||
},
|
||||
"TEAMS_CONNECTOR": {
|
||||
enabled: false,
|
||||
status: "maintenance",
|
||||
statusMessage: "Temporarily unavailable for maintenance",
|
||||
},
|
||||
},
|
||||
globalSettings: {
|
||||
showWarnings: true,
|
||||
|
|
@ -89,9 +81,7 @@ export function getDefaultConnectorStatus(): ConnectorStatusConfig {
|
|||
return connectorStatusConfigSchema.parse({
|
||||
enabled: true,
|
||||
status: "active",
|
||||
warning: null,
|
||||
statusMessage: null,
|
||||
disableReason: null,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,13 +29,6 @@ export function useConnectorStatus() {
|
|||
return getConnectorStatus(connectorType).enabled;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get warning message for a connector (if any)
|
||||
*/
|
||||
const getConnectorWarning = (connectorType: string | undefined): string | null => {
|
||||
return getConnectorStatus(connectorType).warning || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get status message for a connector
|
||||
*/
|
||||
|
|
@ -54,7 +47,6 @@ export function useConnectorStatus() {
|
|||
() => ({
|
||||
getConnectorStatus,
|
||||
isConnectorEnabled,
|
||||
getConnectorWarning,
|
||||
getConnectorStatusMessage,
|
||||
shouldShowWarnings,
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import type { LogActiveTask, LogSummary } from "@/contracts/types/log.types";
|
|||
import { cn } from "@/lib/utils";
|
||||
import { getConnectorDisplayName } from "../tabs/all-connectors-tab";
|
||||
import { useConnectorStatus } from "../hooks/use-connector-status";
|
||||
import { ConnectorWarningBanner } from "../components/connector-warning-banner";
|
||||
|
||||
interface ConnectorAccountsListViewProps {
|
||||
connectorType: string;
|
||||
|
|
@ -68,13 +67,10 @@ export const ConnectorAccountsListView: FC<ConnectorAccountsListViewProps> = ({
|
|||
isConnecting = false,
|
||||
}) => {
|
||||
// Get connector status
|
||||
const { isConnectorEnabled, getConnectorWarning, getConnectorStatusMessage, shouldShowWarnings } =
|
||||
useConnectorStatus();
|
||||
const { isConnectorEnabled, getConnectorStatusMessage } = useConnectorStatus();
|
||||
|
||||
const isEnabled = isConnectorEnabled(connectorType);
|
||||
const warning = getConnectorWarning(connectorType);
|
||||
const statusMessage = getConnectorStatusMessage(connectorType);
|
||||
const showWarnings = shouldShowWarnings();
|
||||
|
||||
// Filter connectors to only show those of this type
|
||||
const typeConnectors = connectors.filter((c) => c.connector_type === connectorType);
|
||||
|
|
@ -137,10 +133,6 @@ export const ConnectorAccountsListView: FC<ConnectorAccountsListViewProps> = ({
|
|||
|
||||
{/* Content */}
|
||||
<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 && showWarnings && (
|
||||
<ConnectorWarningBanner warning={warning} statusMessage={statusMessage} />
|
||||
)}
|
||||
{/* Connected Accounts Grid */}
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||
{typeConnectors.map((connector) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue