mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-25 19:15:18 +02:00
refactor: Enhance connector form submission and tooltip styling
- Updated the handleSubmitConnectForm function to accept an additional parameter for indexing start notification, improving the connector form submission process. - Adjusted tooltip styling across various components for consistency and improved visual clarity. - Simplified conditional rendering in ActiveConnectorsTab and ConnectorAccountsListView to enhance UI responsiveness during indexing operations.
This commit is contained in:
parent
0e0aec13f3
commit
34230bdb84
6 changed files with 33 additions and 26 deletions
|
|
@ -191,7 +191,7 @@ export const ConnectorIndicator: FC = () => {
|
||||||
) : connectingConnectorType ? (
|
) : connectingConnectorType ? (
|
||||||
<ConnectorConnectView
|
<ConnectorConnectView
|
||||||
connectorType={connectingConnectorType}
|
connectorType={connectingConnectorType}
|
||||||
onSubmit={handleSubmitConnectForm}
|
onSubmit={(formData) => handleSubmitConnectForm(formData, startIndexing)}
|
||||||
onBack={handleBackFromConnect}
|
onBack={handleBackFromConnect}
|
||||||
isSubmitting={isCreatingConnector}
|
isSubmitting={isCreatingConnector}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -491,20 +491,23 @@ export const useConnectorDialog = () => {
|
||||||
|
|
||||||
// Handle submitting connect form
|
// Handle submitting connect form
|
||||||
const handleSubmitConnectForm = useCallback(
|
const handleSubmitConnectForm = useCallback(
|
||||||
async (formData: {
|
async (
|
||||||
name: string;
|
formData: {
|
||||||
connector_type: string;
|
name: string;
|
||||||
config: Record<string, unknown>;
|
connector_type: string;
|
||||||
is_indexable: boolean;
|
config: Record<string, unknown>;
|
||||||
last_indexed_at: null;
|
is_indexable: boolean;
|
||||||
periodic_indexing_enabled: boolean;
|
last_indexed_at: null;
|
||||||
indexing_frequency_minutes: number | null;
|
periodic_indexing_enabled: boolean;
|
||||||
next_scheduled_at: null;
|
indexing_frequency_minutes: number | null;
|
||||||
startDate?: Date;
|
next_scheduled_at: null;
|
||||||
endDate?: Date;
|
startDate?: Date;
|
||||||
periodicEnabled?: boolean;
|
endDate?: Date;
|
||||||
frequencyMinutes?: string;
|
periodicEnabled?: boolean;
|
||||||
}) => {
|
frequencyMinutes?: string;
|
||||||
|
},
|
||||||
|
onIndexingStart?: (connectorId: number) => void
|
||||||
|
) => {
|
||||||
if (!searchSpaceId || !connectingConnectorType) return;
|
if (!searchSpaceId || !connectingConnectorType) return;
|
||||||
|
|
||||||
// Prevent multiple submissions using ref for immediate check
|
// Prevent multiple submissions using ref for immediate check
|
||||||
|
|
@ -603,6 +606,11 @@ export const useConnectorDialog = () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notify caller that indexing is starting (for UI syncing state)
|
||||||
|
if (onIndexingStart) {
|
||||||
|
onIndexingStart(connector.id);
|
||||||
|
}
|
||||||
|
|
||||||
// Start indexing (backend will use defaults if dates are undefined)
|
// Start indexing (backend will use defaults if dates are undefined)
|
||||||
const startDateStr = startDateForIndexing
|
const startDateStr = startDateForIndexing
|
||||||
? format(startDateForIndexing, "yyyy-MM-dd")
|
? format(startDateForIndexing, "yyyy-MM-dd")
|
||||||
|
|
|
||||||
|
|
@ -174,10 +174,10 @@ export const ActiveConnectorsTab: FC<ActiveConnectorsTabProps> = ({
|
||||||
<div
|
<div
|
||||||
key={`oauth-type-${connectorType}`}
|
key={`oauth-type-${connectorType}`}
|
||||||
className={cn(
|
className={cn(
|
||||||
"relative flex items-center gap-4 p-4 rounded-xl border border-border transition-all",
|
"relative flex items-center gap-4 p-4 rounded-xl transition-all",
|
||||||
isAnyIndexing
|
isAnyIndexing
|
||||||
? "bg-primary/5 border-primary/20"
|
? "bg-primary/5 border-0"
|
||||||
: "bg-slate-400/5 dark:bg-white/5 hover:bg-slate-400/10 dark:hover:bg-white/10"
|
: "bg-slate-400/5 dark:bg-white/5 hover:bg-slate-400/10 dark:hover:bg-white/10 border border-border"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|
@ -231,10 +231,10 @@ export const ActiveConnectorsTab: FC<ActiveConnectorsTabProps> = ({
|
||||||
<div
|
<div
|
||||||
key={`connector-${connector.id}`}
|
key={`connector-${connector.id}`}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex items-center gap-4 p-4 rounded-xl border border-border transition-all",
|
"flex items-center gap-4 p-4 rounded-xl transition-all",
|
||||||
isIndexing
|
isIndexing
|
||||||
? "bg-primary/5 border-primary/20"
|
? "bg-primary/5 border-0"
|
||||||
: "bg-slate-400/5 dark:bg-white/5 hover:bg-slate-400/10 dark:hover:bg-white/10"
|
: "bg-slate-400/5 dark:bg-white/5 hover:bg-slate-400/10 dark:hover:bg-white/10 border border-border"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -139,10 +139,10 @@ export const ConnectorAccountsListView: FC<ConnectorAccountsListViewProps> = ({
|
||||||
<div
|
<div
|
||||||
key={connector.id}
|
key={connector.id}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex items-center gap-4 p-4 rounded-xl border border-border transition-all",
|
"flex items-center gap-4 p-4 rounded-xl transition-all",
|
||||||
isIndexing
|
isIndexing
|
||||||
? "bg-primary/5 border-primary/20"
|
? "bg-primary/5 border-0"
|
||||||
: "bg-slate-400/5 dark:bg-white/5 hover:bg-slate-400/10 dark:hover:bg-white/10"
|
: "bg-slate-400/5 dark:bg-white/5 hover:bg-slate-400/10 dark:hover:bg-white/10 border border-border"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ export const TooltipIconButton = forwardRef<HTMLButtonElement, TooltipIconButton
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent
|
<TooltipContent
|
||||||
side={side}
|
side={side}
|
||||||
className="bg-black text-white font-medium shadow-xl px-3 py-1.5 dark:bg-zinc-800 dark:text-zinc-50 border-none"
|
|
||||||
>
|
>
|
||||||
{tooltip}
|
{tooltip}
|
||||||
</TooltipContent>
|
</TooltipContent>
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ function TooltipContent({
|
||||||
data-slot="tooltip-content"
|
data-slot="tooltip-content"
|
||||||
sideOffset={sideOffset}
|
sideOffset={sideOffset}
|
||||||
className={cn(
|
className={cn(
|
||||||
"bg-popover text-popover-foreground fill-popover shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit rounded-md px-3 py-1.5 text-xs text-balance",
|
"bg-black text-white font-medium shadow-xl px-3 py-1.5 dark:bg-zinc-800 dark:text-zinc-50 border-none animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit rounded-md text-xs text-balance",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue