updating license check to search for feature
This commit is contained in:
parent
2c16089258
commit
ea061e6ab1
|
@ -8,7 +8,7 @@
|
|||
"editor.defaultFormatter": "vscode.json-language-features"
|
||||
},
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "vscode.typescript-language-features"
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"debug.javascript.terminalOptions": {
|
||||
"skipFiles": [
|
||||
|
@ -16,7 +16,4 @@
|
|||
"<node_internals>/**"
|
||||
]
|
||||
},
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "vscode.typescript-language-features"
|
||||
},
|
||||
}
|
||||
|
|
|
@ -69,7 +69,9 @@
|
|||
$: unlocked = lockedApps?.length === 0
|
||||
$: automationErrors = getAutomationErrors(enrichedApps)
|
||||
|
||||
$: isProPlan = $auth.user?.license.plan.type !== Constants.PlanType.FREE
|
||||
$: hasGroupsLicense = $auth.user?.license.features.includes(
|
||||
Constants.Features.USER_GROUPS
|
||||
)
|
||||
|
||||
const enrichApps = (apps, user, sortBy) => {
|
||||
const enrichedApps = apps.map(app => ({
|
||||
|
@ -358,7 +360,7 @@
|
|||
</Button>
|
||||
{/if}
|
||||
<div class="filter">
|
||||
{#if isProPlan && $groups.length}
|
||||
{#if hasGroupsLicense && $groups.length}
|
||||
<AccessFilter on:change={accessFilterAction} />
|
||||
{/if}
|
||||
<Select
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
$: page = $pageInfo.page
|
||||
$: fetchUsers(page, search)
|
||||
$: group = $groups.find(x => x._id === groupId)
|
||||
$: console.log(group.users)
|
||||
|
||||
async function addAll() {
|
||||
group.users = selectedUsers
|
||||
await groups.actions.save(group)
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
import CreateEditGroupModal from "./_components/CreateEditGroupModal.svelte"
|
||||
import UserGroupsRow from "./_components/UserGroupsRow.svelte"
|
||||
|
||||
$: isProPlan = $auth.user?.license.plan.type !== Constants.PlanType.FREE
|
||||
$: hasGroupsLicense = $auth.user?.license.features.includes(
|
||||
Constants.Features.USER_GROUPS
|
||||
)
|
||||
|
||||
let modal
|
||||
let group = {
|
||||
|
@ -45,7 +47,9 @@
|
|||
|
||||
onMount(async () => {
|
||||
try {
|
||||
if (hasGroupsLicense) {
|
||||
await groups.actions.init()
|
||||
}
|
||||
} catch (error) {
|
||||
notifications.error("Error getting User groups")
|
||||
}
|
||||
|
@ -56,7 +60,7 @@
|
|||
<Layout gap="XS" noPadding>
|
||||
<div style="display: flex;">
|
||||
<Heading size="M">User groups</Heading>
|
||||
{#if !isProPlan}
|
||||
{#if !hasGroupsLicense}
|
||||
<Tags>
|
||||
<div class="tags">
|
||||
<div class="tag">
|
||||
|
@ -71,14 +75,14 @@
|
|||
<div class="align-buttons">
|
||||
<Button
|
||||
newStyles
|
||||
icon={isProPlan ? "UserGroup" : ""}
|
||||
cta={isProPlan}
|
||||
on:click={isProPlan
|
||||
icon={hasGroupsLicense ? "UserGroup" : ""}
|
||||
cta={hasGroupsLicense}
|
||||
on:click={hasGroupsLicense
|
||||
? () => modal.show()
|
||||
: window.open("https://budibase.com/pricing/", "_blank")}
|
||||
>{isProPlan ? "Create user group" : "Upgrade Account"}</Button
|
||||
>{hasGroupsLicense ? "Create user group" : "Upgrade Account"}</Button
|
||||
>
|
||||
{#if !isProPlan}
|
||||
{#if !hasGroupsLicense}
|
||||
<Button
|
||||
newStyles
|
||||
secondary
|
||||
|
@ -89,7 +93,7 @@
|
|||
{/if}
|
||||
</div>
|
||||
|
||||
{#if isProPlan}
|
||||
{#if hasGroupsLicense}
|
||||
<div class="groupTable">
|
||||
{#each $groups as group}
|
||||
<div>
|
||||
|
|
|
@ -41,7 +41,9 @@
|
|||
let allAppList = []
|
||||
|
||||
$: user = users.get(userId)
|
||||
$: isProPlan = $auth.user?.license.plan.type !== Constants.PlanType.FREE
|
||||
$: hasGroupsLicense = $auth.user?.license.features.includes(
|
||||
Constants.Features.USER_GROUPS
|
||||
)
|
||||
|
||||
$: allAppList = $apps
|
||||
.filter(x => {
|
||||
|
@ -70,7 +72,6 @@
|
|||
selectedGroups &&
|
||||
group?.name?.toLowerCase().includes(searchTerm.toLowerCase())
|
||||
)
|
||||
$: console.log($groups)
|
||||
$: userGroups = $groups.filter(x => {
|
||||
return x.users?.find(y => {
|
||||
return y._id === userId
|
||||
|
@ -236,7 +237,7 @@
|
|||
</div>
|
||||
</Layout>
|
||||
|
||||
{#if isProPlan}
|
||||
{#if hasGroupsLicense}
|
||||
<!-- User groups -->
|
||||
<Layout gap="XS" noPadding>
|
||||
<div class="tableTitle">
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
let disabled
|
||||
let userGroups = []
|
||||
|
||||
$: isProPlan = $auth.user?.license.plan.type !== Constants.PlanType.FREE
|
||||
$: hasGroupsLicense = $auth.user?.license.features.includes(
|
||||
Constants.Features.USER_GROUPS
|
||||
)
|
||||
|
||||
$: userData = [
|
||||
{
|
||||
|
@ -65,7 +67,7 @@
|
|||
</div>
|
||||
</Layout>
|
||||
|
||||
{#if isProPlan}
|
||||
{#if hasGroupsLicense}
|
||||
<Multiselect
|
||||
bind:value={userGroups}
|
||||
placeholder="Select User Groups"
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
let usersRole = null
|
||||
|
||||
$: invalidEmails = []
|
||||
$: isProPlan = $auth.user?.license.plan.type !== Constants.PlanType.FREE
|
||||
$: hasGroupsLicense = $auth.user?.license.features.includes(
|
||||
Constants.Features.USER_GROUPS
|
||||
)
|
||||
|
||||
const validEmails = userEmails => {
|
||||
for (const email of userEmails) {
|
||||
|
@ -87,7 +89,7 @@
|
|||
options={Constants.BuilderRoleDescriptions}
|
||||
/>
|
||||
|
||||
{#if isProPlan}
|
||||
{#if hasGroupsLicense}
|
||||
<Multiselect
|
||||
bind:value={userGroups}
|
||||
placeholder="Select User Groups"
|
||||
|
|
|
@ -64,7 +64,9 @@
|
|||
{ column: "role", component: RoleTableRenderer },
|
||||
]
|
||||
|
||||
$: isProPlan = $auth.user?.license.plan.type !== Constants.PlanType.FREE
|
||||
$: hasGroupsLicense = $auth.user?.license.features.includes(
|
||||
Constants.Features.USER_GROUPS
|
||||
)
|
||||
|
||||
$: schema = {
|
||||
name: {},
|
||||
|
@ -73,7 +75,7 @@
|
|||
noPropagation: true,
|
||||
sortable: false,
|
||||
},
|
||||
...(isProPlan && {
|
||||
...(hasGroupsLicense && {
|
||||
userGroups: { sortable: false, displayName: "User groups" },
|
||||
}),
|
||||
apps: { width: "120px" },
|
||||
|
|
|
@ -31,7 +31,9 @@
|
|||
$: page = $pageInfo.page
|
||||
$: fetchUsers(page, search)
|
||||
|
||||
$: isProPlan = $auth.user?.license.plan.type !== Constants.PlanType.FREE
|
||||
$: hasGroupsLicense = $auth.user?.license.features.includes(
|
||||
Constants.Features.USER_GROUPS
|
||||
)
|
||||
|
||||
$: appUsers =
|
||||
$users.data?.filter(x => {
|
||||
|
@ -158,7 +160,7 @@
|
|||
>
|
||||
</div>
|
||||
</div>
|
||||
{#if isProPlan && appGroups.length}
|
||||
{#if hasGroupsLicense && appGroups.length}
|
||||
<List title="User Groups">
|
||||
{#each appGroups as group}
|
||||
<ListItem
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { writable } from "svelte/store"
|
||||
import { writable, get } from "svelte/store"
|
||||
import { API } from "api"
|
||||
import { auth } from "stores/portal"
|
||||
import { Constants } from "@budibase/frontend-core"
|
||||
|
||||
export function createGroupsStore() {
|
||||
const DEFAULT_CONFIG = {
|
||||
|
@ -15,8 +17,14 @@ export function createGroupsStore() {
|
|||
|
||||
const actions = {
|
||||
init: async () => {
|
||||
// only init if these is a groups license, just to be sure but the feature will be blocked
|
||||
// on the backend anyway
|
||||
if (
|
||||
get(auth).user.license.features.includes(Constants.Features.USER_GROUPS)
|
||||
) {
|
||||
const users = await API.getGroups()
|
||||
store.set(users)
|
||||
}
|
||||
},
|
||||
|
||||
save: async group => {
|
||||
|
|
|
@ -99,6 +99,10 @@ export const PlanType = {
|
|||
*/
|
||||
export const ApiVersion = "1"
|
||||
|
||||
export const Features = {
|
||||
USER_GROUPS: "userGroups",
|
||||
}
|
||||
|
||||
// Role IDs
|
||||
export const Roles = {
|
||||
ADMIN: "ADMIN",
|
||||
|
|
|
@ -33,6 +33,7 @@ describe("/users", () => {
|
|||
.expect(200)
|
||||
|
||||
expect(res.body.length).toBe(3)
|
||||
console.debug('test: ' + JSON.stringify(res.body))
|
||||
expect(res.body.find(u => u._id === `ro_ta_users_us_uuidx`)).toBeDefined()
|
||||
expect(res.body.find(u => u._id === `ro_ta_users_us_uuidy`)).toBeDefined()
|
||||
})
|
||||
|
|
|
@ -11,7 +11,9 @@ const tenantsRoutes = require("./system/tenants")
|
|||
const statusRoutes = require("./system/status")
|
||||
const selfRoutes = require("./global/self")
|
||||
const licenseRoutes = require("./global/license")
|
||||
const userGroupRoutes = require("./global/groups")
|
||||
const { api } = require("@budibase/pro")
|
||||
|
||||
let userGroupRoutes = api.groups
|
||||
exports.routes = [
|
||||
configRoutes,
|
||||
userRoutes,
|
||||
|
|
Loading…
Reference in New Issue