Merge branch 'master' of github.com:Budibase/budibase into design-updates

This commit is contained in:
Andrew Kingston 2022-07-27 11:19:39 +01:00
commit 31ddce3ada
28 changed files with 312 additions and 82 deletions

View File

@ -1,5 +1,5 @@
{
"version": "1.1.21",
"version": "1.1.25",
"npmClient": "yarn",
"packages": [
"packages/*"

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/backend-core",
"version": "1.1.21",
"version": "1.1.25",
"description": "Budibase backend core libraries used in server and worker",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
@ -20,7 +20,7 @@
"test:watch": "jest --watchAll"
},
"dependencies": {
"@budibase/types": "^1.1.21",
"@budibase/types": "^1.1.25",
"@techpass/passport-openidconnect": "0.3.2",
"aws-sdk": "2.1030.0",
"bcrypt": "5.0.1",

View File

@ -1,5 +1,6 @@
import BaseCache from "./base"
import { getWritethroughClient } from "../redis/init"
import { logWarn } from "../logging"
const DEFAULT_WRITE_RATE_MS = 10000
let CACHE: BaseCache | null = null
@ -51,10 +52,8 @@ export async function put(
if (err.status !== 409) {
throw err
} else {
// get the rev, update over it - this is risky, may change in future
const readDoc = await db.get(doc._id)
doc._rev = readDoc._rev
await writeDb(doc)
// Swallow 409s but log them
logWarn(`Ignoring conflict in write-through cache`)
}
}
}

View File

@ -15,6 +15,11 @@ export function logAlert(message: string, e?: any) {
console.error(`bb-alert: ${message} ${errorJson}`)
}
export function logWarn(message: string) {
console.warn(`bb-warn: ${message}`)
}
export default {
logAlert,
logWarn,
}

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.",
"version": "1.1.21",
"version": "1.1.25",
"license": "MPL-2.0",
"svelte": "src/index.js",
"module": "dist/bbui.es.js",
@ -38,7 +38,7 @@
],
"dependencies": {
"@adobe/spectrum-css-workflow-icons": "^1.2.1",
"@budibase/string-templates": "^1.1.21",
"@budibase/string-templates": "^1.1.25",
"@spectrum-css/actionbutton": "^1.0.1",
"@spectrum-css/actiongroup": "^1.0.1",
"@spectrum-css/avatar": "^3.0.2",

View File

@ -26,5 +26,9 @@
<style>
.tooltip {
pointer-events: none;
background: var(--spectrum-global-color-gray-500);
}
.spectrum-Tooltip-tip {
border-top-color: var(--spectrum-global-color-gray-500);
}
</style>

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/builder",
"version": "1.1.21",
"version": "1.1.25",
"license": "GPL-3.0",
"private": true,
"scripts": {
@ -69,10 +69,10 @@
}
},
"dependencies": {
"@budibase/bbui": "^1.1.21",
"@budibase/client": "^1.1.21",
"@budibase/frontend-core": "^1.1.21",
"@budibase/string-templates": "^1.1.21",
"@budibase/bbui": "^1.1.25",
"@budibase/client": "^1.1.25",
"@budibase/frontend-core": "^1.1.25",
"@budibase/string-templates": "^1.1.25",
"@sentry/browser": "5.19.1",
"@spectrum-css/page": "^3.0.1",
"@spectrum-css/vars": "^3.0.1",

View File

@ -1,11 +1,10 @@
import { createLocalStorageStore } from "@budibase/frontend-core"
import { Constants, createLocalStorageStore } from "@budibase/frontend-core"
export const getThemeStore = () => {
const themeElement = document.documentElement
const initialValue = {
theme: "darkest",
options: ["lightest", "light", "dark", "darkest", "nord"],
}
const store = createLocalStorageStore("bb-theme", initialValue)
@ -17,11 +16,14 @@ export const getThemeStore = () => {
return
}
state.options.forEach(option => {
Constants.ThemeOptions.forEach(option => {
themeElement.classList.toggle(
`spectrum--${option}`,
option === state.theme
)
// Ensure darkest is always added as this is the base class for custom
// themes
themeElement.classList.add("spectrum--darkest")
})
})

View File

@ -52,8 +52,9 @@
x => x.blockToLoop === block.id
)
$: setPermissions(role)
$: getPermissions(automationId)
$: isAppAction = block?.stepId === TriggerStepID.APP
$: isAppAction && setPermissions(role)
$: isAppAction && getPermissions(automationId)
async function setPermissions(role) {
if (!role || !automationId) {
@ -238,7 +239,7 @@
</div>
{/if}
{#if block.stepId === TriggerStepID.APP}
{#if isAppAction}
<Label>Role</Label>
<RoleSelect bind:value={role} />
{/if}

View File

@ -15,16 +15,20 @@
let trigger = {}
let schemaProperties = {}
// clone the trigger so we're not mutating the reference
$: trigger = cloneDeep(
$automationStore.selectedAutomation.automation.definition.trigger
)
$: {
// clone the trigger so we're not mutating the reference
trigger = cloneDeep(
$automationStore.selectedAutomation.automation.definition.trigger
)
// get the outputs so we can define the fields
$: schemaProperties = Object.entries(trigger?.schema?.outputs?.properties)
// get the outputs so we can define the fields
let schema = Object.entries(trigger.schema?.outputs?.properties || {})
if (!$automationStore.selectedAutomation.automation.testData) {
$automationStore.selectedAutomation.automation.testData = {}
if (trigger?.event === "app:trigger") {
schema = [["fields", { customType: "fields" }]]
}
schemaProperties = schema
}
// check to see if there is existing test data in the store

View File

@ -1,6 +1,7 @@
<script>
import TableSelector from "./TableSelector.svelte"
import RowSelector from "./RowSelector.svelte"
import FieldSelector from "./FieldSelector.svelte"
import SchemaSetup from "./SchemaSetup.svelte"
import {
Button,
@ -31,6 +32,7 @@
import { getSchemaForTable } from "builderStore/dataBinding"
import { Utils } from "@budibase/frontend-core"
import { TriggerStepID, ActionStepID } from "constants/backend/automations"
import { cloneDeep } from "lodash/fp"
export let block
export let testData
@ -41,13 +43,25 @@
let tempFilters = lookForFilters(schemaProperties) || []
let fillWidth = true
let codeBindingOpen = false
let inputData
$: stepId = block.stepId
$: bindings = getAvailableBindings(
block || $automationStore.selectedBlock,
$automationStore.selectedAutomation?.automation?.definition
)
$: inputData = testData ? testData : block.inputs
$: getInputData(testData, block.inputs)
const getInputData = (testData, blockInputs) => {
let newInputData = testData || blockInputs
if (block.event === "app:trigger" && !newInputData?.fields) {
newInputData = cloneDeep(blockInputs)
}
inputData = newInputData
}
$: tableId = inputData ? inputData.tableId : null
$: table = tableId
? $tables.list.find(table => table._id === inputData.tableId)
@ -73,15 +87,13 @@
[key]: e.detail,
})
testData[key] = e.detail
await automationStore.actions.save(
$automationStore.selectedAutomation?.automation
)
} else {
block.inputs[key] = e.detail
await automationStore.actions.save(
$automationStore.selectedAutomation?.automation
)
}
await automationStore.actions.save(
$automationStore.selectedAutomation?.automation
)
} catch (error) {
notifications.error("Error saving automation")
}
@ -185,11 +197,13 @@
<div class="fields">
{#each schemaProperties as [key, value]}
<div class="block-field">
<Label
tooltip={value.title === "Binding / Value"
? "If using the String input type, please use a comma or newline separated string"
: null}>{value.title || (key === "row" ? "Table" : key)}</Label
>
{#if key !== "fields"}
<Label
tooltip={value.title === "Binding / Value"
? "If using the String input type, please use a comma or newline separated string"
: null}>{value.title || (key === "row" ? "Table" : key)}</Label
>
{/if}
{#if value.type === "string" && value.enum}
<Select
on:change={e => onChange(e, key)}
@ -280,6 +294,14 @@
on:change={e => onChange(e, key)}
value={inputData[key]}
/>
{:else if value.customType === "fields"}
<FieldSelector
{block}
value={inputData[key]}
on:change={e => onChange(e, key)}
{bindings}
{isTestModal}
/>
{:else if value.customType === "triggerSchema"}
<SchemaSetup on:change={e => onChange(e, key)} value={inputData[key]} />
{:else if value.customType === "code"}

View File

@ -0,0 +1,114 @@
<script>
import { createEventDispatcher } from "svelte"
import RowSelectorTypes from "./RowSelectorTypes.svelte"
const dispatch = createEventDispatcher()
export let value
export let bindings
export let block
export let isTestModal
let schemaFields
$: {
let fields = {}
for (const [key, type] of Object.entries(block?.inputs?.fields)) {
fields = {
...fields,
[key]: {
type: type,
name: key,
fieldName: key,
constraints: { type: type },
},
}
if (value[key] === type) {
value[key] = INITIAL_VALUES[type.toUpperCase()]
}
}
schemaFields = Object.entries(fields)
}
const INITIAL_VALUES = {
BOOLEAN: null,
NUMBER: null,
DATETIME: null,
STRING: "",
OPTIONS: [],
ARRAY: [],
}
const coerce = (value, type) => {
const re = new RegExp(/{{([^{].*?)}}/g)
if (re.test(value)) {
return value
}
if (type === "boolean") {
if (typeof value === "boolean") {
return value
}
return value === "true"
}
if (type === "number") {
if (typeof value === "number") {
return value
}
return Number(value)
}
if (type === "options") {
return [value]
}
if (type === "array") {
if (Array.isArray(value)) {
return value
}
return value.split(",").map(x => x.trim())
}
if (type === "link") {
if (Array.isArray(value)) {
return value
}
return [value]
}
return value
}
const onChange = (e, field, type) => {
value[field] = coerce(e.detail, type)
dispatch("change", value)
}
</script>
{#if schemaFields.length && isTestModal}
<div class="schema-fields">
{#each schemaFields as [field, schema]}
<RowSelectorTypes
{isTestModal}
{field}
{schema}
{bindings}
{value}
{onChange}
/>
{/each}
</div>
{/if}
<style>
.schema-fields {
display: grid;
grid-gap: var(--spacing-s);
margin-top: var(--spacing-s);
}
.schema-fields :global(label) {
text-transform: capitalize;
}
</style>

View File

@ -5,6 +5,8 @@ import "@spectrum-css/vars/dist/spectrum-darkest.css"
import "@spectrum-css/vars/dist/spectrum-dark.css"
import "@spectrum-css/vars/dist/spectrum-light.css"
import "@spectrum-css/vars/dist/spectrum-lightest.css"
import "@budibase/frontend-core/src/themes/nord.css"
import "@budibase/frontend-core/src/themes/midnight.css"
import "@spectrum-css/page/dist/index-vars.css"
import "./global.css"
import { suppressWarnings } from "./helpers/warnings"

View File

@ -139,9 +139,10 @@
notifications.success("App ID copied to clipboard.")
}
const exportApp = app => {
const id = isPublished ? app.prodId : app.devId
const exportApp = (app, opts = { published: false }) => {
const appName = encodeURIComponent(app.name)
const id = opts?.published ? app.prodId : app.devId
// always export the development version
window.location = `/api/backups/export?appId=${id}&appname=${appName}`
}
@ -266,12 +267,21 @@
<span slot="control" class="app-overview-actions-icon">
<Icon hoverable name="More" />
</span>
<MenuItem on:click={() => exportApp(selectedApp)} icon="Download">
Export
<MenuItem
on:click={() => exportApp(selectedApp, { published: false })}
icon="DownloadFromCloud"
>
Export latest
</MenuItem>
{#if isPublished}
<MenuItem
on:click={() => exportApp(selectedApp, { published: true })}
icon="DownloadFromCloudOutline"
>
Export published
</MenuItem>
<MenuItem on:click={() => copyAppId(selectedApp)} icon="Copy">
Copy App ID
Copy app ID
</MenuItem>
{/if}
{#if !isPublished}

View File

@ -2,6 +2,7 @@
import { Layout, Heading, Body, Divider, Label, Select } from "@budibase/bbui"
import { themeStore } from "builderStore"
import { capitalise } from "helpers"
import { Constants } from "@budibase/frontend-core"
</script>
<Layout noPadding>
@ -14,7 +15,7 @@
<div class="field">
<Label size="L">Builder theme</Label>
<Select
options={$themeStore.options}
options={Constants.ThemeOptions}
bind:value={$themeStore.theme}
placeholder={null}
getOptionLabel={capitalise}

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/cli",
"version": "1.1.21",
"version": "1.1.25",
"description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "src/index.js",
"bin": {

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/client",
"version": "1.1.21",
"version": "1.1.25",
"license": "MPL-2.0",
"module": "dist/budibase-client.js",
"main": "dist/budibase-client.js",
@ -19,9 +19,9 @@
"dev:builder": "rollup -cw"
},
"dependencies": {
"@budibase/bbui": "^1.1.21",
"@budibase/frontend-core": "^1.1.21",
"@budibase/string-templates": "^1.1.21",
"@budibase/bbui": "^1.1.25",
"@budibase/frontend-core": "^1.1.25",
"@budibase/string-templates": "^1.1.25",
"@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3",

View File

@ -92,7 +92,7 @@
id="spectrum-root"
lang="en"
dir="ltr"
class="spectrum spectrum--medium {$themeStore.theme}"
class="spectrum spectrum--medium spectrum--darkest {$themeStore.theme}"
>
<DeviceBindingsProvider>
<UserBindingsProvider>

View File

@ -1,10 +1,10 @@
import "@spectrum-css/vars/dist/spectrum-global.css"
import "@spectrum-css/vars/dist/spectrum-medium.css"
import "@spectrum-css/vars/dist/spectrum-large.css"
import "@spectrum-css/vars/dist/spectrum-lightest.css"
import "@spectrum-css/vars/dist/spectrum-light.css"
import "@spectrum-css/vars/dist/spectrum-dark.css"
import "@spectrum-css/vars/dist/spectrum-darkest.css"
import "@spectrum-css/vars/dist/spectrum-dark.css"
import "@spectrum-css/vars/dist/spectrum-light.css"
import "@spectrum-css/vars/dist/spectrum-lightest.css"
import "@spectrum-css/page/dist/index-vars.css"
// Non user-facing components
@ -35,6 +35,7 @@ export { default as embeddedmap } from "./embedded-map/EmbeddedMap.svelte"
export * from "./charts"
export * from "./forms"
export * from "./table"
export * from "./blocks"
export * from "./dynamic-filter"

View File

@ -1,12 +1,12 @@
{
"name": "@budibase/frontend-core",
"version": "1.1.21",
"version": "1.1.25",
"description": "Budibase frontend core libraries used in builder and client",
"author": "Budibase",
"license": "MPL-2.0",
"svelte": "src/index.js",
"dependencies": {
"@budibase/bbui": "^1.1.21",
"@budibase/bbui": "^1.1.25",
"lodash": "^4.17.21",
"svelte": "^3.46.2"
}

View File

@ -98,3 +98,12 @@ export const SqlNumberTypeRangeMap = {
min: -8388608,
},
}
export const ThemeOptions = [
"lightest",
"light",
"dark",
"darkest",
"nord",
"midnight",
]

View File

@ -0,0 +1,16 @@
.spectrum--midnight {
--hue: 220;
--sat: 10%;
--spectrum-global-color-gray-50: hsl(var(--hue), var(--sat), 12%);
--spectrum-global-color-gray-75: hsl(var(--hue), var(--sat), 15%);
--spectrum-global-color-gray-100: hsl(var(--hue), var(--sat), 17%);
--spectrum-global-color-gray-200: hsl(var(--hue), var(--sat), 20%);
--spectrum-global-color-gray-300: hsl(var(--hue), var(--sat), 24%);
--spectrum-global-color-gray-400: hsl(var(--hue), var(--sat), 32%);
--spectrum-global-color-gray-500: hsl(var(--hue), var(--sat), 40%);
--spectrum-global-color-gray-600: hsl(var(--hue), var(--sat), 60%);
--spectrum-global-color-gray-700: hsl(var(--hue), var(--sat), 70%);
--spectrum-global-color-gray-800: hsl(var(--hue), var(--sat), 80%);
--spectrum-global-color-gray-900: hsl(var(--hue), var(--sat), 95%);
}

View File

@ -0,0 +1,46 @@
.spectrum--nord {
--spectrum-global-color-red-400: #bf616a;
--spectrum-global-color-red-500: #c26971;
--spectrum-global-color-red-600: #c57179;
--spectrum-global-color-red-700: #c97980;
--spectrum-global-color-static-red-400: #bf616a;
--spectrum-global-color-static-red-500: #c26971;
--spectrum-global-color-static-red-600: #c57179;
--spectrum-global-color-static-red-700: #c97980;
--spectrum-global-color-green-400: #719453;
--spectrum-global-color-green-500: #789d58;
--spectrum-global-color-green-600: #7fa55e;
--spectrum-global-color-green-700: #86aa67;
--spectrum-global-color-static-green-400: #719453;
--spectrum-global-color-static-green-500: #789d58;
--spectrum-global-color-static-green-600: #7fa55e;
--spectrum-global-color-static-green-700: #86aa67;
--spectrum-global-color-blue-400: #5680b4;
--spectrum-global-color-blue-500: #5e86b8;
--spectrum-global-color-blue-600: #668dbb;
--spectrum-global-color-blue-700: #6f93bf;
--spectrum-global-color-static-blue-200: #7799c4;
--spectrum-global-color-static-blue-300: #6f93bf;
--spectrum-global-color-static-blue-400: #668dbb;
--spectrum-global-color-static-blue-500: #5e86b8;
--spectrum-global-color-static-blue-600: #5680b4;
--spectrum-global-color-static-blue-700: #4e79af;
--spectrum-global-color-static-blue-800: #4a73a6;
--spectrum-global-color-gray-50: #2e3440;
--spectrum-global-color-gray-75: #353b4a;
--spectrum-global-color-gray-100: #3b4252;
--spectrum-global-color-gray-200: #4a5367;
--spectrum-global-color-gray-300: #4c566a;
--spectrum-global-color-gray-400: #5a657d;
--spectrum-global-color-gray-500: #677590;
--spectrum-global-color-gray-600: #79869f;
--spectrum-global-color-gray-700: #a9b1c1;
--spectrum-global-color-gray-800: #bac1cd;
--spectrum-global-color-gray-900: #eceff4;
--spectrum-alias-highlight-hover: rgba(169, 177, 193, 0.06);
--spectrum-alias-highlight-active: rgba(169, 177, 193, 0.1);
}

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/server",
"email": "hi@budibase.com",
"version": "1.1.21",
"version": "1.1.25",
"description": "Budibase Web Server",
"main": "src/index.ts",
"repository": {
@ -77,11 +77,11 @@
"license": "GPL-3.0",
"dependencies": {
"@apidevtools/swagger-parser": "10.0.3",
"@budibase/backend-core": "^1.1.21",
"@budibase/client": "^1.1.21",
"@budibase/pro": "1.1.21",
"@budibase/string-templates": "^1.1.21",
"@budibase/types": "^1.1.21",
"@budibase/backend-core": "^1.1.25",
"@budibase/client": "^1.1.25",
"@budibase/pro": "1.1.25",
"@budibase/string-templates": "^1.1.25",
"@budibase/types": "^1.1.25",
"@bull-board/api": "3.7.0",
"@bull-board/koa": "3.9.4",
"@elastic/elasticsearch": "7.10.0",

View File

@ -111,20 +111,12 @@ exports.apiFileReturn = contents => {
}
exports.defineFilter = excludeRows => {
const ids = [USER_METDATA_PREFIX, LINK_USER_METADATA_PREFIX]
if (excludeRows) {
return doc =>
!(
doc._id.includes(USER_METDATA_PREFIX) ||
doc._id.includes(LINK_USER_METADATA_PREFIX) ||
doc._id.includes(TABLE_ROW_PREFIX)
)
} else if (!excludeRows) {
return doc =>
!(
doc._id.includes(USER_METDATA_PREFIX) ||
doc._id.includes(LINK_USER_METADATA_PREFIX)
)
ids.push(TABLE_ROW_PREFIX)
}
return doc =>
!ids.map(key => doc._id.includes(key)).reduce((prev, curr) => prev || curr)
}
/**
@ -132,6 +124,7 @@ exports.defineFilter = excludeRows => {
* data or user relationships.
* @param {string} appId The app to backup
* @param {object} config Config to send to export DB
* @param {boolean} includeRows Flag to state whether the export should include data.
* @returns {*} either a string or a stream of the backup
*/
const backupAppData = async (appId, config, includeRows) => {
@ -154,6 +147,7 @@ exports.performBackup = async (appId, backupName) => {
/**
* Streams a backup of the database state for an app
* @param {string} appId The ID of the app which is to be backed up.
* @param {boolean} includeRows Flag to state whether the export should include data.
* @returns {*} a readable stream of the backup which is written in real time
*/
exports.streamBackup = async (appId, includeRows) => {

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/string-templates",
"version": "1.1.21",
"version": "1.1.25",
"description": "Handlebars wrapper for Budibase templating.",
"main": "src/index.cjs",
"module": "dist/bundle.mjs",

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/types",
"version": "1.1.21",
"version": "1.1.25",
"description": "Budibase types",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/worker",
"email": "hi@budibase.com",
"version": "1.1.21",
"version": "1.1.25",
"description": "Budibase background service",
"main": "src/index.ts",
"repository": {
@ -35,10 +35,10 @@
"author": "Budibase",
"license": "GPL-3.0",
"dependencies": {
"@budibase/backend-core": "^1.1.21",
"@budibase/pro": "1.1.21",
"@budibase/string-templates": "^1.1.21",
"@budibase/types": "^1.1.21",
"@budibase/backend-core": "^1.1.25",
"@budibase/pro": "1.1.25",
"@budibase/string-templates": "^1.1.25",
"@budibase/types": "^1.1.25",
"@koa/router": "8.0.8",
"@sentry/node": "6.17.7",
"@techpass/passport-openidconnect": "0.3.2",