mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-09 15:52:40 +02:00
Merge branch 'dev' of https://github.com/MODSetter/SurfSense into dev
This commit is contained in:
commit
c54dfb8f96
8 changed files with 25 additions and 59 deletions
|
|
@ -40,19 +40,13 @@ export function UserDropdown({
|
||||||
|
|
||||||
await logout();
|
await logout();
|
||||||
|
|
||||||
router.push("/");
|
router.push(getLoginPath());
|
||||||
router.refresh();
|
router.refresh();
|
||||||
if (typeof window !== "undefined") {
|
|
||||||
window.location.href = getLoginPath();
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error during logout:", error);
|
console.error("Error during logout:", error);
|
||||||
await logout();
|
await logout();
|
||||||
router.push("/");
|
router.push(getLoginPath());
|
||||||
router.refresh();
|
router.refresh();
|
||||||
if (typeof window !== "undefined") {
|
|
||||||
window.location.href = getLoginPath();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Download, FileQuestionMark, FileText, Loader2, PenLine, RefreshCw } from "lucide-react";
|
import { Download, FileQuestionMark, FileText, Loader2, PenLine, RefreshCw } from "lucide-react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { PlateEditor } from "@/components/editor/plate-editor";
|
import { PlateEditor } from "@/components/editor/plate-editor";
|
||||||
|
|
@ -60,6 +61,7 @@ export function DocumentTabContent({ documentId, searchSpaceId, title }: Documen
|
||||||
const markdownRef = useRef<string>("");
|
const markdownRef = useRef<string>("");
|
||||||
const initialLoadDone = useRef(false);
|
const initialLoadDone = useRef(false);
|
||||||
const changeCountRef = useRef(0);
|
const changeCountRef = useRef(0);
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
const isLargeDocument = (doc?.content_size_bytes ?? 0) > LARGE_DOCUMENT_THRESHOLD;
|
const isLargeDocument = (doc?.content_size_bytes ?? 0) > LARGE_DOCUMENT_THRESHOLD;
|
||||||
|
|
||||||
|
|
@ -190,7 +192,7 @@ export function DocumentTabContent({ documentId, searchSpaceId, title }: Documen
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="mt-1 gap-1.5"
|
className="mt-1 gap-1.5"
|
||||||
onClick={() => window.location.reload()}
|
onClick={() => router.refresh()}
|
||||||
>
|
>
|
||||||
<RefreshCw className="size-3.5" />
|
<RefreshCw className="size-3.5" />
|
||||||
Retry
|
Retry
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { useAtomValue, useSetAtom } from "jotai";
|
import { useAtomValue, useSetAtom } from "jotai";
|
||||||
import { Earth, User, Users } from "lucide-react";
|
import { Earth, User, Users } from "lucide-react";
|
||||||
|
|
||||||
import { useCallback, useMemo, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { currentThreadAtom, setThreadVisibilityAtom } from "@/atoms/chat/current-thread.atom";
|
import { currentThreadAtom, setThreadVisibilityAtom } from "@/atoms/chat/current-thread.atom";
|
||||||
import { myAccessAtom } from "@/atoms/members/members-query.atoms";
|
import { myAccessAtom } from "@/atoms/members/members-query.atoms";
|
||||||
|
|
@ -63,11 +63,8 @@ export function ChatShareButton({ thread, onVisibilityChange, className }: ChatS
|
||||||
|
|
||||||
// Permission check for public sharing
|
// Permission check for public sharing
|
||||||
const { data: access } = useAtomValue(myAccessAtom);
|
const { data: access } = useAtomValue(myAccessAtom);
|
||||||
const canCreatePublicLink = useMemo(() => {
|
const canCreatePublicLink =
|
||||||
if (!access) return false;
|
!!access && (access.is_owner || (access.permissions?.includes("public_sharing:create") ?? false));
|
||||||
if (access.is_owner) return true;
|
|
||||||
return access.permissions?.includes("public_sharing:create") ?? false;
|
|
||||||
}, [access]);
|
|
||||||
|
|
||||||
// Query to check if thread has public snapshots
|
// Query to check if thread has public snapshots
|
||||||
const { data: snapshotsData } = useQuery({
|
const { data: snapshotsData } = useQuery({
|
||||||
|
|
|
||||||
|
|
@ -121,9 +121,8 @@ export function ModelSelector({
|
||||||
return llmUserConfigs?.find((c) => c.id === agentLlmId) ?? null;
|
return llmUserConfigs?.find((c) => c.id === agentLlmId) ?? null;
|
||||||
}, [preferences, llmGlobalConfigs, llmUserConfigs]);
|
}, [preferences, llmGlobalConfigs, llmUserConfigs]);
|
||||||
|
|
||||||
const isLLMAutoMode = useMemo(() => {
|
const isLLMAutoMode =
|
||||||
return currentLLMConfig && "is_auto_mode" in currentLLMConfig && currentLLMConfig.is_auto_mode;
|
currentLLMConfig && "is_auto_mode" in currentLLMConfig && currentLLMConfig.is_auto_mode;
|
||||||
}, [currentLLMConfig]);
|
|
||||||
|
|
||||||
// ─── Image current config ───
|
// ─── Image current config ───
|
||||||
const currentImageConfig = useMemo(() => {
|
const currentImageConfig = useMemo(() => {
|
||||||
|
|
@ -135,11 +134,8 @@ export function ModelSelector({
|
||||||
return imageUserConfigs?.find((c) => c.id === id) ?? null;
|
return imageUserConfigs?.find((c) => c.id === id) ?? null;
|
||||||
}, [preferences, imageGlobalConfigs, imageUserConfigs]);
|
}, [preferences, imageGlobalConfigs, imageUserConfigs]);
|
||||||
|
|
||||||
const isImageAutoMode = useMemo(() => {
|
const isImageAutoMode =
|
||||||
return (
|
currentImageConfig && "is_auto_mode" in currentImageConfig && currentImageConfig.is_auto_mode;
|
||||||
currentImageConfig && "is_auto_mode" in currentImageConfig && currentImageConfig.is_auto_mode
|
|
||||||
);
|
|
||||||
}, [currentImageConfig]);
|
|
||||||
|
|
||||||
// ─── Vision current config ───
|
// ─── Vision current config ───
|
||||||
const currentVisionConfig = useMemo(() => {
|
const currentVisionConfig = useMemo(() => {
|
||||||
|
|
|
||||||
|
|
@ -43,17 +43,11 @@ export function PublicChatSnapshotsManager({
|
||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
const { data: access } = useAtomValue(myAccessAtom);
|
const { data: access } = useAtomValue(myAccessAtom);
|
||||||
const canView = useMemo(() => {
|
const canView =
|
||||||
if (!access) return false;
|
!!access && (access.is_owner || (access.permissions?.includes("public_sharing:view") ?? false));
|
||||||
if (access.is_owner) return true;
|
|
||||||
return access.permissions?.includes("public_sharing:view") ?? false;
|
|
||||||
}, [access]);
|
|
||||||
|
|
||||||
const canDelete = useMemo(() => {
|
const canDelete =
|
||||||
if (!access) return false;
|
!!access && (access.is_owner || (access.permissions?.includes("public_sharing:delete") ?? false));
|
||||||
if (access.is_owner) return true;
|
|
||||||
return access.permissions?.includes("public_sharing:delete") ?? false;
|
|
||||||
}, [access]);
|
|
||||||
|
|
||||||
// Mutations
|
// Mutations
|
||||||
const { mutateAsync: deleteSnapshot } = useAtomValue(deletePublicChatSnapshotMutationAtom);
|
const { mutateAsync: deleteSnapshot } = useAtomValue(deletePublicChatSnapshotMutationAtom);
|
||||||
|
|
|
||||||
|
|
@ -78,16 +78,10 @@ export function ImageModelManager({ searchSpaceId }: ImageModelManagerProps) {
|
||||||
}, [members]);
|
}, [members]);
|
||||||
|
|
||||||
const { data: access } = useAtomValue(myAccessAtom);
|
const { data: access } = useAtomValue(myAccessAtom);
|
||||||
const canCreate = useMemo(() => {
|
const canCreate =
|
||||||
if (!access) return false;
|
!!access && (access.is_owner || (access.permissions?.includes("image_generations:create") ?? false));
|
||||||
if (access.is_owner) return true;
|
const canDelete =
|
||||||
return access.permissions?.includes("image_generations:create") ?? false;
|
!!access && (access.is_owner || (access.permissions?.includes("image_generations:delete") ?? false));
|
||||||
}, [access]);
|
|
||||||
const canDelete = useMemo(() => {
|
|
||||||
if (!access) return false;
|
|
||||||
if (access.is_owner) return true;
|
|
||||||
return access.permissions?.includes("image_generations:delete") ?? false;
|
|
||||||
}, [access]);
|
|
||||||
const canUpdate = canCreate;
|
const canUpdate = canCreate;
|
||||||
const isReadOnly = !canCreate && !canDelete;
|
const isReadOnly = !canCreate && !canDelete;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,21 +89,9 @@ export function ModelConfigManager({ searchSpaceId }: ModelConfigManagerProps) {
|
||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
const { data: access } = useAtomValue(myAccessAtom);
|
const { data: access } = useAtomValue(myAccessAtom);
|
||||||
const canCreate = useMemo(() => {
|
const canCreate = !!access && (access.is_owner || (access.permissions?.includes("llm_configs:create") ?? false));
|
||||||
if (!access) return false;
|
const canUpdate = !!access && (access.is_owner || (access.permissions?.includes("llm_configs:update") ?? false));
|
||||||
if (access.is_owner) return true;
|
const canDelete = !!access && (access.is_owner || (access.permissions?.includes("llm_configs:delete") ?? false));
|
||||||
return access.permissions?.includes("llm_configs:create") ?? false;
|
|
||||||
}, [access]);
|
|
||||||
const canUpdate = useMemo(() => {
|
|
||||||
if (!access) return false;
|
|
||||||
if (access.is_owner) return true;
|
|
||||||
return access.permissions?.includes("llm_configs:update") ?? false;
|
|
||||||
}, [access]);
|
|
||||||
const canDelete = useMemo(() => {
|
|
||||||
if (!access) return false;
|
|
||||||
if (access.is_owner) return true;
|
|
||||||
return access.permissions?.includes("llm_configs:delete") ?? false;
|
|
||||||
}, [access]);
|
|
||||||
const isReadOnly = !canCreate && !canUpdate && !canDelete;
|
const isReadOnly = !canCreate && !canUpdate && !canDelete;
|
||||||
|
|
||||||
// Local state
|
// Local state
|
||||||
|
|
|
||||||
|
|
@ -310,7 +310,8 @@ const TabsList = forwardRef<
|
||||||
}, [updateActiveIndicator]);
|
}, [updateActiveIndicator]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
requestAnimationFrame(updateActiveIndicator);
|
const id = requestAnimationFrame(updateActiveIndicator);
|
||||||
|
return () => cancelAnimationFrame(id);
|
||||||
}, [updateActiveIndicator]);
|
}, [updateActiveIndicator]);
|
||||||
|
|
||||||
const scrollTabToCenter = useCallback((index: number) => {
|
const scrollTabToCenter = useCallback((index: number) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue