mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-02 22:01:05 +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 {
|
const {
|
||||||
getConnectorStatus,
|
getConnectorStatus,
|
||||||
isConnectorEnabled,
|
isConnectorEnabled,
|
||||||
getConnectorWarning,
|
|
||||||
getConnectorStatusMessage,
|
getConnectorStatusMessage,
|
||||||
shouldShowWarnings,
|
shouldShowWarnings,
|
||||||
} = useConnectorStatus();
|
} = useConnectorStatus();
|
||||||
|
|
||||||
const status = getConnectorStatus(connectorType);
|
const status = getConnectorStatus(connectorType);
|
||||||
const isEnabled = isConnectorEnabled(connectorType);
|
const isEnabled = isConnectorEnabled(connectorType);
|
||||||
const warning = getConnectorWarning(connectorType);
|
|
||||||
const statusMessage = getConnectorStatusMessage(connectorType);
|
const statusMessage = getConnectorStatusMessage(connectorType);
|
||||||
const showWarnings = shouldShowWarnings();
|
const showWarnings = shouldShowWarnings();
|
||||||
|
|
||||||
|
|
@ -159,11 +157,6 @@ 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 (only if no status message)
|
|
||||||
if (warning && showWarnings) {
|
|
||||||
return <span className="text-[10px] text-yellow-600 dark:text-yellow-500">{warning}</span>;
|
|
||||||
}
|
|
||||||
|
|
||||||
return description;
|
return description;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/**
|
/**
|
||||||
* Connector Status Configuration
|
* Connector Status Configuration
|
||||||
*
|
*
|
||||||
* This configuration allows managing connector statuses in the frontend without backend changes.
|
* This configuration allows managing connector statuses.
|
||||||
* Statuses control warnings, disabling connectors, and displaying status messages.
|
* Statuses control disabling connectors and displaying status messages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
@ -19,9 +19,7 @@ export const connectorStatusSchema = z.enum([
|
||||||
export const connectorStatusConfigSchema = z.object({
|
export const connectorStatusConfigSchema = z.object({
|
||||||
enabled: z.boolean(),
|
enabled: z.boolean(),
|
||||||
status: connectorStatusSchema,
|
status: connectorStatusSchema,
|
||||||
warning: z.string().nullable().optional(),
|
|
||||||
statusMessage: z.string().nullable().optional(),
|
statusMessage: z.string().nullable().optional(),
|
||||||
disableReason: z.string().nullable().optional(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const connectorStatusMapSchema = z.record(z.string(), connectorStatusConfigSchema);
|
export const connectorStatusMapSchema = z.record(z.string(), connectorStatusConfigSchema);
|
||||||
|
|
@ -48,27 +46,21 @@ export type ConnectorStatusConfigFile = z.infer<typeof connectorStatusConfigFile
|
||||||
*/
|
*/
|
||||||
const rawConnectorStatusConfig = {
|
const rawConnectorStatusConfig = {
|
||||||
connectorStatuses: {
|
connectorStatuses: {
|
||||||
// "SLACK_CONNECTOR": {
|
"SLACK_CONNECTOR": {
|
||||||
// enabled: false,
|
enabled: false,
|
||||||
// status: "disabled",
|
status: "disabled",
|
||||||
// warning: null,
|
statusMessage: "Unavailable due to API changes",
|
||||||
// statusMessage: "Unavailable due to API changes",
|
},
|
||||||
// disableReason: "maintenance",
|
"NOTION_CONNECTOR": {
|
||||||
// },
|
enabled: true,
|
||||||
// "NOTION_CONNECTOR": {
|
status: "warning",
|
||||||
// enabled: true,
|
statusMessage: "Rate limits may apply",
|
||||||
// status: "warning",
|
},
|
||||||
// warning: "Rate limits may apply",
|
"TEAMS_CONNECTOR": {
|
||||||
// statusMessage: "Some requests may be delayed due to Notion API rate limits",
|
enabled: false,
|
||||||
// disableReason: null,
|
status: "maintenance",
|
||||||
// },
|
statusMessage: "Temporarily unavailable for maintenance",
|
||||||
// "TEAMS_CONNECTOR": {
|
},
|
||||||
// enabled: false,
|
|
||||||
// status: "maintenance",
|
|
||||||
// warning: "Under maintenance",
|
|
||||||
// statusMessage: "Temporarily unavailable for maintenance",
|
|
||||||
// disableReason: "maintenance",
|
|
||||||
// },
|
|
||||||
},
|
},
|
||||||
globalSettings: {
|
globalSettings: {
|
||||||
showWarnings: true,
|
showWarnings: true,
|
||||||
|
|
@ -89,9 +81,7 @@ export function getDefaultConnectorStatus(): ConnectorStatusConfig {
|
||||||
return connectorStatusConfigSchema.parse({
|
return connectorStatusConfigSchema.parse({
|
||||||
enabled: true,
|
enabled: true,
|
||||||
status: "active",
|
status: "active",
|
||||||
warning: null,
|
|
||||||
statusMessage: null,
|
statusMessage: null,
|
||||||
disableReason: null,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,13 +29,6 @@ export function useConnectorStatus() {
|
||||||
return getConnectorStatus(connectorType).enabled;
|
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
|
* Get status message for a connector
|
||||||
*/
|
*/
|
||||||
|
|
@ -54,7 +47,6 @@ export function useConnectorStatus() {
|
||||||
() => ({
|
() => ({
|
||||||
getConnectorStatus,
|
getConnectorStatus,
|
||||||
isConnectorEnabled,
|
isConnectorEnabled,
|
||||||
getConnectorWarning,
|
|
||||||
getConnectorStatusMessage,
|
getConnectorStatusMessage,
|
||||||
shouldShowWarnings,
|
shouldShowWarnings,
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import type { LogActiveTask, LogSummary } from "@/contracts/types/log.types";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { getConnectorDisplayName } from "../tabs/all-connectors-tab";
|
import { getConnectorDisplayName } from "../tabs/all-connectors-tab";
|
||||||
import { useConnectorStatus } from "../hooks/use-connector-status";
|
import { useConnectorStatus } from "../hooks/use-connector-status";
|
||||||
import { ConnectorWarningBanner } from "../components/connector-warning-banner";
|
|
||||||
|
|
||||||
interface ConnectorAccountsListViewProps {
|
interface ConnectorAccountsListViewProps {
|
||||||
connectorType: string;
|
connectorType: string;
|
||||||
|
|
@ -68,13 +67,10 @@ export const ConnectorAccountsListView: FC<ConnectorAccountsListViewProps> = ({
|
||||||
isConnecting = false,
|
isConnecting = false,
|
||||||
}) => {
|
}) => {
|
||||||
// Get connector status
|
// Get connector status
|
||||||
const { isConnectorEnabled, getConnectorWarning, getConnectorStatusMessage, shouldShowWarnings } =
|
const { isConnectorEnabled, getConnectorStatusMessage } = useConnectorStatus();
|
||||||
useConnectorStatus();
|
|
||||||
|
|
||||||
const isEnabled = isConnectorEnabled(connectorType);
|
const isEnabled = isConnectorEnabled(connectorType);
|
||||||
const warning = getConnectorWarning(connectorType);
|
|
||||||
const statusMessage = getConnectorStatusMessage(connectorType);
|
const statusMessage = getConnectorStatusMessage(connectorType);
|
||||||
const showWarnings = shouldShowWarnings();
|
|
||||||
|
|
||||||
// Filter connectors to only show those of this type
|
// Filter connectors to only show those of this type
|
||||||
const typeConnectors = connectors.filter((c) => c.connector_type === connectorType);
|
const typeConnectors = connectors.filter((c) => c.connector_type === connectorType);
|
||||||
|
|
@ -137,10 +133,6 @@ export const ConnectorAccountsListView: FC<ConnectorAccountsListViewProps> = ({
|
||||||
|
|
||||||
{/* Content */}
|
{/* Content */}
|
||||||
<div className="flex-1 overflow-y-auto px-6 sm:px-12 pt-0 sm:pt-6 pb-6 sm:pb-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 && showWarnings && (
|
|
||||||
<ConnectorWarningBanner warning={warning} statusMessage={statusMessage} />
|
|
||||||
)}
|
|
||||||
{/* Connected Accounts Grid */}
|
{/* Connected Accounts Grid */}
|
||||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||||
{typeConnectors.map((connector) => {
|
{typeConnectors.map((connector) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue