瀏覽代碼

fix: always show system collections and groups by default

Remove checkboxes and always include system items for superadmins.
Fszontagh 6 月之前
父節點
當前提交
327e1f1a55
共有 2 個文件被更改,包括 24 次插入59 次删除
  1. 11 26
      webui/src/pages/Collections.tsx
  2. 13 33
      webui/src/pages/Groups.tsx

+ 11 - 26
webui/src/pages/Collections.tsx

@@ -303,7 +303,6 @@ function Collections() {
   const [showCreateModal, setShowCreateModal] = useState(false)
   const [editingCollection, setEditingCollection] = useState<Collection | null>(null)
   const [deletingCollection, setDeletingCollection] = useState<Collection | null>(null)
-  const [showSystemCollections, setShowSystemCollections] = useState(false)
 
   const isSuperadmin = user?.is_superadmin === true
 
@@ -318,7 +317,8 @@ function Collections() {
     setError(null)
     try {
       let url = `/workspaces/${currentWorkspace.id}/collections`
-      if (showSystemCollections && isSuperadmin) {
+      // Always include system collections for superadmins
+      if (isSuperadmin) {
         url += '?include_system=true'
       }
       const response = await apiClient.get<{ collections: Collection[] }>(url)
@@ -328,7 +328,7 @@ function Collections() {
     } finally {
       setIsLoading(false)
     }
-  }, [currentWorkspace, showSystemCollections, isSuperadmin])
+  }, [currentWorkspace, isSuperadmin])
 
   const fetchGroups = useCallback(async () => {
     if (!currentWorkspace) {
@@ -400,29 +400,14 @@ function Collections() {
         </Button>
       </div>
 
-      {/* Search and filters */}
-      <div className="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
-        <div className="max-w-md flex-1">
-          <Input
-            type="search"
-            placeholder="Search collections..."
-            value={searchQuery}
-            onChange={(e) => setSearchQuery(e.target.value)}
-          />
-        </div>
-
-        {/* System collections toggle for superadmins */}
-        {isSuperadmin && (
-          <label className="flex items-center gap-2 text-sm">
-            <input
-              type="checkbox"
-              checked={showSystemCollections}
-              onChange={(e) => setShowSystemCollections(e.target.checked)}
-              className="h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500"
-            />
-            <span className="text-gray-700">Show system collections</span>
-          </label>
-        )}
+      {/* Search */}
+      <div className="max-w-md">
+        <Input
+          type="search"
+          placeholder="Search collections..."
+          value={searchQuery}
+          onChange={(e) => setSearchQuery(e.target.value)}
+        />
       </div>
 
       {/* Error state */}

+ 13 - 33
webui/src/pages/Groups.tsx

@@ -192,7 +192,6 @@ function Groups() {
   const [showCreateModal, setShowCreateModal] = useState(false)
   const [editingGroup, setEditingGroup] = useState<Group | null>(null)
   const [deletingGroup, setDeletingGroup] = useState<Group | null>(null)
-  const [showSystemGroups, setShowSystemGroups] = useState(false)
 
   const fetchGroups = useCallback(async () => {
     if (!currentWorkspace) {
@@ -204,10 +203,8 @@ function Groups() {
     setIsLoading(true)
     setError(null)
     try {
-      let url = `/workspaces/${currentWorkspace.id}/groups`
-      if (showSystemGroups) {
-        url += '?include_system=true'
-      }
+      // Always include system groups
+      const url = `/workspaces/${currentWorkspace.id}/groups?include_system=true`
       const response = await apiClient.get<{ groups: Group[] }>(url)
       setGroups(response.groups || [])
     } catch (err) {
@@ -215,7 +212,7 @@ function Groups() {
     } finally {
       setIsLoading(false)
     }
-  }, [currentWorkspace, showSystemGroups])
+  }, [currentWorkspace])
 
   useEffect(() => {
     fetchGroups()
@@ -223,19 +220,13 @@ function Groups() {
 
   useEffect(() => {
     const query = searchQuery.toLowerCase()
-    let filtered = groups.filter(
+    const filtered = groups.filter(
       (g) =>
         g.name.toLowerCase().includes(query) ||
         g.permissions.some((p) => p.toLowerCase().includes(query))
     )
-
-    // Filter out system groups unless showing them
-    if (!showSystemGroups) {
-      filtered = filtered.filter((g) => !g.is_system)
-    }
-
     setFilteredGroups(filtered)
-  }, [groups, searchQuery, showSystemGroups])
+  }, [groups, searchQuery])
 
   const handleSave = () => {
     setShowCreateModal(false)
@@ -283,25 +274,14 @@ function Groups() {
         </Button>
       </div>
 
-      {/* Search and filters */}
-      <div className="flex flex-col gap-4 sm:flex-row sm:items-center">
-        <div className="max-w-md flex-1">
-          <Input
-            type="search"
-            placeholder="Search groups..."
-            value={searchQuery}
-            onChange={(e) => setSearchQuery(e.target.value)}
-          />
-        </div>
-        <label className="inline-flex items-center gap-2 text-sm text-gray-600">
-          <input
-            type="checkbox"
-            checked={showSystemGroups}
-            onChange={(e) => setShowSystemGroups(e.target.checked)}
-            className="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
-          />
-          Show system groups
-        </label>
+      {/* Search */}
+      <div className="max-w-md">
+        <Input
+          type="search"
+          placeholder="Search groups..."
+          value={searchQuery}
+          onChange={(e) => setSearchQuery(e.target.value)}
+        />
       </div>
 
       {/* Error state */}