Update app access assignment and fix backups table

This commit is contained in:
Andrew Kingston 2023-01-12 17:04:05 +00:00
parent 5d24fe0a13
commit 4e4b074635
5 changed files with 40 additions and 66 deletions

View File

@ -104,7 +104,7 @@
<Icon size="XL" name="ChevronDown" /> <Icon size="XL" name="ChevronDown" />
</div> </div>
<MenuItem icon="UserEdit" on:click={() => userInfoModal.show()}> <MenuItem icon="UserEdit" on:click={() => userInfoModal.show()}>
Update user information My profile
</MenuItem> </MenuItem>
<MenuItem <MenuItem
icon="LockClosed" icon="LockClosed"

View File

@ -1,49 +0,0 @@
<script>
import { PickerDropdown } from "@budibase/bbui"
import { groups } from "stores/portal"
import { createEventDispatcher } from "svelte"
const dispatch = createEventDispatcher()
let filter = null
$: filteredGroups = !filter
? $groups
: $groups.filter(group =>
group.name?.toLowerCase().includes(filter.toLowerCase())
)
$: optionSections = {
groups: {
data: filteredGroups,
getLabel: group => group.name,
getValue: group => group._id,
getIcon: group => group.icon,
getColour: group => group.color,
},
}
$: onChange = selected => {
const { detail } = selected
if (!detail || Object.keys(detail).length == 0) {
dispatch("change", null)
return
}
const groupSelected = $groups.find(x => x._id === detail)
const appRoleIds = groupSelected?.roles
? Object.keys(groupSelected?.roles)
: []
dispatch("change", appRoleIds)
}
</script>
<PickerDropdown
autocomplete
bind:searchTerm={filter}
primaryOptions={optionSections}
placeholder={"Filter by access"}
on:pickprimary={onChange}
on:closed={() => {
filter = null
}}
/>

View File

@ -14,6 +14,8 @@
export let app export let app
export let appUsers = [] export let appUsers = []
export let showUsers = false
export let showGroups = false
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
const usersFetch = fetchData({ const usersFetch = fetchData({
@ -41,7 +43,8 @@
$: availableGroups = getAvailableGroups($groups, app.appId, search, data) $: availableGroups = getAvailableGroups($groups, app.appId, search, data)
$: valid = data?.length && !data?.some(x => !x.id?.length || !x.role?.length) $: valid = data?.length && !data?.some(x => !x.id?.length || !x.role?.length)
$: optionSections = { $: optionSections = {
...($licensing.groupsEnabled && ...(showGroups &&
$licensing.groupsEnabled &&
availableGroups.length && { availableGroups.length && {
["User groups"]: { ["User groups"]: {
data: availableGroups, data: availableGroups,
@ -51,13 +54,15 @@
getColour: group => group.color, getColour: group => group.color,
}, },
}), }),
users: { ...(showUsers && {
data: availableUsers, users: {
getLabel: user => user.email, data: availableUsers,
getValue: user => user._id, getLabel: user => user.email,
getIcon: user => user.icon, getValue: user => user._id,
getColour: user => user.color, getIcon: user => user.icon,
}, getColour: user => user.color,
},
}),
} }
const addData = async appData => { const addData = async appData => {
@ -185,7 +190,7 @@
</Layout> </Layout>
{/if} {/if}
<div> <div>
<ActionButton on:click={addNewInput} icon="Add">Add email</ActionButton> <ActionButton on:click={addNewInput} icon="Add">Add more</ActionButton>
</div> </div>
</ModalContent> </ModalContent>

View File

@ -36,7 +36,7 @@
}, },
role: { role: {
displayName: "Access", displayName: "Access",
width: "160px", width: "150px",
borderLeft: true, borderLeft: true,
}, },
} }
@ -50,6 +50,8 @@
let assignmentModal let assignmentModal
let appGroups let appGroups
let appUsers let appUsers
let showAddUsers = false
let showAddGroups = false
$: app = $overview.selectedApp $: app = $overview.selectedApp
$: devAppId = app.devId $: devAppId = app.devId
@ -153,6 +155,18 @@
await usersFetch.refresh() await usersFetch.refresh()
} }
const showUsersModal = () => {
showAddUsers = true
showAddGroups = false
assignmentModal.show()
}
const showGroupsModal = () => {
showAddUsers = false
showAddGroups = true
assignmentModal.show()
}
setContext("roles", { setContext("roles", {
updateRole, updateRole,
removeRole, removeRole,
@ -178,7 +192,7 @@
<Layout noPadding gap="S"> <Layout noPadding gap="S">
<div class="title"> <div class="title">
<Heading size="S">Users</Heading> <Heading size="S">Users</Heading>
<Button secondary on:click={assignmentModal.show}>Assign user</Button> <Button secondary on:click={showUsersModal}>Assign user</Button>
</div> </div>
<Table <Table
customPlaceholder customPlaceholder
@ -207,9 +221,7 @@
<Layout noPadding gap="S"> <Layout noPadding gap="S">
<div class="title"> <div class="title">
<Heading size="S">Groups</Heading> <Heading size="S">Groups</Heading>
<Button secondary on:click={assignmentModal.show}> <Button secondary on:click={showGroupsModal}>Assign group</Button>
Assign group
</Button>
</div> </div>
<Table <Table
customPlaceholder customPlaceholder
@ -228,7 +240,13 @@
</Layout> </Layout>
<Modal bind:this={assignmentModal}> <Modal bind:this={assignmentModal}>
<AssignmentModal {app} {appUsers} on:update={usersFetch.refresh} /> <AssignmentModal
{app}
{appUsers}
on:update={usersFetch.refresh}
showGroups={showAddGroups}
showUsers={showAddUsers}
/>
</Modal> </Modal>
<style> <style>

View File

@ -90,7 +90,7 @@
}, },
actions: { actions: {
displayName: null, displayName: null,
width: "5%", width: "auto",
}, },
} }