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