code tidy up
This commit is contained in:
parent
f456210224
commit
ac34f1129c
|
@ -48,7 +48,7 @@
|
||||||
{
|
{
|
||||||
_id: CreatorID,
|
_id: CreatorID,
|
||||||
name: "Creator",
|
name: "Creator",
|
||||||
tag: !$licensing.perAppBuildersEnabled && "Business",
|
tag: !$licensing.perAppBuildersEnabled && Constants.PlanType.BUSINESS,
|
||||||
},
|
},
|
||||||
...newRoles,
|
...newRoles,
|
||||||
]
|
]
|
||||||
|
@ -108,13 +108,8 @@
|
||||||
getOptionValue={role => role._id}
|
getOptionValue={role => role._id}
|
||||||
getOptionColour={getColor}
|
getOptionColour={getColor}
|
||||||
getOptionIcon={getIcon}
|
getOptionIcon={getIcon}
|
||||||
isOptionEnabled={option => {
|
isOptionEnabled={option =>
|
||||||
if (option._id == CreatorID && !$licensing.perAppBuildersEnabled) {
|
option._id !== CreatorID || $licensing.perAppBuildersEnabled}
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
{placeholder}
|
{placeholder}
|
||||||
{error}
|
{error}
|
||||||
/>
|
/>
|
||||||
|
@ -132,13 +127,8 @@
|
||||||
getOptionValue={role => role._id}
|
getOptionValue={role => role._id}
|
||||||
getOptionColour={getColor}
|
getOptionColour={getColor}
|
||||||
getOptionIcon={getIcon}
|
getOptionIcon={getIcon}
|
||||||
isOptionEnabled={option => {
|
isOptionEnabled={option =>
|
||||||
if (option._id == CreatorID && !$licensing.perAppBuildersEnabled) {
|
option._id !== CreatorID || $licensing.perAppBuildersEnabled}
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
{placeholder}
|
{placeholder}
|
||||||
{error}
|
{error}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -80,16 +80,18 @@
|
||||||
if (!filterByAppAccess && !query) {
|
if (!filterByAppAccess && !query) {
|
||||||
filteredInvites =
|
filteredInvites =
|
||||||
appInvites.length > 100 ? appInvites.slice(0, 100) : [...appInvites]
|
appInvites.length > 100 ? appInvites.slice(0, 100) : [...appInvites]
|
||||||
|
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)
|
||||||
})
|
})
|
||||||
|
.sort(sortInviteRoles)
|
||||||
}
|
}
|
||||||
|
|
||||||
$: filterByAppAccess, prodAppId, filterInvites(query)
|
$: filterByAppAccess, prodAppId, filterInvites(query)
|
||||||
|
@ -150,6 +152,19 @@
|
||||||
.sort(sortRoles)
|
.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 sortRoles = (a, b) => {
|
||||||
const roleA = a.role
|
const roleA = a.role
|
||||||
const roleB = b.role
|
const roleB = b.role
|
||||||
|
@ -357,10 +372,8 @@
|
||||||
const payload = [
|
const payload = [
|
||||||
{
|
{
|
||||||
email: newUserEmail,
|
email: newUserEmail,
|
||||||
builder:
|
builder: !!creationRoleType === Constants.BudibaseRoles.Admin,
|
||||||
creationRoleType === Constants.BudibaseRoles.Admin ? true : false,
|
admin: !!creationRoleType === Constants.BudibaseRoles.Admin,
|
||||||
admin:
|
|
||||||
creationRoleType === Constants.BudibaseRoles.Admin ? true : false,
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -387,6 +400,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const onInviteUser = async () => {
|
const onInviteUser = async () => {
|
||||||
|
form.validate()
|
||||||
userOnboardResponse = await inviteUser()
|
userOnboardResponse = await inviteUser()
|
||||||
const originalQuery = query + ""
|
const originalQuery = query + ""
|
||||||
query = null
|
query = null
|
||||||
|
@ -563,21 +577,14 @@
|
||||||
<div class="invite-header">
|
<div class="invite-header">
|
||||||
<Heading size="XS">No user found</Heading>
|
<Heading size="XS">No user found</Heading>
|
||||||
<div class="invite-directions">
|
<div class="invite-directions">
|
||||||
Add a valid email to invite a new user
|
Try searching a different email or <span
|
||||||
|
class="underlined"
|
||||||
|
on:click={$licensing.userLimitReached
|
||||||
|
? userLimitReachedModal.show
|
||||||
|
: openInviteFlow}>invite a new user</span
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="invite-form">
|
|
||||||
<span>{query || ""}</span>
|
|
||||||
<ActionButton
|
|
||||||
icon="UserAdd"
|
|
||||||
disabled={!queryIsEmail || inviting}
|
|
||||||
on:click={$licensing.userLimitReached
|
|
||||||
? userLimitReachedModal.show
|
|
||||||
: openInviteFlow}
|
|
||||||
>
|
|
||||||
Add user
|
|
||||||
</ActionButton>
|
|
||||||
</div>
|
|
||||||
</Layout>
|
</Layout>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
@ -752,6 +759,7 @@
|
||||||
value={query}
|
value={query}
|
||||||
on:change={e => {
|
on:change={e => {
|
||||||
email = e.detail
|
email = e.detail
|
||||||
|
query = e.detail
|
||||||
}}
|
}}
|
||||||
validate={() => {
|
validate={() => {
|
||||||
if (!email) {
|
if (!email) {
|
||||||
|
@ -770,7 +778,7 @@
|
||||||
)}
|
)}
|
||||||
label="Role"
|
label="Role"
|
||||||
/>
|
/>
|
||||||
{#if creationRoleType !== Constants.Roles.ADMIN}
|
{#if creationRoleType !== Constants.BudibaseRoles.Admin}
|
||||||
<RoleSelect
|
<RoleSelect
|
||||||
placeholder={false}
|
placeholder={false}
|
||||||
bind:value={creationAccessType}
|
bind:value={creationAccessType}
|
||||||
|
@ -783,14 +791,19 @@
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</FancyForm>
|
</FancyForm>
|
||||||
{#if creationRoleType === Constants.Roles.ADMIN}
|
{#if creationRoleType === Constants.BudibaseRoles.Admin}
|
||||||
<div class="admin-info">
|
<div class="admin-info">
|
||||||
<Icon name="Info" />
|
<Icon name="Info" />
|
||||||
Admins will get full access to all apps and settings
|
Admins will get full access to all apps and settings
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<span class="add-user">
|
<span class="add-user">
|
||||||
<Button newStyles cta on:click={onInviteUser}>Add user</Button>
|
<Button
|
||||||
|
newStyles
|
||||||
|
cta
|
||||||
|
disabled={!query.length && !email?.length}
|
||||||
|
on:click={onInviteUser}>Add user</Button
|
||||||
|
>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
@ -818,15 +831,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-info {
|
.admin-info {
|
||||||
padding: var(--spacing-l) var(--spacing-l) var(--spacing-xs)
|
margin-top: var(--spacing-xl);
|
||||||
var(--spacing-l);
|
padding: var(--spacing-l) var(--spacing-l) var(--spacing-l) var(--spacing-l);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: var(--spacing-xl);
|
gap: var(--spacing-xl);
|
||||||
height: 50px;
|
height: 30px;
|
||||||
background-color: var(--background-alt);
|
background-color: var(--background-alt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.underlined {
|
||||||
|
text-decoration: underline;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.search-input {
|
.search-input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue