diff --git a/src/lib/components/admin/Users/Groups.svelte b/src/lib/components/admin/Users/Groups.svelte index ede1cc378..8da1b9e44 100644 --- a/src/lib/components/admin/Users/Groups.svelte +++ b/src/lib/components/admin/Users/Groups.svelte @@ -12,18 +12,15 @@ import Tooltip from '$lib/components/common/Tooltip.svelte'; import Plus from '$lib/components/icons/Plus.svelte'; - import Badge from '$lib/components/common/Badge.svelte'; import UsersSolid from '$lib/components/icons/UsersSolid.svelte'; import ChevronRight from '$lib/components/icons/ChevronRight.svelte'; - import EllipsisHorizontal from '$lib/components/icons/EllipsisHorizontal.svelte'; import Search from '$lib/components/icons/Search.svelte'; - import User from '$lib/components/icons/User.svelte'; - import UserCircleSolid from '$lib/components/icons/UserCircleSolid.svelte'; import EditGroupModal from './Groups/EditGroupModal.svelte'; - import Pencil from '$lib/components/icons/Pencil.svelte'; - import ChevronUp from '$lib/components/icons/ChevronUp.svelte'; - import ChevronDown from '$lib/components/icons/ChevronDown.svelte'; import GroupItem from './Groups/GroupItem.svelte'; + import XMark from '$lib/components/icons/XMark.svelte'; + import ChevronDown from '$lib/components/icons/ChevronDown.svelte'; + import Check from '$lib/components/icons/Check.svelte'; + import { Select } from 'bits-ui'; import { createNewGroup, getGroups } from '$lib/apis/groups'; import { getUserDefaultPermissions, @@ -38,17 +35,12 @@ let groups = []; let query = ''; - let orderBy = ''; - let direction = 'asc'; + let sortBy = 'members'; - const setSortKey = (key) => { - if (orderBy === key) { - direction = direction === 'asc' ? 'desc' : 'asc'; - } else { - orderBy = key; - direction = 'asc'; - } - }; + const sortItems = [ + { value: 'name', label: $i18n.t('Name') }, + { value: 'members', label: $i18n.t('Members') } + ]; $: filteredGroups = groups .filter((group) => { @@ -61,12 +53,10 @@ } }) .sort((a, b) => { - if (orderBy === 'name') { - const cmp = a.name.localeCompare(b.name); - return direction === 'asc' ? cmp : -cmp; - } else if (orderBy === 'members') { - const cmp = (a.member_count ?? 0) - (b.member_count ?? 0); - return direction === 'asc' ? cmp : -cmp; + if (sortBy === 'name') { + return a.name.localeCompare(b.name); + } else if (sortBy === 'members') { + return (b.member_count ?? 0) - (a.member_count ?? 0); } return 0; }); @@ -129,144 +119,153 @@ onSubmit={addGroupHandler} /> -
-
-
- {$i18n.t('Groups')} -
- -
- {groups.length} -
-
- -
-
-
-
- -
- +
+
+
+
+ {$i18n.t('Groups')}
-
- +
+ {groups.length} +
+
+ +
+ +
+
+
+ +
+
+
+
+ +
+ + {#if query} +
- +
+ {/if} +
+ + item.value === sortBy)} + items={sortItems} + onSelectedChange={(selectedItem) => { + sortBy = selectedItem.value; + }} + > + + + + + + + {#each sortItems as item} + + {item.label} + + {#if sortBy === item.value} +
+ +
+ {/if} +
+ {/each} +
+
+
+ + {#if filteredGroups.length !== 0} +
+ {#each filteredGroups as group} + + {/each} +
+ {:else} +
+
+
👥
+
{$i18n.t('No groups found')}
+
+ {$i18n.t('Use groups to organize your users and assign permissions.')} +
+
+
+ {/if} +
+ +
+ + + +
-
- {#if filteredGroups.length === 0} -
-
- {$i18n.t('Organize your users')} -
- -
- {$i18n.t('Use groups to group your users and assign permissions.')} -
- -
- -
-
- {:else} -
-
- - - -
- -
- - {#each filteredGroups as group} -
- -
- {/each} -
- {/if} - -
- - - - -
+
+ +
+ {/if} diff --git a/src/lib/components/admin/Users/Groups/GroupItem.svelte b/src/lib/components/admin/Users/Groups/GroupItem.svelte index 944e824d1..86348f3d7 100644 --- a/src/lib/components/admin/Users/Groups/GroupItem.svelte +++ b/src/lib/components/admin/Users/Groups/GroupItem.svelte @@ -8,7 +8,6 @@ import { deleteGroupById, updateGroupById } from '$lib/apis/groups'; import Pencil from '$lib/components/icons/Pencil.svelte'; - import User from '$lib/components/icons/User.svelte'; import EditGroupModal from './EditGroupModal.svelte'; export let group = { @@ -63,26 +62,34 @@ />