diff --git a/surfsense_web/components/layout/index.ts b/surfsense_web/components/layout/index.ts index 3a79ccde7..b9c271915 100644 --- a/surfsense_web/components/layout/index.ts +++ b/surfsense_web/components/layout/index.ts @@ -11,6 +11,7 @@ export type { SearchSpace, } from "./types/layout.types"; export { + AllSearchSpacesSheet, ChatListItem, CreateSearchSpaceDialog, Header, diff --git a/surfsense_web/components/layout/ui/index.ts b/surfsense_web/components/layout/ui/index.ts index 1c3ddb2ca..c5aba9250 100644 --- a/surfsense_web/components/layout/ui/index.ts +++ b/surfsense_web/components/layout/ui/index.ts @@ -2,6 +2,7 @@ export { CreateSearchSpaceDialog } from "./dialogs"; export { Header } from "./header"; export { IconRail, NavIcon, SearchSpaceAvatar } from "./icon-rail"; export { LayoutShell } from "./shell"; +export { AllSearchSpacesSheet } from "./sheets"; export { ChatListItem, MobileSidebar, diff --git a/surfsense_web/components/layout/ui/sheets/AllSearchSpacesSheet.tsx b/surfsense_web/components/layout/ui/sheets/AllSearchSpacesSheet.tsx new file mode 100644 index 000000000..29c1b8791 --- /dev/null +++ b/surfsense_web/components/layout/ui/sheets/AllSearchSpacesSheet.tsx @@ -0,0 +1,130 @@ +"use client"; + +import { Crown, Search, Users } from "lucide-react"; +import { useTranslations } from "next-intl"; +import { Badge } from "@/components/ui/badge"; +import { Button } from "@/components/ui/button"; +import { + Sheet, + SheetContent, + SheetDescription, + SheetHeader, + SheetTitle, +} from "@/components/ui/sheet"; +import { cn } from "@/lib/utils"; +import type { SearchSpace } from "../../types/layout.types"; + +interface AllSearchSpacesSheetProps { + open: boolean; + onOpenChange: (open: boolean) => void; + searchSpaces: SearchSpace[]; + activeSearchSpaceId: number | null; + onSearchSpaceSelect: (id: number) => void; + onCreateNew?: () => void; +} + +export function AllSearchSpacesSheet({ + open, + onOpenChange, + searchSpaces, + activeSearchSpaceId, + onSearchSpaceSelect, + onCreateNew, +}: AllSearchSpacesSheetProps) { + const t = useTranslations("searchSpace"); + const tCommon = useTranslations("common"); + + const handleSelect = (id: number) => { + onSearchSpaceSelect(id); + onOpenChange(false); + }; + + return ( + + + +
+
+ +
+
+ {t("all_search_spaces")} + + {t("search_spaces_count", { count: searchSpaces.length })} + +
+
+
+ +
+ {searchSpaces.length === 0 ? ( +
+
+ +
+
+

{t("no_search_spaces")}

+

+ {t("create_first_search_space")} +

+
+ {onCreateNew && ( + + )} +
+ ) : ( + searchSpaces.map((space) => ( + + )) + )} +
+ + {searchSpaces.length > 0 && onCreateNew && ( +
+ +
+ )} +
+
+ ); +} + diff --git a/surfsense_web/components/layout/ui/sheets/index.ts b/surfsense_web/components/layout/ui/sheets/index.ts new file mode 100644 index 000000000..b2d05f1a8 --- /dev/null +++ b/surfsense_web/components/layout/ui/sheets/index.ts @@ -0,0 +1,2 @@ +export { AllSearchSpacesSheet } from "./AllSearchSpacesSheet"; + diff --git a/surfsense_web/messages/en.json b/surfsense_web/messages/en.json index 52991793a..2ab400102 100644 --- a/surfsense_web/messages/en.json +++ b/surfsense_web/messages/en.json @@ -28,7 +28,8 @@ "info": "Information", "required": "Required", "optional": "Optional", - "retry": "Retry" + "retry": "Retry", + "owner": "Owner" }, "auth": { "login": "Login", @@ -85,7 +86,13 @@ "description_label": "Description", "description_placeholder": "What is this search space for?", "create_button": "Create", - "creating": "Creating..." + "creating": "Creating...", + "all_search_spaces": "All Search Spaces", + "search_spaces_count": "{count, plural, =0 {No search spaces} =1 {1 search space} other {# search spaces}}", + "no_search_spaces": "No search spaces yet", + "create_first_search_space": "Create your first search space to get started", + "members_count": "{count, plural, =1 {1 member} other {# members}}", + "create_new_search_space": "Create new search space" }, "dashboard": { "title": "Dashboard", diff --git a/surfsense_web/messages/zh.json b/surfsense_web/messages/zh.json index ea3af36e3..bcfeb1ef4 100644 --- a/surfsense_web/messages/zh.json +++ b/surfsense_web/messages/zh.json @@ -28,7 +28,8 @@ "info": "信息", "required": "必填", "optional": "可选", - "retry": "重试" + "retry": "重试", + "owner": "所有者" }, "auth": { "login": "登录", @@ -85,7 +86,13 @@ "description_label": "描述", "description_placeholder": "这个搜索空间是做什么的?", "create_button": "创建", - "creating": "创建中..." + "creating": "创建中...", + "all_search_spaces": "所有搜索空间", + "search_spaces_count": "{count, plural, =0 {没有搜索空间} other {# 个搜索空间}}", + "no_search_spaces": "暂无搜索空间", + "create_first_search_space": "创建您的第一个搜索空间以开始使用", + "members_count": "{count, plural, other {# 位成员}}", + "create_new_search_space": "创建新的搜索空间" }, "dashboard": { "title": "仪表盘",