Prevent showing any mention of groups when groups are not enabled both the platform and license level
This commit is contained in:
parent
1f7784c6c0
commit
96e239c66c
|
@ -27,7 +27,6 @@
|
||||||
import { AppStatus } from "constants"
|
import { AppStatus } from "constants"
|
||||||
import Logo from "assets/bb-space-man.svg"
|
import Logo from "assets/bb-space-man.svg"
|
||||||
import AccessFilter from "./_components/AcessFilter.svelte"
|
import AccessFilter from "./_components/AcessFilter.svelte"
|
||||||
import { Constants } from "@budibase/frontend-core"
|
|
||||||
|
|
||||||
let sortBy = "name"
|
let sortBy = "name"
|
||||||
let template
|
let template
|
||||||
|
@ -69,10 +68,6 @@
|
||||||
$: unlocked = lockedApps?.length === 0
|
$: unlocked = lockedApps?.length === 0
|
||||||
$: automationErrors = getAutomationErrors(enrichedApps)
|
$: automationErrors = getAutomationErrors(enrichedApps)
|
||||||
|
|
||||||
$: hasGroupsLicense = $auth.user?.license.features.includes(
|
|
||||||
Constants.Features.USER_GROUPS
|
|
||||||
)
|
|
||||||
|
|
||||||
const enrichApps = (apps, user, sortBy) => {
|
const enrichApps = (apps, user, sortBy) => {
|
||||||
const enrichedApps = apps.map(app => ({
|
const enrichedApps = apps.map(app => ({
|
||||||
...app,
|
...app,
|
||||||
|
@ -360,7 +355,7 @@
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="filter">
|
<div class="filter">
|
||||||
{#if hasGroupsLicense && $groups.length}
|
{#if $auth.groupsEnabled && $groups.length}
|
||||||
<AccessFilter on:change={accessFilterAction} />
|
<AccessFilter on:change={accessFilterAction} />
|
||||||
{/if}
|
{/if}
|
||||||
<Select
|
<Select
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import { groups, auth } from "stores/portal"
|
import { groups, auth } from "stores/portal"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
import { Constants } from "@budibase/frontend-core"
|
|
||||||
import CreateEditGroupModal from "./_components/CreateEditGroupModal.svelte"
|
import CreateEditGroupModal from "./_components/CreateEditGroupModal.svelte"
|
||||||
import UserGroupsRow from "./_components/UserGroupsRow.svelte"
|
import UserGroupsRow from "./_components/UserGroupsRow.svelte"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
|
@ -27,10 +26,6 @@
|
||||||
let modal
|
let modal
|
||||||
let group = cloneDeep(DefaultGroup)
|
let group = cloneDeep(DefaultGroup)
|
||||||
|
|
||||||
$: hasGroupsLicense = $auth.user?.license.features.includes(
|
|
||||||
Constants.Features.USER_GROUPS
|
|
||||||
)
|
|
||||||
|
|
||||||
async function deleteGroup(group) {
|
async function deleteGroup(group) {
|
||||||
try {
|
try {
|
||||||
groups.actions.delete(group)
|
groups.actions.delete(group)
|
||||||
|
@ -54,7 +49,7 @@
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
try {
|
try {
|
||||||
if (hasGroupsLicense) {
|
if ($auth.groupsEnabled) {
|
||||||
await groups.actions.init()
|
await groups.actions.init()
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -67,7 +62,7 @@
|
||||||
<Layout gap="XS" noPadding>
|
<Layout gap="XS" noPadding>
|
||||||
<div style="display: flex;">
|
<div style="display: flex;">
|
||||||
<Heading size="M">User groups</Heading>
|
<Heading size="M">User groups</Heading>
|
||||||
{#if !hasGroupsLicense}
|
{#if !$auth.groupsEnabled}
|
||||||
<Tags>
|
<Tags>
|
||||||
<div class="tags">
|
<div class="tags">
|
||||||
<div class="tag">
|
<div class="tag">
|
||||||
|
@ -82,15 +77,15 @@
|
||||||
<div class="align-buttons">
|
<div class="align-buttons">
|
||||||
<Button
|
<Button
|
||||||
newStyles
|
newStyles
|
||||||
icon={hasGroupsLicense ? "UserGroup" : ""}
|
icon={$auth.groupsEnabled ? "UserGroup" : ""}
|
||||||
cta={hasGroupsLicense}
|
cta={$auth.groupsEnabled}
|
||||||
on:click={hasGroupsLicense
|
on:click={$auth.groupsEnabled
|
||||||
? showCreateGroupModal
|
? showCreateGroupModal
|
||||||
: window.open("https://budibase.com/pricing/", "_blank")}
|
: window.open("https://budibase.com/pricing/", "_blank")}
|
||||||
>
|
>
|
||||||
{hasGroupsLicense ? "Create user group" : "Upgrade Account"}
|
{$auth.groupsEnabled ? "Create user group" : "Upgrade Account"}
|
||||||
</Button>
|
</Button>
|
||||||
{#if !hasGroupsLicense}
|
{#if !$auth.groupsEnabled}
|
||||||
<Button
|
<Button
|
||||||
newStyles
|
newStyles
|
||||||
secondary
|
secondary
|
||||||
|
@ -101,7 +96,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if hasGroupsLicense && $groups.length}
|
{#if $auth.groupsEnabled && $groups.length}
|
||||||
<div class="groupTable">
|
<div class="groupTable">
|
||||||
{#each $groups as group}
|
{#each $groups as group}
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -42,18 +42,13 @@
|
||||||
let allAppList = []
|
let allAppList = []
|
||||||
let user
|
let user
|
||||||
let loaded = false
|
let loaded = false
|
||||||
$: fetchUser(userId)
|
|
||||||
|
|
||||||
|
$: fetchUser(userId)
|
||||||
$: fullName = $userFetch?.data?.firstName
|
$: fullName = $userFetch?.data?.firstName
|
||||||
? $userFetch?.data?.firstName + " " + $userFetch?.data?.lastName
|
? $userFetch?.data?.firstName + " " + $userFetch?.data?.lastName
|
||||||
: ""
|
: ""
|
||||||
|
|
||||||
$: hasGroupsLicense = $auth.user?.license.features.includes(
|
|
||||||
Constants.Features.USER_GROUPS
|
|
||||||
)
|
|
||||||
$: nameLabel = getNameLabel($userFetch)
|
$: nameLabel = getNameLabel($userFetch)
|
||||||
$: initials = getInitials(nameLabel)
|
$: initials = getInitials(nameLabel)
|
||||||
|
|
||||||
$: allAppList = $apps
|
$: allAppList = $apps
|
||||||
.filter(x => {
|
.filter(x => {
|
||||||
if ($userFetch.data?.roles) {
|
if ($userFetch.data?.roles) {
|
||||||
|
@ -86,7 +81,6 @@
|
||||||
return y._id === userId
|
return y._id === userId
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
$: globalRole = $userFetch?.data?.admin?.global
|
$: globalRole = $userFetch?.data?.admin?.global
|
||||||
? "admin"
|
? "admin"
|
||||||
: $userFetch?.data?.builder?.global
|
: $userFetch?.data?.builder?.global
|
||||||
|
@ -290,7 +284,7 @@
|
||||||
</Layout>
|
</Layout>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
||||||
{#if hasGroupsLicense}
|
{#if $auth.groupsEnabled}
|
||||||
<!-- User groups -->
|
<!-- User groups -->
|
||||||
<Layout gap="S" noPadding>
|
<Layout gap="S" noPadding>
|
||||||
<div class="tableTitle">
|
<div class="tableTitle">
|
||||||
|
|
|
@ -18,9 +18,6 @@
|
||||||
let disabled
|
let disabled
|
||||||
let userGroups = []
|
let userGroups = []
|
||||||
|
|
||||||
$: hasGroupsLicense = $auth.user?.license.features.includes(
|
|
||||||
Constants.Features.USER_GROUPS
|
|
||||||
)
|
|
||||||
$: userData = [
|
$: userData = [
|
||||||
{
|
{
|
||||||
email: "",
|
email: "",
|
||||||
|
@ -112,7 +109,7 @@
|
||||||
</div>
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
||||||
{#if hasGroupsLicense}
|
{#if $auth.groupsEnabled}
|
||||||
<Multiselect
|
<Multiselect
|
||||||
bind:value={userGroups}
|
bind:value={userGroups}
|
||||||
placeholder="No groups"
|
placeholder="No groups"
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
notifications,
|
notifications,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import { groups, auth, admin } from "stores/portal"
|
import { groups, auth, admin } from "stores/portal"
|
||||||
import { emailValidator } from "../../../../../../helpers/validation"
|
import { emailValidator } from "helpers/validation"
|
||||||
import { Constants } from "@budibase/frontend-core"
|
import { Constants } from "@budibase/frontend-core"
|
||||||
|
|
||||||
const BYTES_IN_MB = 1000000
|
const BYTES_IN_MB = 1000000
|
||||||
|
@ -22,9 +22,6 @@
|
||||||
let usersRole = null
|
let usersRole = null
|
||||||
|
|
||||||
$: invalidEmails = []
|
$: invalidEmails = []
|
||||||
$: hasGroupsLicense = $auth.user?.license.features.includes(
|
|
||||||
Constants.Features.USER_GROUPS
|
|
||||||
)
|
|
||||||
|
|
||||||
const validEmails = userEmails => {
|
const validEmails = userEmails => {
|
||||||
if ($admin.cloud && userEmails.length > MAX_USERS_UPLOAD_LIMIT) {
|
if ($admin.cloud && userEmails.length > MAX_USERS_UPLOAD_LIMIT) {
|
||||||
|
@ -95,7 +92,7 @@
|
||||||
options={Constants.BuilderRoleDescriptions}
|
options={Constants.BuilderRoleDescriptions}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if hasGroupsLicense}
|
{#if $auth.groupsEnabled}
|
||||||
<Multiselect
|
<Multiselect
|
||||||
bind:value={userGroups}
|
bind:value={userGroups}
|
||||||
placeholder="No groups"
|
placeholder="No groups"
|
||||||
|
|
|
@ -25,21 +25,17 @@
|
||||||
import PasswordModal from "./_components/PasswordModal.svelte"
|
import PasswordModal from "./_components/PasswordModal.svelte"
|
||||||
import ImportUsersModal from "./_components/ImportUsersModal.svelte"
|
import ImportUsersModal from "./_components/ImportUsersModal.svelte"
|
||||||
import { createPaginationStore } from "helpers/pagination"
|
import { createPaginationStore } from "helpers/pagination"
|
||||||
import { Constants } from "@budibase/frontend-core"
|
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
|
|
||||||
//let email
|
|
||||||
let enrichedUsers = []
|
let enrichedUsers = []
|
||||||
let createUserModal,
|
let createUserModal,
|
||||||
inviteConfirmationModal,
|
inviteConfirmationModal,
|
||||||
onboardingTypeModal,
|
onboardingTypeModal,
|
||||||
passwordModal,
|
passwordModal,
|
||||||
importUsersModal
|
importUsersModal
|
||||||
|
|
||||||
let pageInfo = createPaginationStore()
|
let pageInfo = createPaginationStore()
|
||||||
let prevEmail = undefined,
|
let prevEmail = undefined,
|
||||||
searchEmail = undefined
|
searchEmail = undefined
|
||||||
|
|
||||||
let selectedRows = []
|
let selectedRows = []
|
||||||
let customRenderers = [
|
let customRenderers = [
|
||||||
{ column: "userGroups", component: GroupsTableRenderer },
|
{ column: "userGroups", component: GroupsTableRenderer },
|
||||||
|
@ -47,23 +43,17 @@
|
||||||
{ column: "role", component: RoleTableRenderer },
|
{ column: "role", component: RoleTableRenderer },
|
||||||
]
|
]
|
||||||
|
|
||||||
$: hasGroupsLicense = $auth.user?.license.features.includes(
|
|
||||||
Constants.Features.USER_GROUPS
|
|
||||||
)
|
|
||||||
|
|
||||||
$: schema = {
|
$: schema = {
|
||||||
email: {},
|
email: {},
|
||||||
role: {
|
role: {
|
||||||
sortable: false,
|
sortable: false,
|
||||||
},
|
},
|
||||||
...(hasGroupsLicense && {
|
...($auth.groupsEnabled && {
|
||||||
userGroups: { sortable: false, displayName: "User groups" },
|
userGroups: { sortable: false, displayName: "Groups" },
|
||||||
}),
|
}),
|
||||||
apps: {},
|
apps: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
$: userData = []
|
$: userData = []
|
||||||
|
|
||||||
$: page = $pageInfo.page
|
$: page = $pageInfo.page
|
||||||
$: fetchUsers(page, searchEmail)
|
$: fetchUsers(page, searchEmail)
|
||||||
$: {
|
$: {
|
||||||
|
@ -86,6 +76,7 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const showOnboardingTypeModal = async addUsersData => {
|
const showOnboardingTypeModal = async addUsersData => {
|
||||||
userData = await removingDuplicities(addUsersData)
|
userData = await removingDuplicities(addUsersData)
|
||||||
if (!userData?.users?.length) return
|
if (!userData?.users?.length) return
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
import { users, groups, apps, auth } from "stores/portal"
|
import { users, groups, apps, auth } from "stores/portal"
|
||||||
import AssignmentModal from "./AssignmentModal.svelte"
|
import AssignmentModal from "./AssignmentModal.svelte"
|
||||||
import { createPaginationStore } from "helpers/pagination"
|
import { createPaginationStore } from "helpers/pagination"
|
||||||
import { Constants } from "@budibase/frontend-core"
|
|
||||||
import { roles } from "stores/backend"
|
import { roles } from "stores/backend"
|
||||||
|
|
||||||
export let app
|
export let app
|
||||||
|
|
||||||
let assignmentModal
|
let assignmentModal
|
||||||
let appGroups = []
|
let appGroups = []
|
||||||
let appUsers = []
|
let appUsers = []
|
||||||
|
@ -28,14 +28,9 @@
|
||||||
search = undefined
|
search = undefined
|
||||||
let pageInfo = createPaginationStore()
|
let pageInfo = createPaginationStore()
|
||||||
let fixedAppId
|
let fixedAppId
|
||||||
|
|
||||||
$: page = $pageInfo.page
|
$: page = $pageInfo.page
|
||||||
|
|
||||||
$: hasGroupsLicense = $auth.user?.license.features.includes(
|
|
||||||
Constants.Features.USER_GROUPS
|
|
||||||
)
|
|
||||||
|
|
||||||
$: fixedAppId = apps.getProdAppID(app.devId)
|
$: fixedAppId = apps.getProdAppID(app.devId)
|
||||||
|
|
||||||
$: appGroups = $groups.filter(x => {
|
$: appGroups = $groups.filter(x => {
|
||||||
return x.apps.includes(app.appId)
|
return x.apps.includes(app.appId)
|
||||||
})
|
})
|
||||||
|
@ -161,7 +156,7 @@
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{#if hasGroupsLicense && appGroups.length}
|
{#if $auth.groupsEnabled && appGroups.length}
|
||||||
<List title="User Groups">
|
<List title="User Groups">
|
||||||
{#each appGroups as group}
|
{#each appGroups as group}
|
||||||
<ListItem
|
<ListItem
|
||||||
|
|
|
@ -7,19 +7,21 @@
|
||||||
notifications,
|
notifications,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import { roles } from "stores/backend"
|
import { roles } from "stores/backend"
|
||||||
import { groups, users } from "stores/portal"
|
import { groups, users, auth } from "stores/portal"
|
||||||
import { RoleUtils } from "@budibase/frontend-core"
|
import { RoleUtils } from "@budibase/frontend-core"
|
||||||
import { createPaginationStore } from "helpers/pagination"
|
import { createPaginationStore } from "helpers/pagination"
|
||||||
|
|
||||||
export let app
|
export let app
|
||||||
export let addData
|
export let addData
|
||||||
export let appUsers = []
|
export let appUsers = []
|
||||||
|
|
||||||
let prevSearch = undefined,
|
let prevSearch = undefined,
|
||||||
search = undefined
|
search = undefined
|
||||||
let pageInfo = createPaginationStore()
|
let pageInfo = createPaginationStore()
|
||||||
|
|
||||||
$: page = $pageInfo.page
|
$: page = $pageInfo.page
|
||||||
$: fetchUsers(page, search)
|
$: fetchUsers(page, search)
|
||||||
|
|
||||||
async function fetchUsers(page, search) {
|
async function fetchUsers(page, search) {
|
||||||
if ($pageInfo.loading) {
|
if ($pageInfo.loading) {
|
||||||
return
|
return
|
||||||
|
@ -46,15 +48,16 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
$: optionSections = {
|
$: optionSections = {
|
||||||
...(filteredGroups.length && {
|
...($auth.groupsEnabled &&
|
||||||
groups: {
|
filteredGroups.length && {
|
||||||
data: filteredGroups,
|
groups: {
|
||||||
getLabel: group => group.name,
|
data: filteredGroups,
|
||||||
getValue: group => group._id,
|
getLabel: group => group.name,
|
||||||
getIcon: group => group.icon,
|
getValue: group => group._id,
|
||||||
getColour: group => group.color,
|
getIcon: group => group.icon,
|
||||||
},
|
getColour: group => group.color,
|
||||||
}),
|
},
|
||||||
|
}),
|
||||||
users: {
|
users: {
|
||||||
data: $users.data.filter(u => !appUsers.find(x => x._id === u._id)),
|
data: $users.data.filter(u => !appUsers.find(x => x._id === u._id)),
|
||||||
getLabel: user => user.email,
|
getLabel: user => user.email,
|
||||||
|
|
|
@ -2,6 +2,8 @@ import { derived, writable, get } from "svelte/store"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { admin } from "stores/portal"
|
import { admin } from "stores/portal"
|
||||||
import analytics from "analytics"
|
import analytics from "analytics"
|
||||||
|
import { FEATURE_FLAGS } from "helpers/featureFlags"
|
||||||
|
import { Constants } from "@budibase/frontend-core"
|
||||||
|
|
||||||
export function createAuthStore() {
|
export function createAuthStore() {
|
||||||
const auth = writable({
|
const auth = writable({
|
||||||
|
@ -10,11 +12,13 @@ export function createAuthStore() {
|
||||||
tenantSet: false,
|
tenantSet: false,
|
||||||
loaded: false,
|
loaded: false,
|
||||||
postLogout: false,
|
postLogout: false,
|
||||||
|
groupsEnabled: false,
|
||||||
})
|
})
|
||||||
const store = derived(auth, $store => {
|
const store = derived(auth, $store => {
|
||||||
let initials = null
|
let initials = null
|
||||||
let isAdmin = false
|
let isAdmin = false
|
||||||
let isBuilder = false
|
let isBuilder = false
|
||||||
|
let groupsEnabled = false
|
||||||
if ($store.user) {
|
if ($store.user) {
|
||||||
const user = $store.user
|
const user = $store.user
|
||||||
if (user.firstName) {
|
if (user.firstName) {
|
||||||
|
@ -29,6 +33,9 @@ export function createAuthStore() {
|
||||||
}
|
}
|
||||||
isAdmin = !!user.admin?.global
|
isAdmin = !!user.admin?.global
|
||||||
isBuilder = !!user.builder?.global
|
isBuilder = !!user.builder?.global
|
||||||
|
groupsEnabled =
|
||||||
|
user?.license.features.includes(Constants.Features.USER_GROUPS) &&
|
||||||
|
user?.featureFlags.includes(FEATURE_FLAGS.USER_GROUPS)
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
user: $store.user,
|
user: $store.user,
|
||||||
|
@ -39,6 +46,7 @@ export function createAuthStore() {
|
||||||
initials,
|
initials,
|
||||||
isAdmin,
|
isAdmin,
|
||||||
isBuilder,
|
isBuilder,
|
||||||
|
groupsEnabled,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue