Add searching for users back
This commit is contained in:
parent
10fcca92f6
commit
8102c54bc3
|
@ -16,6 +16,7 @@
|
|||
import { fetchData } from "@budibase/frontend-core"
|
||||
import { API } from "api"
|
||||
import UserGroupPicker from "components/settings/UserGroupPicker.svelte"
|
||||
import { createPaginationStore } from "helpers/pagination"
|
||||
import { users, apps, groups, auth, features } from "stores/portal"
|
||||
import { onMount, setContext } from "svelte"
|
||||
import { roles } from "stores/backend"
|
||||
|
@ -30,7 +31,7 @@
|
|||
|
||||
export let groupId
|
||||
|
||||
const fetchUsers = fetchData({
|
||||
const fetchGroupUsers = fetchData({
|
||||
API,
|
||||
datasource: {
|
||||
type: "groupUser",
|
||||
|
@ -84,12 +85,17 @@
|
|||
let popoverAnchor
|
||||
let popover
|
||||
let searchTerm = ""
|
||||
let prevSearch = undefined
|
||||
let pageInfo = createPaginationStore()
|
||||
let loaded = false
|
||||
let editModal, deleteModal
|
||||
|
||||
$: scimEnabled = $features.isScimEnabled
|
||||
$: readonly = !$auth.isAdmin || scimEnabled
|
||||
$: page = $pageInfo.page
|
||||
$: fetchUsers(page, searchTerm)
|
||||
$: group = $groups.find(x => x._id === groupId)
|
||||
$: filtered = $users.data
|
||||
$: groupApps = $apps
|
||||
.filter(app =>
|
||||
groups.actions
|
||||
|
@ -106,6 +112,25 @@
|
|||
}
|
||||
}
|
||||
|
||||
async function fetchUsers(page, search) {
|
||||
if ($pageInfo.loading) {
|
||||
return
|
||||
}
|
||||
// need to remove the page if they've started searching
|
||||
if (search && !prevSearch) {
|
||||
pageInfo.reset()
|
||||
page = undefined
|
||||
}
|
||||
prevSearch = search
|
||||
try {
|
||||
pageInfo.loading()
|
||||
await users.search({ page, email: search })
|
||||
pageInfo.fetched($users.hasNextPage, $users.nextPage)
|
||||
} catch (error) {
|
||||
notifications.error("Error getting user list")
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteGroup() {
|
||||
try {
|
||||
await groups.actions.delete(group)
|
||||
|
@ -201,7 +226,7 @@
|
|||
|
||||
<Table
|
||||
schema={userSchema}
|
||||
data={$fetchUsers.rows}
|
||||
data={$fetchGroupUsers?.users}
|
||||
allowEditRows={false}
|
||||
customPlaceholder
|
||||
customRenderers={customUserTableRenderers}
|
||||
|
@ -214,11 +239,19 @@
|
|||
|
||||
<div class="pagination">
|
||||
<Pagination
|
||||
page={$fetchUsers.pageNumber + 1}
|
||||
hasPrevPage={$fetchUsers.loading ? false : $fetchUsers.hasPrevPage}
|
||||
hasNextPage={$fetchUsers.loading ? false : $fetchUsers.hasNextPage}
|
||||
goToPrevPage={$fetchUsers.loading ? null : fetchUsers.prevPage}
|
||||
goToNextPage={$fetchUsers.loading ? null : fetchUsers.nextPage}
|
||||
page={$fetchGroupUsers.pageNumber + 1}
|
||||
hasPrevPage={$fetchGroupUsers.loading
|
||||
? false
|
||||
: $fetchGroupUsers.hasPrevPage}
|
||||
hasNextPage={$fetchGroupUsers.loading
|
||||
? false
|
||||
: $fetchGroupUsers.hasNextPage}
|
||||
goToPrevPage={$fetchGroupUsers.loading
|
||||
? null
|
||||
: fetchGroupUsers.prevPage}
|
||||
goToNextPage={$fetchGroupUsers.loading
|
||||
? null
|
||||
: fetchGroupUsers.nextPage}
|
||||
/>
|
||||
</div>
|
||||
</Layout>
|
||||
|
|
Loading…
Reference in New Issue