mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-23 19:05:16 +02:00
refactor: update alert components to use warning variant and clean up unused alerts in settings manager
This commit is contained in:
parent
d129ddd8f7
commit
c8f0f7cb1b
4 changed files with 20 additions and 20 deletions
|
|
@ -47,7 +47,7 @@ export const ObsidianConfig: FC<ConnectorConfigProps> = ({ connector }) => {
|
||||||
const LegacyBanner: FC = () => {
|
const LegacyBanner: FC = () => {
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<Alert>
|
<Alert variant="warning">
|
||||||
<AlertTriangle />
|
<AlertTriangle />
|
||||||
<AlertTitle>Sync stopped, install the plugin to migrate</AlertTitle>
|
<AlertTitle>Sync stopped, install the plugin to migrate</AlertTitle>
|
||||||
<AlertDescription>
|
<AlertDescription>
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,10 @@
|
||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { useAtomValue } from "jotai";
|
import { useAtomValue } from "jotai";
|
||||||
import { Info } from "lucide-react";
|
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { updateSearchSpaceMutationAtom } from "@/atoms/search-spaces/search-space-mutation.atoms";
|
import { updateSearchSpaceMutationAtom } from "@/atoms/search-spaces/search-space-mutation.atoms";
|
||||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
|
|
@ -41,6 +39,9 @@ export function GeneralSettingsManager({ searchSpaceId }: GeneralSettingsManager
|
||||||
const [description, setDescription] = useState("");
|
const [description, setDescription] = useState("");
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const [isExporting, setIsExporting] = useState(false);
|
const [isExporting, setIsExporting] = useState(false);
|
||||||
|
const hasSearchSpace = !!searchSpace;
|
||||||
|
const searchSpaceName = searchSpace?.name;
|
||||||
|
const searchSpaceDescription = searchSpace?.description;
|
||||||
|
|
||||||
const handleExportKB = useCallback(async () => {
|
const handleExportKB = useCallback(async () => {
|
||||||
if (isExporting) return;
|
if (isExporting) return;
|
||||||
|
|
@ -74,11 +75,11 @@ export function GeneralSettingsManager({ searchSpaceId }: GeneralSettingsManager
|
||||||
|
|
||||||
// Initialize state from fetched search space
|
// Initialize state from fetched search space
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (searchSpace) {
|
if (hasSearchSpace) {
|
||||||
setName(searchSpace.name || "");
|
setName(searchSpaceName || "");
|
||||||
setDescription(searchSpace.description || "");
|
setDescription(searchSpaceDescription || "");
|
||||||
}
|
}
|
||||||
}, [searchSpace?.name, searchSpace?.description]);
|
}, [hasSearchSpace, searchSpaceName, searchSpaceDescription]);
|
||||||
|
|
||||||
// Derive hasChanges during render
|
// Derive hasChanges during render
|
||||||
const hasChanges =
|
const hasChanges =
|
||||||
|
|
@ -98,9 +99,9 @@ export function GeneralSettingsManager({ searchSpaceId }: GeneralSettingsManager
|
||||||
});
|
});
|
||||||
|
|
||||||
await fetchSearchSpace();
|
await fetchSearchSpace();
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
console.error("Error saving search space details:", error);
|
console.error("Error saving search space details:", error);
|
||||||
toast.error(error.message || "Failed to save search space details");
|
toast.error(error instanceof Error ? error.message : "Failed to save search space details");
|
||||||
} finally {
|
} finally {
|
||||||
setSaving(false);
|
setSaving(false);
|
||||||
}
|
}
|
||||||
|
|
@ -135,11 +136,6 @@ export function GeneralSettingsManager({ searchSpaceId }: GeneralSettingsManager
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4 md:space-y-6">
|
<div className="space-y-4 md:space-y-6">
|
||||||
<Alert>
|
|
||||||
<Info />
|
|
||||||
<AlertDescription>Update your search space name and description.</AlertDescription>
|
|
||||||
</Alert>
|
|
||||||
|
|
||||||
<form onSubmit={onSubmit} className="space-y-6">
|
<form onSubmit={onSubmit} className="space-y-6">
|
||||||
<div className="flex flex-col gap-6">
|
<div className="flex flex-col gap-6">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,15 @@ export function PromptConfigManager({ searchSpaceId }: PromptConfigManagerProps)
|
||||||
|
|
||||||
const [customInstructions, setCustomInstructions] = useState("");
|
const [customInstructions, setCustomInstructions] = useState("");
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
|
const hasSearchSpace = !!searchSpace;
|
||||||
|
const searchSpaceInstructions = searchSpace?.qna_custom_instructions;
|
||||||
|
|
||||||
// Initialize state from fetched search space
|
// Initialize state from fetched search space
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (searchSpace) {
|
if (hasSearchSpace) {
|
||||||
setCustomInstructions(searchSpace.qna_custom_instructions || "");
|
setCustomInstructions(searchSpaceInstructions || "");
|
||||||
}
|
}
|
||||||
}, [searchSpace?.qna_custom_instructions]);
|
}, [hasSearchSpace, searchSpaceInstructions]);
|
||||||
|
|
||||||
// Derive hasChanges during render
|
// Derive hasChanges during render
|
||||||
const hasChanges =
|
const hasChanges =
|
||||||
|
|
@ -69,9 +71,9 @@ export function PromptConfigManager({ searchSpaceId }: PromptConfigManagerProps)
|
||||||
toast.success("System instructions saved successfully");
|
toast.success("System instructions saved successfully");
|
||||||
|
|
||||||
await fetchSearchSpace();
|
await fetchSearchSpace();
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
console.error("Error saving system instructions:", error);
|
console.error("Error saving system instructions:", error);
|
||||||
toast.error(error.message || "Failed to save system instructions");
|
toast.error(error instanceof Error ? error.message : "Failed to save system instructions");
|
||||||
} finally {
|
} finally {
|
||||||
setSaving(false);
|
setSaving(false);
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +104,7 @@ export function PromptConfigManager({ searchSpaceId }: PromptConfigManagerProps)
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4 md:space-y-6">
|
<div className="space-y-4 md:space-y-6">
|
||||||
{/* Work in Progress Notice */}
|
{/* Work in Progress Notice */}
|
||||||
<Alert>
|
<Alert variant="warning">
|
||||||
<AlertTriangle />
|
<AlertTriangle />
|
||||||
<AlertTitle>Work in Progress</AlertTitle>
|
<AlertTitle>Work in Progress</AlertTitle>
|
||||||
<AlertDescription>
|
<AlertDescription>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ const alertVariants = cva(
|
||||||
variants: {
|
variants: {
|
||||||
variant: {
|
variant: {
|
||||||
default: "border-popover-border bg-accent text-accent-foreground",
|
default: "border-popover-border bg-accent text-accent-foreground",
|
||||||
|
warning:
|
||||||
|
"border-highlight/40 bg-highlight/10 text-foreground *:data-[slot=alert-description]:text-muted-foreground [&>svg]:text-highlight",
|
||||||
destructive:
|
destructive:
|
||||||
"border-destructive/30 bg-destructive/10 text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current",
|
"border-destructive/30 bg-destructive/10 text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue