diff --git a/packages/builder/src/components/common/RoleSelect.svelte b/packages/builder/src/components/common/RoleSelect.svelte index cef032f7c5..b856048714 100644 --- a/packages/builder/src/components/common/RoleSelect.svelte +++ b/packages/builder/src/components/common/RoleSelect.svelte @@ -48,7 +48,7 @@ { _id: CreatorID, name: "Creator", - tag: !$licensing.perAppBuildersEnabled && "Business", + tag: !$licensing.perAppBuildersEnabled && Constants.PlanType.BUSINESS, }, ...newRoles, ] @@ -108,13 +108,8 @@ getOptionValue={role => role._id} getOptionColour={getColor} getOptionIcon={getIcon} - isOptionEnabled={option => { - if (option._id == CreatorID && !$licensing.perAppBuildersEnabled) { - return false - } else { - return true - } - }} + isOptionEnabled={option => + option._id !== CreatorID || $licensing.perAppBuildersEnabled} {placeholder} {error} /> @@ -132,13 +127,8 @@ getOptionValue={role => role._id} getOptionColour={getColor} getOptionIcon={getIcon} - isOptionEnabled={option => { - if (option._id == CreatorID && !$licensing.perAppBuildersEnabled) { - return false - } else { - return true - } - }} + isOptionEnabled={option => + option._id !== CreatorID || $licensing.perAppBuildersEnabled} {placeholder} {error} /> diff --git a/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte b/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte index 5515e366ac..fe2d2fb482 100644 --- a/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte +++ b/packages/builder/src/pages/builder/app/[application]/_components/BuilderSidePanel.svelte @@ -80,16 +80,18 @@ if (!filterByAppAccess && !query) { filteredInvites = appInvites.length > 100 ? appInvites.slice(0, 100) : [...appInvites] + 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) - }) + 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) } $: filterByAppAccess, prodAppId, filterInvites(query) @@ -150,6 +152,19 @@ .sort(sortRoles) } + const sortInviteRoles = (a, b) => { + const aIsEmpty = !a.info.apps || Object.keys(a.info.apps).length === 0 + const bIsEmpty = !b.info.apps || Object.keys(b.info.apps).length === 0 + + return aIsEmpty + ? bIsEmpty + ? 0 + : 1 // Put items with empty "apps" at the bottom + : bIsEmpty + ? -1 + : 0 // Put items with non-empty "apps" above the empty ones + } + const sortRoles = (a, b) => { const roleA = a.role const roleB = b.role @@ -357,10 +372,8 @@ const payload = [ { email: newUserEmail, - builder: - creationRoleType === Constants.BudibaseRoles.Admin ? true : false, - admin: - creationRoleType === Constants.BudibaseRoles.Admin ? true : false, + builder: !!creationRoleType === Constants.BudibaseRoles.Admin, + admin: !!creationRoleType === Constants.BudibaseRoles.Admin, }, ] @@ -387,6 +400,7 @@ } const onInviteUser = async () => { + form.validate() userOnboardResponse = await inviteUser() const originalQuery = query + "" query = null @@ -563,21 +577,14 @@