Merge branch 'develop' of github.com:Budibase/budibase into develop
This commit is contained in:
commit
4c32ac04e3
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "1.2.58-alpha.1",
|
"version": "1.2.58-alpha.5",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/backend-core",
|
"name": "@budibase/backend-core",
|
||||||
"version": "1.2.58-alpha.1",
|
"version": "1.2.58-alpha.5",
|
||||||
"description": "Budibase backend core libraries used in server and worker",
|
"description": "Budibase backend core libraries used in server and worker",
|
||||||
"main": "dist/src/index.js",
|
"main": "dist/src/index.js",
|
||||||
"types": "dist/src/index.d.ts",
|
"types": "dist/src/index.d.ts",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
"test:watch": "jest --watchAll"
|
"test:watch": "jest --watchAll"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/types": "1.2.58-alpha.1",
|
"@budibase/types": "1.2.58-alpha.5",
|
||||||
"@techpass/passport-openidconnect": "0.3.2",
|
"@techpass/passport-openidconnect": "0.3.2",
|
||||||
"aws-sdk": "2.1030.0",
|
"aws-sdk": "2.1030.0",
|
||||||
"bcrypt": "5.0.1",
|
"bcrypt": "5.0.1",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/bbui",
|
"name": "@budibase/bbui",
|
||||||
"description": "A UI solution used in the different Budibase projects.",
|
"description": "A UI solution used in the different Budibase projects.",
|
||||||
"version": "1.2.58-alpha.1",
|
"version": "1.2.58-alpha.5",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"svelte": "src/index.js",
|
"svelte": "src/index.js",
|
||||||
"module": "dist/bbui.es.js",
|
"module": "dist/bbui.es.js",
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@adobe/spectrum-css-workflow-icons": "^1.2.1",
|
"@adobe/spectrum-css-workflow-icons": "^1.2.1",
|
||||||
"@budibase/string-templates": "1.2.58-alpha.1",
|
"@budibase/string-templates": "1.2.58-alpha.5",
|
||||||
"@spectrum-css/actionbutton": "^1.0.1",
|
"@spectrum-css/actionbutton": "^1.0.1",
|
||||||
"@spectrum-css/actiongroup": "^1.0.1",
|
"@spectrum-css/actiongroup": "^1.0.1",
|
||||||
"@spectrum-css/avatar": "^3.0.2",
|
"@spectrum-css/avatar": "^3.0.2",
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
export let getOptionLabel = option => option
|
export let getOptionLabel = option => option
|
||||||
export let getOptionValue = option => option
|
export let getOptionValue = option => option
|
||||||
|
export let getOptionTitle = option => option
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = e => dispatch("change", e.target.value)
|
const onChange = e => dispatch("change", e.target.value)
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
{#if options && Array.isArray(options)}
|
{#if options && Array.isArray(options)}
|
||||||
{#each options as option}
|
{#each options as option}
|
||||||
<div
|
<div
|
||||||
title={getOptionLabel(option)}
|
title={getOptionTitle(option)}
|
||||||
class="spectrum-Radio spectrum-FieldGroup-item spectrum-Radio--emphasized"
|
class="spectrum-Radio spectrum-FieldGroup-item spectrum-Radio--emphasized"
|
||||||
class:is-invalid={!!error}
|
class:is-invalid={!!error}
|
||||||
>
|
>
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
export let direction = "vertical"
|
export let direction = "vertical"
|
||||||
export let getOptionLabel = option => extractProperty(option, "label")
|
export let getOptionLabel = option => extractProperty(option, "label")
|
||||||
export let getOptionValue = option => extractProperty(option, "value")
|
export let getOptionValue = option => extractProperty(option, "value")
|
||||||
|
export let getOptionTitle = option => extractProperty(option, "label")
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = e => {
|
const onChange = e => {
|
||||||
|
@ -35,6 +36,7 @@
|
||||||
{direction}
|
{direction}
|
||||||
{getOptionLabel}
|
{getOptionLabel}
|
||||||
{getOptionValue}
|
{getOptionValue}
|
||||||
|
{getOptionTitle}
|
||||||
on:change={onChange}
|
on:change={onChange}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/builder",
|
"name": "@budibase/builder",
|
||||||
"version": "1.2.58-alpha.1",
|
"version": "1.2.58-alpha.5",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -69,10 +69,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/bbui": "1.2.58-alpha.1",
|
"@budibase/bbui": "1.2.58-alpha.5",
|
||||||
"@budibase/client": "1.2.58-alpha.1",
|
"@budibase/client": "1.2.58-alpha.5",
|
||||||
"@budibase/frontend-core": "1.2.58-alpha.1",
|
"@budibase/frontend-core": "1.2.58-alpha.5",
|
||||||
"@budibase/string-templates": "1.2.58-alpha.1",
|
"@budibase/string-templates": "1.2.58-alpha.5",
|
||||||
"@sentry/browser": "5.19.1",
|
"@sentry/browser": "5.19.1",
|
||||||
"@spectrum-css/page": "^3.0.1",
|
"@spectrum-css/page": "^3.0.1",
|
||||||
"@spectrum-css/vars": "^3.0.1",
|
"@spectrum-css/vars": "^3.0.1",
|
||||||
|
|
|
@ -19,7 +19,6 @@ import {
|
||||||
makeComponentUnique,
|
makeComponentUnique,
|
||||||
} from "../componentUtils"
|
} from "../componentUtils"
|
||||||
import { Helpers } from "@budibase/bbui"
|
import { Helpers } from "@budibase/bbui"
|
||||||
import { DefaultAppTheme, LAYOUT_NAMES } from "../../constants"
|
|
||||||
import { Utils } from "@budibase/frontend-core"
|
import { Utils } from "@budibase/frontend-core"
|
||||||
|
|
||||||
const INITIAL_FRONTEND_STATE = {
|
const INITIAL_FRONTEND_STATE = {
|
||||||
|
@ -125,35 +124,6 @@ export const getFrontendStore = () => {
|
||||||
await integrations.init()
|
await integrations.init()
|
||||||
await queries.init()
|
await queries.init()
|
||||||
await tables.init()
|
await tables.init()
|
||||||
|
|
||||||
// Add navigation settings to old apps
|
|
||||||
if (!application.navigation) {
|
|
||||||
const layout = layouts.find(x => x._id === LAYOUT_NAMES.MASTER.PRIVATE)
|
|
||||||
const customTheme = application.customTheme
|
|
||||||
let navigationSettings = {
|
|
||||||
navigation: "Top",
|
|
||||||
title: application.name,
|
|
||||||
navWidth: "Large",
|
|
||||||
navBackground:
|
|
||||||
customTheme?.navBackground || DefaultAppTheme.navBackground,
|
|
||||||
navTextColor:
|
|
||||||
customTheme?.navTextColor || DefaultAppTheme.navTextColor,
|
|
||||||
}
|
|
||||||
if (layout) {
|
|
||||||
navigationSettings.hideLogo = layout.props.hideLogo
|
|
||||||
navigationSettings.hideTitle = layout.props.hideTitle
|
|
||||||
navigationSettings.title = layout.props.title || application.name
|
|
||||||
navigationSettings.logoUrl = layout.props.logoUrl
|
|
||||||
navigationSettings.links = layout.props.links
|
|
||||||
navigationSettings.navigation = layout.props.navigation || "Top"
|
|
||||||
navigationSettings.sticky = layout.props.sticky
|
|
||||||
navigationSettings.navWidth = layout.props.width || "Large"
|
|
||||||
if (navigationSettings.navigation === "None") {
|
|
||||||
navigationSettings.navigation = "Top"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await store.actions.navigation.save(navigationSettings)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
theme: {
|
theme: {
|
||||||
save: async theme => {
|
save: async theme => {
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="automations-list">
|
<div class="automations-list">
|
||||||
{#each $automationStore.automations as automation, idx}
|
{#each $automationStore.automations.sort(aut => aut.name) as automation, idx}
|
||||||
<NavItem
|
<NavItem
|
||||||
border={idx > 0}
|
border={idx > 0}
|
||||||
icon="ShareAndroid"
|
icon="ShareAndroid"
|
||||||
|
|
|
@ -467,6 +467,7 @@
|
||||||
options={relationshipOptions}
|
options={relationshipOptions}
|
||||||
getOptionLabel={option => option.name}
|
getOptionLabel={option => option.name}
|
||||||
getOptionValue={option => option.value}
|
getOptionValue={option => option.value}
|
||||||
|
getOptionTitle={option => option.alt}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<Input
|
<Input
|
||||||
|
|
|
@ -44,7 +44,11 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateInput(email, index) {
|
function validateInput(input, index) {
|
||||||
|
if (input.email) {
|
||||||
|
input.email = input.email.trim()
|
||||||
|
}
|
||||||
|
const email = input.email
|
||||||
if (email) {
|
if (email) {
|
||||||
const res = emailValidator(email)
|
const res = emailValidator(email)
|
||||||
if (res === true) {
|
if (res === true) {
|
||||||
|
@ -95,7 +99,7 @@
|
||||||
bind:dropdownValue={input.role}
|
bind:dropdownValue={input.role}
|
||||||
options={Constants.BudibaseRoleOptions}
|
options={Constants.BudibaseRoleOptions}
|
||||||
error={input.error}
|
error={input.error}
|
||||||
on:blur={() => validateInput(input.email, index)}
|
on:blur={() => validateInput(input, index)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
<script>
|
||||||
|
import { Body, ModalContent, Table } from "@budibase/bbui"
|
||||||
|
import { onMount } from "svelte"
|
||||||
|
|
||||||
|
export let inviteUsersResponse
|
||||||
|
|
||||||
|
let hasSuccess
|
||||||
|
let hasFailure
|
||||||
|
let title
|
||||||
|
let failureMessage
|
||||||
|
|
||||||
|
let unsuccessfulUsers
|
||||||
|
|
||||||
|
const setTitle = () => {
|
||||||
|
if (hasSuccess) {
|
||||||
|
title = "Users invited!"
|
||||||
|
} else if (hasFailure) {
|
||||||
|
title = "Oops!"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const setFailureMessage = () => {
|
||||||
|
if (hasSuccess) {
|
||||||
|
failureMessage = "However there was a problem inviting some users."
|
||||||
|
} else {
|
||||||
|
failureMessage = "There was a problem inviting users."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const setUsers = () => {
|
||||||
|
unsuccessfulUsers = inviteUsersResponse.unsuccessful.map(user => {
|
||||||
|
return {
|
||||||
|
email: user.email,
|
||||||
|
reason: user.reason,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
hasSuccess = inviteUsersResponse.successful.length
|
||||||
|
hasFailure = inviteUsersResponse.unsuccessful.length
|
||||||
|
setTitle()
|
||||||
|
setFailureMessage()
|
||||||
|
setUsers()
|
||||||
|
})
|
||||||
|
|
||||||
|
const failedSchema = {
|
||||||
|
email: {},
|
||||||
|
reason: {},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<ModalContent showCancelButton={false} {title} confirmText="Done">
|
||||||
|
{#if hasSuccess}
|
||||||
|
<Body size="XS">
|
||||||
|
Your users should now receive an email invite to get access to their
|
||||||
|
Budibase account
|
||||||
|
</Body>
|
||||||
|
{/if}
|
||||||
|
{#if hasFailure}
|
||||||
|
<Body size="XS">
|
||||||
|
{failureMessage}
|
||||||
|
</Body>
|
||||||
|
<Table
|
||||||
|
schema={failedSchema}
|
||||||
|
data={unsuccessfulUsers}
|
||||||
|
allowEditColumns={false}
|
||||||
|
allowEditRows={false}
|
||||||
|
allowSelectRows={false}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
</ModalContent>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
|
@ -7,7 +7,6 @@
|
||||||
Table,
|
Table,
|
||||||
Layout,
|
Layout,
|
||||||
Modal,
|
Modal,
|
||||||
ModalContent,
|
|
||||||
Search,
|
Search,
|
||||||
notifications,
|
notifications,
|
||||||
Pagination,
|
Pagination,
|
||||||
|
@ -23,6 +22,7 @@
|
||||||
import { goto } from "@roxi/routify"
|
import { goto } from "@roxi/routify"
|
||||||
import OnboardingTypeModal from "./_components/OnboardingTypeModal.svelte"
|
import OnboardingTypeModal from "./_components/OnboardingTypeModal.svelte"
|
||||||
import PasswordModal from "./_components/PasswordModal.svelte"
|
import PasswordModal from "./_components/PasswordModal.svelte"
|
||||||
|
import InvitedModal from "./_components/InvitedModal.svelte"
|
||||||
import DeletionFailureModal from "./_components/DeletionFailureModal.svelte"
|
import DeletionFailureModal from "./_components/DeletionFailureModal.svelte"
|
||||||
import ImportUsersModal from "./_components/ImportUsersModal.svelte"
|
import ImportUsersModal from "./_components/ImportUsersModal.svelte"
|
||||||
import { createPaginationStore } from "helpers/pagination"
|
import { createPaginationStore } from "helpers/pagination"
|
||||||
|
@ -59,6 +59,7 @@
|
||||||
$: userData = []
|
$: userData = []
|
||||||
$: createUsersResponse = { successful: [], unsuccessful: [] }
|
$: createUsersResponse = { successful: [], unsuccessful: [] }
|
||||||
$: deleteUsersResponse = { successful: [], unsuccessful: [] }
|
$: deleteUsersResponse = { successful: [], unsuccessful: [] }
|
||||||
|
$: inviteUsersResponse = { successful: [], unsuccessful: [] }
|
||||||
$: page = $pageInfo.page
|
$: page = $pageInfo.page
|
||||||
$: fetchUsers(page, searchEmail)
|
$: fetchUsers(page, searchEmail)
|
||||||
$: {
|
$: {
|
||||||
|
@ -96,8 +97,7 @@
|
||||||
admin: user.role === Constants.BudibaseRoles.Admin,
|
admin: user.role === Constants.BudibaseRoles.Admin,
|
||||||
}))
|
}))
|
||||||
try {
|
try {
|
||||||
const res = await users.invite(payload)
|
inviteUsersResponse = await users.invite(payload)
|
||||||
notifications.success(res.message)
|
|
||||||
inviteConfirmationModal.show()
|
inviteConfirmationModal.show()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.error("Error inviting user")
|
notifications.error("Error inviting user")
|
||||||
|
@ -144,10 +144,10 @@
|
||||||
userData = await removingDuplicities({ groups, users })
|
userData = await removingDuplicities({ groups, users })
|
||||||
if (!userData.users.length) return
|
if (!userData.users.length) return
|
||||||
|
|
||||||
return createUser()
|
return createUsers()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createUser() {
|
async function createUsers() {
|
||||||
try {
|
try {
|
||||||
createUsersResponse = await users.create(
|
createUsersResponse = await users.create(
|
||||||
await removingDuplicities(userData)
|
await removingDuplicities(userData)
|
||||||
|
@ -164,7 +164,7 @@
|
||||||
if (onboardingType === "emailOnboarding") {
|
if (onboardingType === "emailOnboarding") {
|
||||||
createUserFlow()
|
createUserFlow()
|
||||||
} else {
|
} else {
|
||||||
await createUser()
|
await createUsers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,16 +281,7 @@
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<Modal bind:this={inviteConfirmationModal}>
|
<Modal bind:this={inviteConfirmationModal}>
|
||||||
<ModalContent
|
<InvitedModal {inviteUsersResponse} />
|
||||||
showCancelButton={false}
|
|
||||||
title="Invites sent!"
|
|
||||||
confirmText="Done"
|
|
||||||
>
|
|
||||||
<Body size="S"
|
|
||||||
>Your users should now recieve an email invite to get access to their
|
|
||||||
Budibase account</Body
|
|
||||||
></ModalContent
|
|
||||||
>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<Modal bind:this={onboardingTypeModal}>
|
<Modal bind:this={onboardingTypeModal}>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/cli",
|
"name": "@budibase/cli",
|
||||||
"version": "1.2.58-alpha.1",
|
"version": "1.2.58-alpha.5",
|
||||||
"description": "Budibase CLI, for developers, self hosting and migrations.",
|
"description": "Budibase CLI, for developers, self hosting and migrations.",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
"outputPath": "build"
|
"outputPath": "build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/backend-core": "1.2.58-alpha.1",
|
"@budibase/backend-core": "1.2.58-alpha.5",
|
||||||
"axios": "0.21.2",
|
"axios": "0.21.2",
|
||||||
"chalk": "4.1.0",
|
"chalk": "4.1.0",
|
||||||
"cli-progress": "3.11.2",
|
"cli-progress": "3.11.2",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/client",
|
"name": "@budibase/client",
|
||||||
"version": "1.2.58-alpha.1",
|
"version": "1.2.58-alpha.5",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"module": "dist/budibase-client.js",
|
"module": "dist/budibase-client.js",
|
||||||
"main": "dist/budibase-client.js",
|
"main": "dist/budibase-client.js",
|
||||||
|
@ -19,9 +19,9 @@
|
||||||
"dev:builder": "rollup -cw"
|
"dev:builder": "rollup -cw"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/bbui": "1.2.58-alpha.1",
|
"@budibase/bbui": "1.2.58-alpha.5",
|
||||||
"@budibase/frontend-core": "1.2.58-alpha.1",
|
"@budibase/frontend-core": "1.2.58-alpha.5",
|
||||||
"@budibase/string-templates": "1.2.58-alpha.1",
|
"@budibase/string-templates": "1.2.58-alpha.5",
|
||||||
"@spectrum-css/button": "^3.0.3",
|
"@spectrum-css/button": "^3.0.3",
|
||||||
"@spectrum-css/card": "^3.0.3",
|
"@spectrum-css/card": "^3.0.3",
|
||||||
"@spectrum-css/divider": "^1.0.3",
|
"@spectrum-css/divider": "^1.0.3",
|
||||||
|
|
|
@ -77,6 +77,7 @@
|
||||||
{direction}
|
{direction}
|
||||||
on:change={handleChange}
|
on:change={handleChange}
|
||||||
getOptionLabel={flatOptions ? x => x : x => x.label}
|
getOptionLabel={flatOptions ? x => x : x => x.label}
|
||||||
|
getOptionTitle={flatOptions ? x => x : x => x.label}
|
||||||
getOptionValue={flatOptions ? x => x : x => x.value}
|
getOptionValue={flatOptions ? x => x : x => x.value}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/frontend-core",
|
"name": "@budibase/frontend-core",
|
||||||
"version": "1.2.58-alpha.1",
|
"version": "1.2.58-alpha.5",
|
||||||
"description": "Budibase frontend core libraries used in builder and client",
|
"description": "Budibase frontend core libraries used in builder and client",
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"svelte": "src/index.js",
|
"svelte": "src/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/bbui": "1.2.58-alpha.1",
|
"@budibase/bbui": "1.2.58-alpha.5",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"svelte": "^3.46.2"
|
"svelte": "^3.46.2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/server",
|
"name": "@budibase/server",
|
||||||
"email": "hi@budibase.com",
|
"email": "hi@budibase.com",
|
||||||
"version": "1.2.58-alpha.1",
|
"version": "1.2.58-alpha.5",
|
||||||
"description": "Budibase Web Server",
|
"description": "Budibase Web Server",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -77,11 +77,11 @@
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apidevtools/swagger-parser": "10.0.3",
|
"@apidevtools/swagger-parser": "10.0.3",
|
||||||
"@budibase/backend-core": "1.2.58-alpha.1",
|
"@budibase/backend-core": "1.2.58-alpha.5",
|
||||||
"@budibase/client": "1.2.58-alpha.1",
|
"@budibase/client": "1.2.58-alpha.5",
|
||||||
"@budibase/pro": "1.2.58-alpha.1",
|
"@budibase/pro": "1.2.58-alpha.5",
|
||||||
"@budibase/string-templates": "1.2.58-alpha.1",
|
"@budibase/string-templates": "1.2.58-alpha.5",
|
||||||
"@budibase/types": "1.2.58-alpha.1",
|
"@budibase/types": "1.2.58-alpha.5",
|
||||||
"@bull-board/api": "3.7.0",
|
"@bull-board/api": "3.7.0",
|
||||||
"@bull-board/koa": "3.9.4",
|
"@bull-board/koa": "3.9.4",
|
||||||
"@elastic/elasticsearch": "7.10.0",
|
"@elastic/elasticsearch": "7.10.0",
|
||||||
|
|
|
@ -47,7 +47,14 @@ import { checkAppMetadata } from "../../automations/logging"
|
||||||
import { getUniqueRows } from "../../utilities/usageQuota/rows"
|
import { getUniqueRows } from "../../utilities/usageQuota/rows"
|
||||||
import { quotas } from "@budibase/pro"
|
import { quotas } from "@budibase/pro"
|
||||||
import { errors, events, migrations } from "@budibase/backend-core"
|
import { errors, events, migrations } from "@budibase/backend-core"
|
||||||
import { App, MigrationType } from "@budibase/types"
|
import {
|
||||||
|
App,
|
||||||
|
Layout,
|
||||||
|
Screen,
|
||||||
|
MigrationType,
|
||||||
|
AppNavigation,
|
||||||
|
} from "@budibase/types"
|
||||||
|
import { BASE_LAYOUT_PROP_IDS } from "../../constants/layouts"
|
||||||
|
|
||||||
const URL_REGEX_SLASH = /\/|\\/g
|
const URL_REGEX_SLASH = /\/|\\/g
|
||||||
|
|
||||||
|
@ -243,27 +250,19 @@ const performAppCreate = async (ctx: any) => {
|
||||||
}
|
}
|
||||||
const instance = await createInstance(instanceConfig)
|
const instance = await createInstance(instanceConfig)
|
||||||
const appId = instance._id
|
const appId = instance._id
|
||||||
|
|
||||||
const db = context.getAppDB()
|
const db = context.getAppDB()
|
||||||
let _rev
|
|
||||||
try {
|
let newApplication: App = {
|
||||||
// if template there will be an existing doc
|
|
||||||
const existing = await db.get(DocumentType.APP_METADATA)
|
|
||||||
_rev = existing._rev
|
|
||||||
} catch (err) {
|
|
||||||
// nothing to do
|
|
||||||
}
|
|
||||||
const newApplication: App = {
|
|
||||||
_id: DocumentType.APP_METADATA,
|
_id: DocumentType.APP_METADATA,
|
||||||
_rev,
|
_rev: undefined,
|
||||||
appId: instance._id,
|
appId,
|
||||||
type: "app",
|
type: "app",
|
||||||
version: packageJson.version,
|
version: packageJson.version,
|
||||||
componentLibraries: ["@budibase/standard-components"],
|
componentLibraries: ["@budibase/standard-components"],
|
||||||
name: name,
|
name: name,
|
||||||
url: url,
|
url: url,
|
||||||
template: ctx.request.body.template,
|
template: templateKey,
|
||||||
instance: instance,
|
instance,
|
||||||
tenantId: getTenantId(),
|
tenantId: getTenantId(),
|
||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
|
@ -285,6 +284,36 @@ const performAppCreate = async (ctx: any) => {
|
||||||
buttonBorderRadius: "16px",
|
buttonBorderRadius: "16px",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we used a template or imported an app there will be an existing doc.
|
||||||
|
// Fetch and migrate some metadata from the existing app.
|
||||||
|
try {
|
||||||
|
const existing: App = await db.get(DocumentType.APP_METADATA)
|
||||||
|
const keys: (keyof App)[] = [
|
||||||
|
"_rev",
|
||||||
|
"navigation",
|
||||||
|
"theme",
|
||||||
|
"customTheme",
|
||||||
|
"icon",
|
||||||
|
]
|
||||||
|
keys.forEach(key => {
|
||||||
|
if (existing[key]) {
|
||||||
|
// @ts-ignore
|
||||||
|
newApplication[key] = existing[key]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Migrate navigation settings and screens if required
|
||||||
|
if (existing && !existing.navigation) {
|
||||||
|
const navigation = await migrateAppNavigation()
|
||||||
|
if (navigation) {
|
||||||
|
newApplication.navigation = navigation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
// Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
const response = await db.put(newApplication, { force: true })
|
const response = await db.put(newApplication, { force: true })
|
||||||
newApplication._rev = response.rev
|
newApplication._rev = response.rev
|
||||||
|
|
||||||
|
@ -567,3 +596,55 @@ const updateAppPackage = async (appPackage: any, appId: any) => {
|
||||||
return newAppPackage
|
return newAppPackage
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const migrateAppNavigation = async () => {
|
||||||
|
const db = context.getAppDB()
|
||||||
|
const existing: App = await db.get(DocumentType.APP_METADATA)
|
||||||
|
const layouts: Layout[] = await getLayouts()
|
||||||
|
const screens: Screen[] = await getScreens()
|
||||||
|
|
||||||
|
// Migrate all screens, removing custom layouts
|
||||||
|
for (let screen of screens) {
|
||||||
|
if (!screen.layoutId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const layout = layouts.find(layout => layout._id === screen.layoutId)
|
||||||
|
screen.layoutId = undefined
|
||||||
|
screen.showNavigation = layout?.props.navigation !== "None"
|
||||||
|
screen.width = layout?.props.width || "Large"
|
||||||
|
await db.put(screen)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Migrate layout navigation settings
|
||||||
|
const { name, customTheme } = existing
|
||||||
|
const layout = layouts?.find(
|
||||||
|
(layout: Layout) => layout._id === BASE_LAYOUT_PROP_IDS.PRIVATE
|
||||||
|
)
|
||||||
|
if (layout) {
|
||||||
|
let navigationSettings: any = {
|
||||||
|
navigation: "Top",
|
||||||
|
title: name,
|
||||||
|
navWidth: "Large",
|
||||||
|
navBackground:
|
||||||
|
customTheme?.navBackground || "var(--spectrum-global-color-gray-50)",
|
||||||
|
navTextColor:
|
||||||
|
customTheme?.navTextColor || "var(--spectrum-global-color-gray-800)",
|
||||||
|
}
|
||||||
|
if (layout) {
|
||||||
|
navigationSettings.hideLogo = layout.props.hideLogo
|
||||||
|
navigationSettings.hideTitle = layout.props.hideTitle
|
||||||
|
navigationSettings.title = layout.props.title || name
|
||||||
|
navigationSettings.logoUrl = layout.props.logoUrl
|
||||||
|
navigationSettings.links = layout.props.links
|
||||||
|
navigationSettings.navigation = layout.props.navigation || "Top"
|
||||||
|
navigationSettings.sticky = layout.props.sticky
|
||||||
|
navigationSettings.navWidth = layout.props.width || "Large"
|
||||||
|
if (navigationSettings.navigation === "None") {
|
||||||
|
navigationSettings.navigation = "Top"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return navigationSettings
|
||||||
|
} else {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ const {
|
||||||
checkBuilderEndpoint,
|
checkBuilderEndpoint,
|
||||||
} = require("./utilities/TestFunctions")
|
} = require("./utilities/TestFunctions")
|
||||||
const setup = require("./utilities")
|
const setup = require("./utilities")
|
||||||
|
const { basicScreen, basicLayout } = setup.structures
|
||||||
const { AppStatus } = require("../../../db/utils")
|
const { AppStatus } = require("../../../db/utils")
|
||||||
const { events } = require("@budibase/backend-core")
|
const { events } = require("@budibase/backend-core")
|
||||||
|
|
||||||
|
@ -81,6 +82,31 @@ describe("/applications", () => {
|
||||||
body: { name: "My App" },
|
body: { name: "My App" },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("migrates navigation settings from old apps", async () => {
|
||||||
|
const res = await request
|
||||||
|
.post("/api/applications")
|
||||||
|
.field("name", "Old App")
|
||||||
|
.field("useTemplate", "true")
|
||||||
|
.set(config.defaultHeaders())
|
||||||
|
.attach("templateFile", "src/api/routes/tests/data/old-app.txt")
|
||||||
|
.expect("Content-Type", /json/)
|
||||||
|
.expect(200)
|
||||||
|
expect(res.body._id).toBeDefined()
|
||||||
|
expect(res.body.navigation).toBeDefined()
|
||||||
|
expect(res.body.navigation.hideLogo).toBe(true)
|
||||||
|
expect(res.body.navigation.title).toBe("Custom Title")
|
||||||
|
expect(res.body.navigation.hideLogo).toBe(true)
|
||||||
|
expect(res.body.navigation.navigation).toBe("Left")
|
||||||
|
expect(res.body.navigation.navBackground).toBe(
|
||||||
|
"var(--spectrum-global-color-blue-600)"
|
||||||
|
)
|
||||||
|
expect(res.body.navigation.navTextColor).toBe(
|
||||||
|
"var(--spectrum-global-color-gray-50)"
|
||||||
|
)
|
||||||
|
expect(events.app.created).toBeCalledTimes(1)
|
||||||
|
expect(events.app.fileImported).toBeCalledTimes(1)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("fetch", () => {
|
describe("fetch", () => {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1094,12 +1094,12 @@
|
||||||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||||
|
|
||||||
"@budibase/backend-core@1.2.58-alpha.1":
|
"@budibase/backend-core@1.2.58-alpha.5":
|
||||||
version "1.2.58-alpha.1"
|
version "1.2.58-alpha.5"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.58-alpha.1.tgz#26fe21df9839e671df70de9403bf9597dcfb15a6"
|
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.58-alpha.5.tgz#430699334629b3bd05a5066aa6660c1f68f047b2"
|
||||||
integrity sha512-WjwwiSc2haaRI9Yg2i7NoZ+QrbVRezM8xBJZWt2sL17xW6VVZ7ao5zCRZD+M0Euo9EO1C25ehCTYI9iUF9UU0w==
|
integrity sha512-Z926rAp0eskXUr5UXGwh0S1OMDA3qzIi8o0GHLlO7KZAzk49RYzhRT/yo1fIst8Eq/9ZCaXLFxIeRkDmCJgILg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@budibase/types" "1.2.58-alpha.1"
|
"@budibase/types" "1.2.58-alpha.5"
|
||||||
"@techpass/passport-openidconnect" "0.3.2"
|
"@techpass/passport-openidconnect" "0.3.2"
|
||||||
aws-sdk "2.1030.0"
|
aws-sdk "2.1030.0"
|
||||||
bcrypt "5.0.1"
|
bcrypt "5.0.1"
|
||||||
|
@ -1178,13 +1178,13 @@
|
||||||
svelte-flatpickr "^3.2.3"
|
svelte-flatpickr "^3.2.3"
|
||||||
svelte-portal "^1.0.0"
|
svelte-portal "^1.0.0"
|
||||||
|
|
||||||
"@budibase/pro@1.2.58-alpha.1":
|
"@budibase/pro@1.2.58-alpha.5":
|
||||||
version "1.2.58-alpha.1"
|
version "1.2.58-alpha.5"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.58-alpha.1.tgz#fbcf2c8712c90d316e8dcec5d807ba9bab27985b"
|
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.58-alpha.5.tgz#1f739653e641ac32d20818517d35bef489ec2ae6"
|
||||||
integrity sha512-cLCXkXnHVJCV+K81BbM2GwkicnBs+W+x97QYo79NhId5pEvIzkmmIuvirtGcihk6hoBI2cPwJUmx5M5CrU574Q==
|
integrity sha512-owT7ipgZ588KAz6aHPJie5bLJX6EkhTRUvUQlyOJuLWt/hdXXnvbu+agxBQNaXE4gVzn916JJP0L0tbiMctjNA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@budibase/backend-core" "1.2.58-alpha.1"
|
"@budibase/backend-core" "1.2.58-alpha.5"
|
||||||
"@budibase/types" "1.2.58-alpha.1"
|
"@budibase/types" "1.2.58-alpha.5"
|
||||||
"@koa/router" "8.0.8"
|
"@koa/router" "8.0.8"
|
||||||
joi "17.6.0"
|
joi "17.6.0"
|
||||||
node-fetch "^2.6.1"
|
node-fetch "^2.6.1"
|
||||||
|
@ -1207,10 +1207,10 @@
|
||||||
svelte-apexcharts "^1.0.2"
|
svelte-apexcharts "^1.0.2"
|
||||||
svelte-flatpickr "^3.1.0"
|
svelte-flatpickr "^3.1.0"
|
||||||
|
|
||||||
"@budibase/types@1.2.58-alpha.1":
|
"@budibase/types@1.2.58-alpha.5":
|
||||||
version "1.2.58-alpha.1"
|
version "1.2.58-alpha.5"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.58-alpha.1.tgz#1d7335eee57f9cb9bf0141640a563ab545b8178d"
|
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.58-alpha.5.tgz#8ea99745f296a1076f878a06b7c228bc60886cd3"
|
||||||
integrity sha512-qxplmPest4l3BAHbKJ5zd4UcYBqjb8IbPTp4D2Yqm0icjSgDH9uOXA3wBwBbnBKwe8AfxeGkXgHyFkccIFSZvA==
|
integrity sha512-0JhHDGvfcMcjhBckP3RqbKCDsMhx7ZVTV8wvaqsOaG7PnBSst9dxyX7ETVVzfvYolIK1eV11itsgx0FpbYID2w==
|
||||||
|
|
||||||
"@bull-board/api@3.7.0":
|
"@bull-board/api@3.7.0":
|
||||||
version "3.7.0"
|
version "3.7.0"
|
||||||
|
@ -10204,18 +10204,13 @@ module-details-from-path@^1.0.3:
|
||||||
integrity sha512-ySViT69/76t8VhE1xXHK6Ch4NcDd26gx0MzKXLO+F7NOtnqH68d9zF94nT8ZWSxXh8ELOERsnJO/sWt1xZYw5A==
|
integrity sha512-ySViT69/76t8VhE1xXHK6Ch4NcDd26gx0MzKXLO+F7NOtnqH68d9zF94nT8ZWSxXh8ELOERsnJO/sWt1xZYw5A==
|
||||||
|
|
||||||
moment-timezone@^0.5.15:
|
moment-timezone@^0.5.15:
|
||||||
version "0.5.34"
|
version "0.5.37"
|
||||||
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.34.tgz#a75938f7476b88f155d3504a9343f7519d9a405c"
|
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.37.tgz#adf97f719c4e458fdb12e2b4e87b8bec9f4eef1e"
|
||||||
integrity sha512-3zAEHh2hKUs3EXLESx/wsgw6IQdusOT8Bxm3D9UrHPQR7zlMmzwybC8zHEM1tQ4LJwP7fcxrWr8tuBg05fFCbg==
|
integrity sha512-uEDzDNFhfaywRl+vwXxffjjq1q0Vzr+fcQpQ1bU0kbzorfS7zVtZnCnGc8mhWmF39d4g4YriF6kwA75mJKE/Zg==
|
||||||
dependencies:
|
dependencies:
|
||||||
moment ">= 2.9.0"
|
moment ">= 2.9.0"
|
||||||
|
|
||||||
"moment@>= 2.9.0":
|
"moment@>= 2.9.0", moment@^2.29.3:
|
||||||
version "2.29.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.3.tgz#edd47411c322413999f7a5940d526de183c031f3"
|
|
||||||
integrity sha512-c6YRvhEo//6T2Jz/vVtYzqBzwvPT95JBQ+smCytzf7c50oMZRsR/a4w88aD34I+/QVSfnoAnSBFPJHItlOMJVw==
|
|
||||||
|
|
||||||
moment@^2.29.3:
|
|
||||||
version "2.29.4"
|
version "2.29.4"
|
||||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108"
|
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108"
|
||||||
integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==
|
integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/string-templates",
|
"name": "@budibase/string-templates",
|
||||||
"version": "1.2.58-alpha.1",
|
"version": "1.2.58-alpha.5",
|
||||||
"description": "Handlebars wrapper for Budibase templating.",
|
"description": "Handlebars wrapper for Budibase templating.",
|
||||||
"main": "src/index.cjs",
|
"main": "src/index.cjs",
|
||||||
"module": "dist/bundle.mjs",
|
"module": "dist/bundle.mjs",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/types",
|
"name": "@budibase/types",
|
||||||
"version": "1.2.58-alpha.1",
|
"version": "1.2.58-alpha.5",
|
||||||
"description": "Budibase types",
|
"description": "Budibase types",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|
|
@ -29,3 +29,15 @@ export interface BulkDeleteUsersResponse {
|
||||||
successful: UserDetails[]
|
successful: UserDetails[]
|
||||||
unsuccessful: { _id: string; email: string; reason: string }[]
|
unsuccessful: { _id: string; email: string; reason: string }[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface InviteUserRequest {
|
||||||
|
email: string
|
||||||
|
userInfo: any
|
||||||
|
}
|
||||||
|
|
||||||
|
export type InviteUsersRequest = InviteUserRequest[]
|
||||||
|
|
||||||
|
export interface InviteUsersResponse {
|
||||||
|
successful: { email: string }[]
|
||||||
|
unsuccessful: { email: string; reason: string }[]
|
||||||
|
}
|
||||||
|
|
|
@ -14,14 +14,11 @@ export interface App extends Document {
|
||||||
tenantId: string
|
tenantId: string
|
||||||
status: string
|
status: string
|
||||||
theme?: string
|
theme?: string
|
||||||
customTheme?: {
|
customTheme?: AppCustomTheme
|
||||||
buttonBorderRadius?: string
|
|
||||||
primaryColor?: string
|
|
||||||
primaryColorHover?: string
|
|
||||||
}
|
|
||||||
revertableVersion?: string
|
revertableVersion?: string
|
||||||
navigation?: AppNavigation
|
navigation?: AppNavigation
|
||||||
automationErrors?: AppMetadataErrors
|
automationErrors?: AppMetadataErrors
|
||||||
|
icon?: AppIcon
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppInstance {
|
export interface AppInstance {
|
||||||
|
@ -47,3 +44,18 @@ export interface AppNavigationLink {
|
||||||
id?: string
|
id?: string
|
||||||
roleId?: string
|
roleId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AppCustomTheme {
|
||||||
|
buttonBorderRadius?: string
|
||||||
|
primaryColor?: string
|
||||||
|
primaryColorHover?: string
|
||||||
|
|
||||||
|
// Used to exist before new design UI
|
||||||
|
navTextColor?: string
|
||||||
|
navBackground?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AppIcon {
|
||||||
|
name: string
|
||||||
|
color: string
|
||||||
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
import { Document } from "../document"
|
import { Document } from "../document"
|
||||||
|
|
||||||
export interface Layout extends Document {}
|
export interface Layout extends Document {
|
||||||
|
props: any
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Document } from "../document"
|
import { Document } from "../document"
|
||||||
|
|
||||||
export interface Screen extends Document {
|
export interface Screen extends Document {
|
||||||
layoutId: string
|
layoutId?: string
|
||||||
showNavigation?: boolean
|
showNavigation?: boolean
|
||||||
width?: string
|
width?: string
|
||||||
routing: {
|
routing: {
|
||||||
|
|
|
@ -2,12 +2,12 @@ import { BaseEvent } from "./event"
|
||||||
|
|
||||||
export interface ScreenCreatedEvent extends BaseEvent {
|
export interface ScreenCreatedEvent extends BaseEvent {
|
||||||
screenId: string
|
screenId: string
|
||||||
layoutId: string
|
layoutId?: string
|
||||||
roleId: string
|
roleId: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ScreenDeletedEvent extends BaseEvent {
|
export interface ScreenDeletedEvent extends BaseEvent {
|
||||||
screenId: string
|
screenId: string
|
||||||
layoutId: string
|
layoutId?: string
|
||||||
roleId: string
|
roleId: string
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/worker",
|
"name": "@budibase/worker",
|
||||||
"email": "hi@budibase.com",
|
"email": "hi@budibase.com",
|
||||||
"version": "1.2.58-alpha.1",
|
"version": "1.2.58-alpha.5",
|
||||||
"description": "Budibase background service",
|
"description": "Budibase background service",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -35,10 +35,10 @@
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/backend-core": "1.2.58-alpha.1",
|
"@budibase/backend-core": "1.2.58-alpha.5",
|
||||||
"@budibase/pro": "1.2.58-alpha.1",
|
"@budibase/pro": "1.2.58-alpha.5",
|
||||||
"@budibase/string-templates": "1.2.58-alpha.1",
|
"@budibase/string-templates": "1.2.58-alpha.5",
|
||||||
"@budibase/types": "1.2.58-alpha.1",
|
"@budibase/types": "1.2.58-alpha.5",
|
||||||
"@koa/router": "8.0.8",
|
"@koa/router": "8.0.8",
|
||||||
"@sentry/node": "6.17.7",
|
"@sentry/node": "6.17.7",
|
||||||
"@techpass/passport-openidconnect": "0.3.2",
|
"@techpass/passport-openidconnect": "0.3.2",
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
import { EmailTemplatePurpose } from "../../../constants"
|
|
||||||
import { checkInviteCode } from "../../../utilities/redis"
|
import { checkInviteCode } from "../../../utilities/redis"
|
||||||
import { sendEmail } from "../../../utilities/email"
|
|
||||||
import { users } from "../../../sdk"
|
import { users } from "../../../sdk"
|
||||||
import env from "../../../environment"
|
import env from "../../../environment"
|
||||||
import { BulkDeleteUsersRequest, CloudAccount, User } from "@budibase/types"
|
import {
|
||||||
|
BulkDeleteUsersRequest,
|
||||||
|
CloudAccount,
|
||||||
|
InviteUserRequest,
|
||||||
|
InviteUsersRequest,
|
||||||
|
User,
|
||||||
|
} from "@budibase/types"
|
||||||
import {
|
import {
|
||||||
accounts,
|
accounts,
|
||||||
cache,
|
cache,
|
||||||
|
@ -191,58 +195,27 @@ export const tenantUserLookup = async (ctx: any) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const invite = async (ctx: any) => {
|
export const invite = async (ctx: any) => {
|
||||||
let { email, userInfo } = ctx.request.body
|
const request = ctx.request.body as InviteUserRequest
|
||||||
const existing = await usersCore.getGlobalUserByEmail(email)
|
const response = await users.invite([request])
|
||||||
if (existing) {
|
|
||||||
ctx.throw(400, "Email address already in use.")
|
// explicitly throw for single user invite
|
||||||
|
if (response.unsuccessful.length) {
|
||||||
|
const reason = response.unsuccessful[0].reason
|
||||||
|
if (reason === "Unavailable") {
|
||||||
|
ctx.throw(400, reason)
|
||||||
|
} else {
|
||||||
|
ctx.throw(500, reason)
|
||||||
}
|
}
|
||||||
if (!userInfo) {
|
|
||||||
userInfo = {}
|
|
||||||
}
|
}
|
||||||
userInfo.tenantId = tenancy.getTenantId()
|
|
||||||
const opts: any = {
|
|
||||||
subject: "{{ company }} platform invitation",
|
|
||||||
info: userInfo,
|
|
||||||
}
|
|
||||||
await sendEmail(email, EmailTemplatePurpose.INVITATION, opts)
|
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
message: "Invitation has been sent.",
|
message: "Invitation has been sent.",
|
||||||
}
|
}
|
||||||
await events.user.invited()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const inviteMultiple = async (ctx: any) => {
|
export const inviteMultiple = async (ctx: any) => {
|
||||||
let users = ctx.request.body
|
const request = ctx.request.body as InviteUsersRequest
|
||||||
let existing = false
|
ctx.body = await users.invite(request)
|
||||||
let existingEmail
|
|
||||||
for (let user of users) {
|
|
||||||
if (await usersCore.getGlobalUserByEmail(user.email)) {
|
|
||||||
existing = true
|
|
||||||
existingEmail = user.email
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (existing) {
|
|
||||||
ctx.throw(400, `${existingEmail} already exists`)
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < users.length; i++) {
|
|
||||||
let userInfo = users[i].userInfo
|
|
||||||
if (!userInfo) {
|
|
||||||
userInfo = {}
|
|
||||||
}
|
|
||||||
userInfo.tenantId = tenancy.getTenantId()
|
|
||||||
const opts: any = {
|
|
||||||
subject: "{{ company }} platform invitation",
|
|
||||||
info: userInfo,
|
|
||||||
}
|
|
||||||
await sendEmail(users[i].email, EmailTemplatePurpose.INVITATION, opts)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.body = {
|
|
||||||
message: "Invitations have been sent.",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const inviteAccept = async (ctx: any) => {
|
export const inviteAccept = async (ctx: any) => {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { InviteUsersResponse } from "@budibase/types"
|
||||||
|
|
||||||
jest.mock("nodemailer")
|
jest.mock("nodemailer")
|
||||||
import {
|
import {
|
||||||
TestConfiguration,
|
TestConfiguration,
|
||||||
|
@ -27,7 +29,8 @@ describe("/api/global/users", () => {
|
||||||
|
|
||||||
describe("invite", () => {
|
describe("invite", () => {
|
||||||
it("should be able to generate an invitation", async () => {
|
it("should be able to generate an invitation", async () => {
|
||||||
const { code, res } = await api.users.sendUserInvite(sendMailMock)
|
const email = structures.users.newEmail()
|
||||||
|
const { code, res } = await api.users.sendUserInvite(sendMailMock, email)
|
||||||
|
|
||||||
expect(res.body).toEqual({ message: "Invitation has been sent." })
|
expect(res.body).toEqual({ message: "Invitation has been sent." })
|
||||||
expect(sendMailMock).toHaveBeenCalled()
|
expect(sendMailMock).toHaveBeenCalled()
|
||||||
|
@ -35,13 +38,27 @@ describe("/api/global/users", () => {
|
||||||
expect(events.user.invited).toBeCalledTimes(1)
|
expect(events.user.invited).toBeCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should not be able to generate an invitation for existing user", async () => {
|
||||||
|
const { code, res } = await api.users.sendUserInvite(
|
||||||
|
sendMailMock,
|
||||||
|
config.defaultUser!.email,
|
||||||
|
400
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(res.body.message).toBe("Unavailable")
|
||||||
|
expect(sendMailMock).toHaveBeenCalledTimes(0)
|
||||||
|
expect(code).toBeUndefined()
|
||||||
|
expect(events.user.invited).toBeCalledTimes(0)
|
||||||
|
})
|
||||||
|
|
||||||
it("should be able to create new user from invite", async () => {
|
it("should be able to create new user from invite", async () => {
|
||||||
const { code } = await api.users.sendUserInvite(sendMailMock)
|
const email = structures.users.newEmail()
|
||||||
|
const { code } = await api.users.sendUserInvite(sendMailMock, email)
|
||||||
|
|
||||||
const res = await api.users.acceptInvite(code)
|
const res = await api.users.acceptInvite(code)
|
||||||
|
|
||||||
expect(res.body._id).toBeDefined()
|
expect(res.body._id).toBeDefined()
|
||||||
const user = await config.getUser("invite@test.com")
|
const user = await config.getUser(email)
|
||||||
expect(user).toBeDefined()
|
expect(user).toBeDefined()
|
||||||
expect(user._id).toEqual(res.body._id)
|
expect(user._id).toEqual(res.body._id)
|
||||||
expect(events.user.inviteAccepted).toBeCalledTimes(1)
|
expect(events.user.inviteAccepted).toBeCalledTimes(1)
|
||||||
|
@ -49,6 +66,37 @@ describe("/api/global/users", () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("inviteMultiple", () => {
|
||||||
|
it("should be able to generate an invitation", async () => {
|
||||||
|
const newUserInvite = () => ({
|
||||||
|
email: structures.users.newEmail(),
|
||||||
|
userInfo: {},
|
||||||
|
})
|
||||||
|
const request = [newUserInvite(), newUserInvite()]
|
||||||
|
|
||||||
|
const res = await api.users.sendMultiUserInvite(request)
|
||||||
|
|
||||||
|
const body = res.body as InviteUsersResponse
|
||||||
|
expect(body.successful.length).toBe(2)
|
||||||
|
expect(body.unsuccessful.length).toBe(0)
|
||||||
|
expect(sendMailMock).toHaveBeenCalledTimes(2)
|
||||||
|
expect(events.user.invited).toBeCalledTimes(2)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should not be able to generate an invitation for existing user", async () => {
|
||||||
|
const request = [{ email: config.defaultUser!.email, userInfo: {} }]
|
||||||
|
|
||||||
|
const res = await api.users.sendMultiUserInvite(request)
|
||||||
|
|
||||||
|
const body = res.body as InviteUsersResponse
|
||||||
|
expect(body.successful.length).toBe(0)
|
||||||
|
expect(body.unsuccessful.length).toBe(1)
|
||||||
|
expect(body.unsuccessful[0].reason).toBe("Unavailable")
|
||||||
|
expect(sendMailMock).toHaveBeenCalledTimes(0)
|
||||||
|
expect(events.user.invited).toBeCalledTimes(0)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("bulkCreate", () => {
|
describe("bulkCreate", () => {
|
||||||
it("should ignore users existing in the same tenant", async () => {
|
it("should ignore users existing in the same tenant", async () => {
|
||||||
const user = await config.createUser()
|
const user = await config.createUser()
|
||||||
|
|
|
@ -16,12 +16,12 @@ import {
|
||||||
migrations,
|
migrations,
|
||||||
StaticDatabases,
|
StaticDatabases,
|
||||||
ViewName,
|
ViewName,
|
||||||
|
events,
|
||||||
} from "@budibase/backend-core"
|
} from "@budibase/backend-core"
|
||||||
import {
|
import {
|
||||||
MigrationType,
|
MigrationType,
|
||||||
PlatformUserByEmail,
|
PlatformUserByEmail,
|
||||||
User,
|
User,
|
||||||
Account,
|
|
||||||
BulkCreateUsersResponse,
|
BulkCreateUsersResponse,
|
||||||
CreateUserResponse,
|
CreateUserResponse,
|
||||||
BulkDeleteUsersResponse,
|
BulkDeleteUsersResponse,
|
||||||
|
@ -30,8 +30,12 @@ import {
|
||||||
RowResponse,
|
RowResponse,
|
||||||
BulkDocsResponse,
|
BulkDocsResponse,
|
||||||
AccountMetadata,
|
AccountMetadata,
|
||||||
|
InviteUsersRequest,
|
||||||
|
InviteUsersResponse,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { groups as groupUtils } from "@budibase/pro"
|
import { groups as groupUtils } from "@budibase/pro"
|
||||||
|
import { sendEmail } from "../../utilities/email"
|
||||||
|
import { EmailTemplatePurpose } from "../../constants"
|
||||||
|
|
||||||
const PAGE_LIMIT = 8
|
const PAGE_LIMIT = 8
|
||||||
|
|
||||||
|
@ -551,3 +555,53 @@ const bulkDeleteProcessing = async (dbUser: User) => {
|
||||||
// let server know to sync user
|
// let server know to sync user
|
||||||
await apps.syncUserInApps(userId)
|
await apps.syncUserInApps(userId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const invite = async (
|
||||||
|
users: InviteUsersRequest
|
||||||
|
): Promise<InviteUsersResponse> => {
|
||||||
|
const response: InviteUsersResponse = {
|
||||||
|
successful: [],
|
||||||
|
unsuccessful: [],
|
||||||
|
}
|
||||||
|
|
||||||
|
const matchedEmails = await searchExistingEmails(users.map(u => u.email))
|
||||||
|
const newUsers = []
|
||||||
|
|
||||||
|
// separate duplicates from new users
|
||||||
|
for (let user of users) {
|
||||||
|
if (matchedEmails.includes(user.email)) {
|
||||||
|
response.unsuccessful.push({ email: user.email, reason: "Unavailable" })
|
||||||
|
} else {
|
||||||
|
newUsers.push(user)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// overwrite users with new only
|
||||||
|
users = newUsers
|
||||||
|
|
||||||
|
// send the emails for new users
|
||||||
|
const tenantId = tenancy.getTenantId()
|
||||||
|
for (let user of users) {
|
||||||
|
try {
|
||||||
|
let userInfo = user.userInfo
|
||||||
|
if (!userInfo) {
|
||||||
|
userInfo = {}
|
||||||
|
}
|
||||||
|
userInfo.tenantId = tenantId
|
||||||
|
const opts: any = {
|
||||||
|
subject: "{{ company }} platform invitation",
|
||||||
|
info: userInfo,
|
||||||
|
}
|
||||||
|
await sendEmail(user.email, EmailTemplatePurpose.INVITATION, opts)
|
||||||
|
response.successful.push({ email: user.email })
|
||||||
|
await events.user.invited()
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`Failed to send email invitation email=${user.email}`, e)
|
||||||
|
response.unsuccessful.push({
|
||||||
|
email: user.email,
|
||||||
|
reason: "Failed to send email",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {
|
||||||
BulkCreateUsersResponse,
|
BulkCreateUsersResponse,
|
||||||
BulkDeleteUsersRequest,
|
BulkDeleteUsersRequest,
|
||||||
CreateUserResponse,
|
CreateUserResponse,
|
||||||
|
InviteUsersRequest,
|
||||||
User,
|
User,
|
||||||
UserDetails,
|
UserDetails,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
@ -19,17 +20,21 @@ export class UserAPI {
|
||||||
|
|
||||||
// INVITE
|
// INVITE
|
||||||
|
|
||||||
sendUserInvite = async (sendMailMock: any) => {
|
sendUserInvite = async (sendMailMock: any, email: string, status = 200) => {
|
||||||
await this.config.saveSmtpConfig()
|
await this.config.saveSmtpConfig()
|
||||||
await this.config.saveSettingsConfig()
|
await this.config.saveSettingsConfig()
|
||||||
const res = await this.request
|
const res = await this.request
|
||||||
.post(`/api/global/users/invite`)
|
.post(`/api/global/users/invite`)
|
||||||
.send({
|
.send({
|
||||||
email: "invite@test.com",
|
email,
|
||||||
})
|
})
|
||||||
.set(this.config.defaultHeaders())
|
.set(this.config.defaultHeaders())
|
||||||
.expect("Content-Type", /json/)
|
.expect("Content-Type", /json/)
|
||||||
.expect(200)
|
.expect(status)
|
||||||
|
|
||||||
|
if (status !== 200) {
|
||||||
|
return { code: undefined, res }
|
||||||
|
}
|
||||||
|
|
||||||
const emailCall = sendMailMock.mock.calls[0][0]
|
const emailCall = sendMailMock.mock.calls[0][0]
|
||||||
// after this URL there should be a code
|
// after this URL there should be a code
|
||||||
|
@ -51,6 +56,17 @@ export class UserAPI {
|
||||||
.expect(200)
|
.expect(200)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendMultiUserInvite = async (request: InviteUsersRequest, status = 200) => {
|
||||||
|
await this.config.saveSmtpConfig()
|
||||||
|
await this.config.saveSettingsConfig()
|
||||||
|
return this.request
|
||||||
|
.post(`/api/global/users/multi/invite`)
|
||||||
|
.send(request)
|
||||||
|
.set(this.config.defaultHeaders())
|
||||||
|
.expect("Content-Type", /json/)
|
||||||
|
.expect(status)
|
||||||
|
}
|
||||||
|
|
||||||
// BULK
|
// BULK
|
||||||
|
|
||||||
bulkCreateUsers = async (users: User[], groups: any[] = []) => {
|
bulkCreateUsers = async (users: User[], groups: any[] = []) => {
|
||||||
|
|
|
@ -291,12 +291,12 @@
|
||||||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||||
|
|
||||||
"@budibase/backend-core@1.2.58-alpha.1":
|
"@budibase/backend-core@1.2.58-alpha.5":
|
||||||
version "1.2.58-alpha.1"
|
version "1.2.58-alpha.5"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.58-alpha.1.tgz#26fe21df9839e671df70de9403bf9597dcfb15a6"
|
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.58-alpha.5.tgz#430699334629b3bd05a5066aa6660c1f68f047b2"
|
||||||
integrity sha512-WjwwiSc2haaRI9Yg2i7NoZ+QrbVRezM8xBJZWt2sL17xW6VVZ7ao5zCRZD+M0Euo9EO1C25ehCTYI9iUF9UU0w==
|
integrity sha512-Z926rAp0eskXUr5UXGwh0S1OMDA3qzIi8o0GHLlO7KZAzk49RYzhRT/yo1fIst8Eq/9ZCaXLFxIeRkDmCJgILg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@budibase/types" "1.2.58-alpha.1"
|
"@budibase/types" "1.2.58-alpha.5"
|
||||||
"@techpass/passport-openidconnect" "0.3.2"
|
"@techpass/passport-openidconnect" "0.3.2"
|
||||||
aws-sdk "2.1030.0"
|
aws-sdk "2.1030.0"
|
||||||
bcrypt "5.0.1"
|
bcrypt "5.0.1"
|
||||||
|
@ -325,21 +325,21 @@
|
||||||
uuid "8.3.2"
|
uuid "8.3.2"
|
||||||
zlib "1.0.5"
|
zlib "1.0.5"
|
||||||
|
|
||||||
"@budibase/pro@1.2.58-alpha.1":
|
"@budibase/pro@1.2.58-alpha.5":
|
||||||
version "1.2.58-alpha.1"
|
version "1.2.58-alpha.5"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.58-alpha.1.tgz#fbcf2c8712c90d316e8dcec5d807ba9bab27985b"
|
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.58-alpha.5.tgz#1f739653e641ac32d20818517d35bef489ec2ae6"
|
||||||
integrity sha512-cLCXkXnHVJCV+K81BbM2GwkicnBs+W+x97QYo79NhId5pEvIzkmmIuvirtGcihk6hoBI2cPwJUmx5M5CrU574Q==
|
integrity sha512-owT7ipgZ588KAz6aHPJie5bLJX6EkhTRUvUQlyOJuLWt/hdXXnvbu+agxBQNaXE4gVzn916JJP0L0tbiMctjNA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@budibase/backend-core" "1.2.58-alpha.1"
|
"@budibase/backend-core" "1.2.58-alpha.5"
|
||||||
"@budibase/types" "1.2.58-alpha.1"
|
"@budibase/types" "1.2.58-alpha.5"
|
||||||
"@koa/router" "8.0.8"
|
"@koa/router" "8.0.8"
|
||||||
joi "17.6.0"
|
joi "17.6.0"
|
||||||
node-fetch "^2.6.1"
|
node-fetch "^2.6.1"
|
||||||
|
|
||||||
"@budibase/types@1.2.58-alpha.1":
|
"@budibase/types@1.2.58-alpha.5":
|
||||||
version "1.2.58-alpha.1"
|
version "1.2.58-alpha.5"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.58-alpha.1.tgz#1d7335eee57f9cb9bf0141640a563ab545b8178d"
|
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.58-alpha.5.tgz#8ea99745f296a1076f878a06b7c228bc60886cd3"
|
||||||
integrity sha512-qxplmPest4l3BAHbKJ5zd4UcYBqjb8IbPTp4D2Yqm0icjSgDH9uOXA3wBwBbnBKwe8AfxeGkXgHyFkccIFSZvA==
|
integrity sha512-0JhHDGvfcMcjhBckP3RqbKCDsMhx7ZVTV8wvaqsOaG7PnBSst9dxyX7ETVVzfvYolIK1eV11itsgx0FpbYID2w==
|
||||||
|
|
||||||
"@cspotcode/source-map-consumer@0.8.0":
|
"@cspotcode/source-map-consumer@0.8.0":
|
||||||
version "0.8.0"
|
version "0.8.0"
|
||||||
|
|
Loading…
Reference in New Issue