From ac34f1129c43d1393a94c886051c63b71b576b60 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Tue, 29 Aug 2023 21:54:15 +0100 Subject: [PATCH] code tidy up --- .../src/components/common/RoleSelect.svelte | 20 ++--- .../_components/BuilderSidePanel.svelte | 80 ++++++++++++------- 2 files changed, 54 insertions(+), 46 deletions(-) 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 @@
No user found
- Add a valid email to invite a new user + Try searching a different email or invite a new user
-
- {query || ""} - - Add user - -
{/if} @@ -752,6 +759,7 @@ value={query} on:change={e => { email = e.detail + query = e.detail }} validate={() => { if (!email) { @@ -770,7 +778,7 @@ )} label="Role" /> - {#if creationRoleType !== Constants.Roles.ADMIN} + {#if creationRoleType !== Constants.BudibaseRoles.Admin} {/if} - {#if creationRoleType === Constants.Roles.ADMIN} + {#if creationRoleType === Constants.BudibaseRoles.Admin}
Admins will get full access to all apps and settings
{/if} - + @@ -818,15 +831,20 @@ } .admin-info { - padding: var(--spacing-l) var(--spacing-l) var(--spacing-xs) - var(--spacing-l); + margin-top: var(--spacing-xl); + padding: var(--spacing-l) var(--spacing-l) var(--spacing-l) var(--spacing-l); display: flex; align-items: center; gap: var(--spacing-xl); - height: 50px; + height: 30px; background-color: var(--background-alt); } + .underlined { + text-decoration: underline; + cursor: pointer; + } + .search-input { flex: 1; }