pr comments and bug fixes
This commit is contained in:
parent
7c8914207b
commit
ddf9e734f4
|
@ -23,7 +23,6 @@
|
|||
|
||||
const dispatch = createEventDispatcher()
|
||||
const RemoveID = "remove"
|
||||
const CreatorID = "CREATOR"
|
||||
|
||||
$: options = getOptions(
|
||||
$roles,
|
||||
|
@ -47,7 +46,7 @@
|
|||
if (allowCreator) {
|
||||
newRoles = [
|
||||
{
|
||||
_id: CreatorID,
|
||||
_id: Constants.Roles.CREATOR,
|
||||
name: "Creator",
|
||||
tag:
|
||||
!$licensing.perAppBuildersEnabled &&
|
||||
|
@ -88,8 +87,6 @@
|
|||
const onChange = e => {
|
||||
if (allowRemove && e.detail === RemoveID) {
|
||||
dispatch("remove")
|
||||
} else if (e.detail === CreatorID) {
|
||||
dispatch("addcreator")
|
||||
} else {
|
||||
dispatch("change", e.detail)
|
||||
}
|
||||
|
@ -112,7 +109,8 @@
|
|||
getOptionColour={getColor}
|
||||
getOptionIcon={getIcon}
|
||||
isOptionEnabled={option =>
|
||||
option._id !== CreatorID || $licensing.perAppBuildersEnabled}
|
||||
option._id !== Constants.Roles.CREATOR ||
|
||||
$licensing.perAppBuildersEnabled}
|
||||
{placeholder}
|
||||
{error}
|
||||
/>
|
||||
|
@ -131,7 +129,8 @@
|
|||
getOptionColour={getColor}
|
||||
getOptionIcon={getIcon}
|
||||
isOptionEnabled={option =>
|
||||
option._id !== CreatorID || $licensing.perAppBuildersEnabled}
|
||||
option._id !== Constants.Roles.CREATOR ||
|
||||
$licensing.perAppBuildersEnabled}
|
||||
{placeholder}
|
||||
{error}
|
||||
/>
|
||||
|
|
|
@ -81,17 +81,15 @@
|
|||
filteredInvites.sort(sortInviteRoles)
|
||||
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)
|
||||
})
|
||||
.sort(sortInviteRoles)
|
||||
filteredInvites = appInvites.filter(invite => {
|
||||
const inviteInfo = invite.info?.apps
|
||||
if (!query && inviteInfo && prodAppId) {
|
||||
return Object.keys(inviteInfo).includes(prodAppId)
|
||||
}
|
||||
return invite.email.includes(query)
|
||||
})
|
||||
filteredInvites.sort(sortInviteRoles)
|
||||
}
|
||||
|
||||
$: filterByAppAccess, prodAppId, filterInvites(query)
|
||||
$: if (searchFocus === true) {
|
||||
filterByAppAccess = false
|
||||
|
@ -122,21 +120,22 @@
|
|||
await usersFetch.refresh()
|
||||
|
||||
filteredUsers = $usersFetch.rows
|
||||
.filter(user => !user?.admin?.global) // filter out global admins
|
||||
.map(user => {
|
||||
const isAdminOrGlobalBuilder = sdk.users.isAdminOrGlobalBuilder(
|
||||
user,
|
||||
prodAppId
|
||||
)
|
||||
const isAppBuilder = sdk.users.hasAppBuilderPermissions(user, prodAppId)
|
||||
let role = undefined
|
||||
let role
|
||||
if (isAdminOrGlobalBuilder) {
|
||||
role = Constants.Roles.ADMIN
|
||||
} else if (isAppBuilder) {
|
||||
role = Constants.Roles.CREATOR
|
||||
} else {
|
||||
const appRole = Object.keys(user.roles).find(x => x === prodAppId)
|
||||
const appRole = user.roles[prodAppId]
|
||||
if (appRole) {
|
||||
role = user.roles[appRole]
|
||||
role = appRole
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -617,9 +616,6 @@
|
|||
allowPublic={false}
|
||||
allowCreator={true}
|
||||
quiet={true}
|
||||
on:addcreator={() => {
|
||||
onUpdateUserInvite(invite, Constants.Roles.CREATOR)
|
||||
}}
|
||||
on:change={e => {
|
||||
onUpdateUserInvite(invite, e.detail)
|
||||
}}
|
||||
|
@ -673,10 +669,11 @@
|
|||
quiet={true}
|
||||
allowCreator={true}
|
||||
on:change={e => {
|
||||
onUpdateGroup(group, e.detail)
|
||||
}}
|
||||
on:addcreator={() => {
|
||||
addGroupAppBuilder(group._id)
|
||||
if (e.detail === Constants.Roles.CREATOR) {
|
||||
addGroupAppBuilder(group._id)
|
||||
} else {
|
||||
onUpdateGroup(group, e.detail)
|
||||
}
|
||||
}}
|
||||
on:remove={() => {
|
||||
onUpdateGroup(group)
|
||||
|
@ -712,11 +709,13 @@
|
|||
allowPublic={false}
|
||||
allowCreator={true}
|
||||
quiet={true}
|
||||
on:addcreator={() => {
|
||||
addAppBuilder(user._id)
|
||||
}}
|
||||
on:addcreator={() => {}}
|
||||
on:change={e => {
|
||||
onUpdateUser(user, e.detail)
|
||||
if (e.detail === Constants.Roles.CREATOR) {
|
||||
addAppBuilder(user._id)
|
||||
} else {
|
||||
onUpdateUser(user, e.detail)
|
||||
}
|
||||
}}
|
||||
on:remove={() => {
|
||||
onUpdateUser(user)
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
import GroupIcon from "./_components/GroupIcon.svelte"
|
||||
import GroupUsers from "./_components/GroupUsers.svelte"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
import { Constants } from "@budibase/frontend-core"
|
||||
|
||||
export let groupId
|
||||
|
||||
|
@ -45,7 +46,7 @@
|
|||
|
||||
let loaded = false
|
||||
let editModal, deleteModal
|
||||
|
||||
$: console.log(group)
|
||||
$: scimEnabled = $features.isScimEnabled
|
||||
$: readonly = !sdk.users.isAdmin($auth.user) || scimEnabled
|
||||
$: group = $groups.find(x => x._id === groupId)
|
||||
|
@ -57,8 +58,11 @@
|
|||
)
|
||||
.map(app => ({
|
||||
...app,
|
||||
role: group?.roles?.[apps.getProdAppID(app.devId)],
|
||||
role: group?.builder?.apps.includes(apps.getProdAppID(app.devId))
|
||||
? Constants.Roles.CREATOR
|
||||
: group?.roles?.[apps.getProdAppID(app.devId)],
|
||||
}))
|
||||
$: console.log(groupApps)
|
||||
$: {
|
||||
if (loaded && !group?._id) {
|
||||
$goto("./")
|
||||
|
|
|
@ -1,9 +1,19 @@
|
|||
<script>
|
||||
import { Icon } from "@budibase/bbui"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
|
||||
export let value
|
||||
export let row
|
||||
$: count = getCount(Object.keys(value || {}).length)
|
||||
|
||||
$: count = Object.keys(value || {}).length
|
||||
const getCount = () => {
|
||||
return sdk.users.hasAppBuilderPermissions(row)
|
||||
? row.builder.apps.length +
|
||||
Object.keys(row.roles || {}).filter(appId =>
|
||||
row.builder.apps.includes(appId)
|
||||
).length
|
||||
: value?.length || 0
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="align">
|
||||
|
|
|
@ -120,11 +120,7 @@
|
|||
name: app.name,
|
||||
devId: app.devId,
|
||||
icon: app.icon,
|
||||
role: privileged
|
||||
? Constants.Roles.ADMIN
|
||||
: user?.builder?.apps.includes(prodAppId)
|
||||
? Constants.Roles.CREATOR
|
||||
: roles[prodAppId],
|
||||
role: getRole(prodAppId, roles),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -137,6 +133,18 @@
|
|||
return groups.filter(group => group.name?.toLowerCase().includes(search))
|
||||
}
|
||||
|
||||
const getRole = (prodAppId, roles) => {
|
||||
if (privileged) {
|
||||
return Constants.Roles.ADMIN
|
||||
}
|
||||
|
||||
if (user?.builder?.apps.includes(prodAppId)) {
|
||||
return Constants.Roles.CREATOR
|
||||
}
|
||||
|
||||
return roles[prodAppId]
|
||||
}
|
||||
|
||||
const getNameLabel = user => {
|
||||
const { firstName, lastName, email } = user || {}
|
||||
if (!firstName && !lastName) {
|
||||
|
|
|
@ -5,13 +5,22 @@
|
|||
|
||||
export let value
|
||||
export let row
|
||||
|
||||
$: console.log(row)
|
||||
$: priviliged = sdk.users.isAdminOrBuilder(row)
|
||||
$: count = priviliged
|
||||
? $apps.length
|
||||
: sdk.users.hasAppBuilderPermissions(row)
|
||||
? row?.builder?.apps?.length
|
||||
: value?.length || 0
|
||||
$: count = getCount(row)
|
||||
|
||||
const getCount = () => {
|
||||
if (priviliged) {
|
||||
return $apps.length
|
||||
} else {
|
||||
return sdk.users.hasAppBuilderPermissions(row)
|
||||
? row.builder.apps.length +
|
||||
Object.keys(row.roles || {}).filter(appId =>
|
||||
row.builder.apps.includes(appId)
|
||||
).length
|
||||
: value?.length || 0
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="align">
|
||||
|
|
|
@ -78,7 +78,11 @@ export function createGroupsStore() {
|
|||
},
|
||||
|
||||
getGroupAppIds: group => {
|
||||
return Object.keys(group?.roles || {})
|
||||
let groupAppIds = Object.keys(group?.roles || {})
|
||||
if (group?.builder?.apps) {
|
||||
groupAppIds = groupAppIds.concat(group.builder.apps)
|
||||
}
|
||||
return groupAppIds
|
||||
},
|
||||
|
||||
addGroupAppBuilder: async (groupId, appId) => {
|
||||
|
|
|
@ -163,7 +163,7 @@ export const buildUserEndpoints = API => ({
|
|||
admin: admin ? { global: true } : undefined,
|
||||
builder: builder ? { global: true } : undefined,
|
||||
apps: apps ? apps : undefined,
|
||||
appBuilders: appBuilders ? appBuilders : undefined,
|
||||
appBuilders,
|
||||
},
|
||||
}
|
||||
}),
|
||||
|
@ -181,7 +181,7 @@ export const buildUserEndpoints = API => ({
|
|||
url: `/api/global/users/invite/update/${invite.code}`,
|
||||
body: {
|
||||
apps: invite.apps,
|
||||
appBuilders: invite.appBuilders ? invite.appBuilders : undefined,
|
||||
appBuilders: invite.appBuilders,
|
||||
},
|
||||
})
|
||||
},
|
||||
|
|
|
@ -417,6 +417,7 @@ export const inviteAccept = async (
|
|||
if (info.appBuilders) {
|
||||
builder.apps = info.appBuilders
|
||||
request.builder = builder
|
||||
delete info.appBuilders
|
||||
}
|
||||
delete info.apps
|
||||
request = {
|
||||
|
|
Loading…
Reference in New Issue