|
@@ -192,7 +192,6 @@ function Groups() {
|
|
|
const [showCreateModal, setShowCreateModal] = useState(false)
|
|
const [showCreateModal, setShowCreateModal] = useState(false)
|
|
|
const [editingGroup, setEditingGroup] = useState<Group | null>(null)
|
|
const [editingGroup, setEditingGroup] = useState<Group | null>(null)
|
|
|
const [deletingGroup, setDeletingGroup] = useState<Group | null>(null)
|
|
const [deletingGroup, setDeletingGroup] = useState<Group | null>(null)
|
|
|
- const [showSystemGroups, setShowSystemGroups] = useState(false)
|
|
|
|
|
|
|
|
|
|
const fetchGroups = useCallback(async () => {
|
|
const fetchGroups = useCallback(async () => {
|
|
|
if (!currentWorkspace) {
|
|
if (!currentWorkspace) {
|
|
@@ -204,10 +203,8 @@ function Groups() {
|
|
|
setIsLoading(true)
|
|
setIsLoading(true)
|
|
|
setError(null)
|
|
setError(null)
|
|
|
try {
|
|
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)
|
|
const response = await apiClient.get<{ groups: Group[] }>(url)
|
|
|
setGroups(response.groups || [])
|
|
setGroups(response.groups || [])
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
@@ -215,7 +212,7 @@ function Groups() {
|
|
|
} finally {
|
|
} finally {
|
|
|
setIsLoading(false)
|
|
setIsLoading(false)
|
|
|
}
|
|
}
|
|
|
- }, [currentWorkspace, showSystemGroups])
|
|
|
|
|
|
|
+ }, [currentWorkspace])
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
fetchGroups()
|
|
fetchGroups()
|
|
@@ -223,19 +220,13 @@ function Groups() {
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
const query = searchQuery.toLowerCase()
|
|
const query = searchQuery.toLowerCase()
|
|
|
- let filtered = groups.filter(
|
|
|
|
|
|
|
+ const filtered = groups.filter(
|
|
|
(g) =>
|
|
(g) =>
|
|
|
g.name.toLowerCase().includes(query) ||
|
|
g.name.toLowerCase().includes(query) ||
|
|
|
g.permissions.some((p) => p.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)
|
|
setFilteredGroups(filtered)
|
|
|
- }, [groups, searchQuery, showSystemGroups])
|
|
|
|
|
|
|
+ }, [groups, searchQuery])
|
|
|
|
|
|
|
|
const handleSave = () => {
|
|
const handleSave = () => {
|
|
|
setShowCreateModal(false)
|
|
setShowCreateModal(false)
|
|
@@ -283,25 +274,14 @@ function Groups() {
|
|
|
</Button>
|
|
</Button>
|
|
|
</div>
|
|
</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>
|
|
</div>
|
|
|
|
|
|
|
|
{/* Error state */}
|
|
{/* Error state */}
|