Merge pull request #10468 from Budibase/feature/user-side-panel-ux-updates
Designer user side panel UX updates.
This commit is contained in:
commit
110e02c454
|
@ -28,13 +28,16 @@
|
||||||
let inviting = false
|
let inviting = false
|
||||||
let searchFocus = false
|
let searchFocus = false
|
||||||
|
|
||||||
|
// Initially filter entities without app access
|
||||||
|
// Show all when false
|
||||||
|
let filterByAppAccess = true
|
||||||
|
|
||||||
let appInvites = []
|
let appInvites = []
|
||||||
let filteredInvites = []
|
let filteredInvites = []
|
||||||
let filteredUsers = []
|
let filteredUsers = []
|
||||||
let filteredGroups = []
|
let filteredGroups = []
|
||||||
let selectedGroup
|
let selectedGroup
|
||||||
let userOnboardResponse = null
|
let userOnboardResponse = null
|
||||||
|
|
||||||
let userLimitReachedModal
|
let userLimitReachedModal
|
||||||
|
|
||||||
$: queryIsEmail = emailValidator(query) === true
|
$: queryIsEmail = emailValidator(query) === true
|
||||||
|
@ -52,15 +55,32 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const filterInvites = async query => {
|
const filterInvites = async query => {
|
||||||
appInvites = await getInvites()
|
if (!prodAppId) {
|
||||||
if (!query || query == "") {
|
|
||||||
filteredInvites = appInvites
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
filteredInvites = appInvites.filter(invite => invite.email.includes(query))
|
|
||||||
|
appInvites = await getInvites()
|
||||||
|
|
||||||
|
//On Focus behaviour
|
||||||
|
if (!filterByAppAccess && !query) {
|
||||||
|
filteredInvites =
|
||||||
|
appInvites.length > 100 ? appInvites.slice(0, 100) : [...appInvites]
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
filteredInvites = appInvites.filter(invite => {
|
||||||
|
const inviteInfo = invite.info?.apps
|
||||||
|
if (!query && inviteInfo && prodAppId) {
|
||||||
|
return Object.keys(inviteInfo).includes(prodAppId)
|
||||||
|
}
|
||||||
|
return invite.email.includes(query)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
$: filterInvites(query)
|
$: filterByAppAccess, prodAppId, filterInvites(query)
|
||||||
|
$: if (searchFocus === true) {
|
||||||
|
filterByAppAccess = false
|
||||||
|
}
|
||||||
|
|
||||||
const usersFetch = fetchData({
|
const usersFetch = fetchData({
|
||||||
API,
|
API,
|
||||||
|
@ -79,9 +99,9 @@
|
||||||
}
|
}
|
||||||
await usersFetch.update({
|
await usersFetch.update({
|
||||||
query: {
|
query: {
|
||||||
appId: query ? null : prodAppId,
|
appId: query || !filterByAppAccess ? null : prodAppId,
|
||||||
email: query,
|
email: query,
|
||||||
paginated: query ? null : false,
|
paginated: query || !filterByAppAccess ? null : false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await usersFetch.refresh()
|
await usersFetch.refresh()
|
||||||
|
@ -107,7 +127,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const debouncedUpdateFetch = Utils.debounce(searchUsers, 250)
|
const debouncedUpdateFetch = Utils.debounce(searchUsers, 250)
|
||||||
$: debouncedUpdateFetch(query, $store.builderSidePanel, loaded)
|
$: debouncedUpdateFetch(
|
||||||
|
query,
|
||||||
|
$store.builderSidePanel,
|
||||||
|
loaded,
|
||||||
|
filterByAppAccess
|
||||||
|
)
|
||||||
|
|
||||||
const updateAppUser = async (user, role) => {
|
const updateAppUser = async (user, role) => {
|
||||||
if (!prodAppId) {
|
if (!prodAppId) {
|
||||||
|
@ -182,9 +207,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchGroups = (userGroups, query) => {
|
const searchGroups = (userGroups, query) => {
|
||||||
let filterGroups = query?.length
|
let filterGroups =
|
||||||
? userGroups
|
query?.length || !filterByAppAccess
|
||||||
: getAppGroups(userGroups, prodAppId)
|
? userGroups
|
||||||
|
: getAppGroups(userGroups, prodAppId)
|
||||||
return filterGroups
|
return filterGroups
|
||||||
.filter(group => {
|
.filter(group => {
|
||||||
if (!query?.length) {
|
if (!query?.length) {
|
||||||
|
@ -214,7 +240,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds the 'role' attribute and sets it to the current app.
|
// Adds the 'role' attribute and sets it to the current app.
|
||||||
$: enrichedGroups = getEnrichedGroups($groups)
|
$: enrichedGroups = getEnrichedGroups($groups, filterByAppAccess)
|
||||||
$: filteredGroups = searchGroups(enrichedGroups, query)
|
$: filteredGroups = searchGroups(enrichedGroups, query)
|
||||||
$: groupUsers = buildGroupUsers(filteredGroups, filteredUsers)
|
$: groupUsers = buildGroupUsers(filteredGroups, filteredUsers)
|
||||||
$: allUsers = [...filteredUsers, ...groupUsers]
|
$: allUsers = [...filteredUsers, ...groupUsers]
|
||||||
|
@ -226,7 +252,7 @@
|
||||||
specific roles for the app.
|
specific roles for the app.
|
||||||
*/
|
*/
|
||||||
const buildGroupUsers = (userGroups, filteredUsers) => {
|
const buildGroupUsers = (userGroups, filteredUsers) => {
|
||||||
if (query) {
|
if (query || !filterByAppAccess) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
// Must exclude users who have explicit privileges
|
// Must exclude users who have explicit privileges
|
||||||
|
@ -321,12 +347,12 @@
|
||||||
[prodAppId]: role,
|
[prodAppId]: role,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await filterInvites()
|
await filterInvites(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onUninviteAppUser = async invite => {
|
const onUninviteAppUser = async invite => {
|
||||||
await uninviteAppUser(invite)
|
await uninviteAppUser(invite)
|
||||||
await filterInvites()
|
await filterInvites(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Purge only the app from the invite or recind the invite if only 1 app remains?
|
// Purge only the app from the invite or recind the invite if only 1 app remains?
|
||||||
|
@ -351,7 +377,6 @@
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
rendered = true
|
rendered = true
|
||||||
searchFocus = true
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleKeyDown(evt) {
|
function handleKeyDown(evt) {
|
||||||
|
@ -417,7 +442,6 @@
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
disabled={inviting}
|
disabled={inviting}
|
||||||
value={query}
|
value={query}
|
||||||
autofocus
|
|
||||||
on:input={e => {
|
on:input={e => {
|
||||||
query = e.target.value.trim()
|
query = e.target.value.trim()
|
||||||
}}
|
}}
|
||||||
|
@ -428,16 +452,20 @@
|
||||||
|
|
||||||
<span
|
<span
|
||||||
class="search-input-icon"
|
class="search-input-icon"
|
||||||
class:searching={query}
|
class:searching={query || !filterByAppAccess}
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
|
if (!filterByAppAccess) {
|
||||||
|
filterByAppAccess = true
|
||||||
|
}
|
||||||
if (!query) {
|
if (!query) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
query = null
|
query = null
|
||||||
userOnboardResponse = null
|
userOnboardResponse = null
|
||||||
|
filterByAppAccess = true
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon name={query ? "Close" : "Search"} />
|
<Icon name={!filterByAppAccess || query ? "Close" : "Search"} />
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue