Merge remote-tracking branch 'origin/master' into feature/multistep-form-block

This commit is contained in:
Dean 2023-12-06 14:22:08 +00:00
commit f0603f7edc
18 changed files with 240 additions and 100 deletions

View File

@ -87,6 +87,7 @@ couchdb:
storageClass: "nfs-client" storageClass: "nfs-client"
adminPassword: admin adminPassword: admin
services:
objectStore: objectStore:
storageClass: "nfs-client" storageClass: "nfs-client"
redis: redis:

View File

@ -86,6 +86,7 @@ couchdb:
storageClass: "nfs-client" storageClass: "nfs-client"
adminPassword: admin adminPassword: admin
services:
objectStore: objectStore:
storageClass: "nfs-client" storageClass: "nfs-client"
redis: redis:

View File

@ -16,6 +16,7 @@ spec:
selector: selector:
matchLabels: matchLabels:
app.kubernetes.io/name: budibase-proxy app.kubernetes.io/name: budibase-proxy
minReadySeconds: 10
strategy: strategy:
type: RollingUpdate type: RollingUpdate
template: template:

View File

@ -249,4 +249,30 @@ http {
gzip_comp_level 6; gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml; gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
} }
# From https://docs.datadoghq.com/integrations/nginx/?tab=kubernetes
server {
listen 81;
server_name localhost;
access_log off;
allow 127.0.0.1;
deny all;
location /nginx_status {
# Choose your status module
# freely available with open source NGINX
stub_status;
# for open source NGINX < version 1.7.5
# stub_status on;
# available only with NGINX Plus
# status;
# ensures the version information can be retrieved
server_tokens on;
}
}
} }

View File

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

View File

@ -57,16 +57,11 @@
}} }}
class="buttons" class="buttons"
> >
<Icon hoverable size="M" name="Play" /> <Icon size="M" name="Play" />
<div>Run test</div> <div>Run test</div>
</div> </div>
<div class="buttons"> <div class="buttons">
<Icon <Icon disabled={!$automationStore.testResults} size="M" name="Multiple" />
disabled={!$automationStore.testResults}
hoverable
size="M"
name="Multiple"
/>
<div <div
class:disabled={!$automationStore.testResults} class:disabled={!$automationStore.testResults}
on:click={() => { on:click={() => {

View File

@ -97,6 +97,7 @@
class:typing={typing && !automationNameError} class:typing={typing && !automationNameError}
class:typing-error={automationNameError} class:typing-error={automationNameError}
class="blockSection" class="blockSection"
on:click={() => dispatch("toggle")}
> >
<div class="splitHeader"> <div class="splitHeader">
<div class="center-items"> <div class="center-items">
@ -138,7 +139,20 @@
on:input={e => { on:input={e => {
automationName = e.target.value.trim() automationName = e.target.value.trim()
}} }}
on:click={startTyping} on:click={e => {
e.stopPropagation()
startTyping()
}}
on:keydown={async e => {
if (e.key === "Enter") {
typing = false
if (automationNameError) {
automationName = stepNames[block.id] || block?.name
} else {
await saveName()
}
}
}}
on:blur={async () => { on:blur={async () => {
typing = false typing = false
if (automationNameError) { if (automationNameError) {
@ -168,7 +182,11 @@
</StatusLight> </StatusLight>
</div> </div>
<Icon <Icon
on:click={() => dispatch("toggle")} e.stopPropagation()
on:click={e => {
e.stopPropagation()
dispatch("toggle")
}}
hoverable hoverable
name={open ? "ChevronUp" : "ChevronDown"} name={open ? "ChevronUp" : "ChevronDown"}
/> />
@ -195,7 +213,10 @@
{/if} {/if}
{#if !showTestStatus} {#if !showTestStatus}
<Icon <Icon
on:click={() => dispatch("toggle")} on:click={e => {
e.stopPropagation()
dispatch("toggle")
}}
hoverable hoverable
name={open ? "ChevronUp" : "ChevronDown"} name={open ? "ChevronUp" : "ChevronDown"}
/> />

View File

@ -1,11 +1,9 @@
<script> <script>
import { import {
ModalContent, ModalContent,
Tabs,
Tab,
TextArea, TextArea,
Label,
notifications, notifications,
ActionButton,
} from "@budibase/bbui" } from "@budibase/bbui"
import { automationStore, selectedAutomation } from "builderStore" import { automationStore, selectedAutomation } from "builderStore"
import AutomationBlockSetup from "../../SetupPanel/AutomationBlockSetup.svelte" import AutomationBlockSetup from "../../SetupPanel/AutomationBlockSetup.svelte"
@ -55,50 +53,69 @@
notifications.error(error) notifications.error(error)
} }
} }
const toggle = () => {
selectedValues = !selectedValues
selectedJSON = !selectedJSON
}
let selectedValues = true
let selectedJSON = false
</script> </script>
<ModalContent <ModalContent
title="Add test data" title="Add test data"
confirmText="Test" confirmText="Run test"
size="M" size="L"
showConfirmButton={true} showConfirmButton={true}
disabled={isError} disabled={isError}
onConfirm={testAutomation} onConfirm={testAutomation}
cancelText="Cancel" cancelText="Cancel"
> >
<Tabs selected="Form" quiet> <div class="size">
<Tab icon="Form" title="Form"> <div class="options">
<div class="tab-content-padding"> <ActionButton quiet selected={selectedValues} on:click={toggle}
<AutomationBlockSetup >Use values</ActionButton
{testData} >
{schemaProperties} <ActionButton quiet selected={selectedJSON} on:click={toggle}
isTestModal >Use JSON</ActionButton
block={trigger} >
/> </div>
</div></Tab </div>
>
<Tab icon="FileJson" title="JSON"> {#if selectedValues}
<div class="tab-content-padding"> <div class="tab-content-padding">
<Label>JSON</Label> <AutomationBlockSetup
<div class="text-area-container"> {testData}
<TextArea {schemaProperties}
value={JSON.stringify($selectedAutomation.testData, null, 2)} isTestModal
error={failedParse} block={trigger}
on:change={e => parseTestJSON(e)} />
/> </div>
</div> {/if}
</div> {#if selectedJSON}
</Tab> <div class="text-area-container">
</Tabs> <TextArea
value={JSON.stringify($selectedAutomation.testData, null, 2)}
error={failedParse}
on:change={e => parseTestJSON(e)}
/>
</div>
{/if}
</ModalContent> </ModalContent>
<style> <style>
.text-area-container :global(textarea) { .text-area-container :global(textarea) {
min-height: 200px; min-height: 300px;
height: 200px; height: 300px;
} }
.tab-content-padding { .tab-content-padding {
padding: 0 var(--spacing-xl); padding: 0 var(--spacing-s);
}
.options {
display: flex;
align-items: center;
gap: 8px;
} }
</style> </style>

View File

@ -9,7 +9,7 @@
<div class="title"> <div class="title">
<div class="title-text"> <div class="title-text">
<Icon name="MultipleCheck" /> <Icon name="MultipleCheck" />
<div style="padding-left: var(--spacing-l)">Test Details</div> <div style="padding-left: var(--spacing-l); ">Test Details</div>
</div> </div>
<div style="padding-right: var(--spacing-xl)"> <div style="padding-right: var(--spacing-xl)">
<Icon <Icon
@ -40,6 +40,7 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
padding-top: var(--spacing-s);
} }
.title :global(h1) { .title :global(h1) {

View File

@ -1,20 +1,44 @@
<script> <script>
import AutomationList from "./AutomationList.svelte" import AutomationList from "./AutomationList.svelte"
import CreateAutomationModal from "./CreateAutomationModal.svelte" import CreateAutomationModal from "./CreateAutomationModal.svelte"
import { Modal, Button, Layout } from "@budibase/bbui" import { Modal, Icon } from "@budibase/bbui"
import Panel from "components/design/Panel.svelte" import Panel from "components/design/Panel.svelte"
export let modal export let modal
export let webhookModal export let webhookModal
</script> </script>
<Panel title="Automations" borderRight> <Panel title="Automations" borderRight noHeaderBorder titleCSS={false}>
<Layout paddingX="L" paddingY="XL" gap="S"> <span class="panel-title-content" slot="panel-title-content">
<Button cta on:click={modal.show}>Add automation</Button> <div class="header">
</Layout> <div>Automations</div>
<div on:click={modal.show} class="add-automation-button">
<Icon name="Add" />
</div>
</div>
</span>
<AutomationList /> <AutomationList />
</Panel> </Panel>
<Modal bind:this={modal}> <Modal bind:this={modal}>
<CreateAutomationModal {webhookModal} /> <CreateAutomationModal {webhookModal} />
</Modal> </Modal>
<style>
.header {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--spacing-m);
}
.add-automation-button {
margin-left: 130px;
color: var(--grey-7);
cursor: pointer;
}
.add-automation-button:hover {
color: var(--ink);
}
</style>

View File

@ -149,7 +149,6 @@
} }
const initialiseField = (field, savingColumn) => { const initialiseField = (field, savingColumn) => {
isCreating = !field isCreating = !field
if (field && !savingColumn) { if (field && !savingColumn) {
editableColumn = cloneDeep(field) editableColumn = cloneDeep(field)
originalName = editableColumn.name ? editableColumn.name + "" : null originalName = editableColumn.name ? editableColumn.name + "" : null
@ -171,7 +170,8 @@
relationshipPart2 = part2 relationshipPart2 = part2
} }
} }
} else if (!savingColumn) { }
if (!savingColumn) {
let highestNumber = 0 let highestNumber = 0
Object.keys(table.schema).forEach(columnName => { Object.keys(table.schema).forEach(columnName => {
const columnNumber = extractColumnNumber(columnName) const columnNumber = extractColumnNumber(columnName)
@ -529,8 +529,16 @@
<Layout noPadding gap="S"> <Layout noPadding gap="S">
{#if mounted} {#if mounted}
<Input <Input
value={editableColumn.name}
autofocus autofocus
bind:value={editableColumn.name} on:input={e => {
if (
!uneditable &&
!(linkEditDisabled && editableColumn.type === LINK_TYPE)
) {
editableColumn.name = e.target.value
}
}}
disabled={uneditable || disabled={uneditable ||
(linkEditDisabled && editableColumn.type === LINK_TYPE)} (linkEditDisabled && editableColumn.type === LINK_TYPE)}
error={errors?.name} error={errors?.name}

View File

@ -16,7 +16,8 @@
export let wide = false export let wide = false
export let extraWide = false export let extraWide = false
export let closeButtonIcon = "Close" export let closeButtonIcon = "Close"
export let noHeaderBorder = false
export let titleCSS = true
$: customHeaderContent = $$slots["panel-header-content"] $: customHeaderContent = $$slots["panel-header-content"]
$: customTitleContent = $$slots["panel-title-content"] $: customTitleContent = $$slots["panel-title-content"]
</script> </script>
@ -32,6 +33,7 @@
class="header" class="header"
class:custom={customHeaderContent} class:custom={customHeaderContent}
class:borderBottom={borderBottomHeader} class:borderBottom={borderBottomHeader}
class:noHeaderBorder
> >
{#if showBackButton} {#if showBackButton}
<Icon name="ArrowLeft" hoverable on:click={onClickBackButton} /> <Icon name="ArrowLeft" hoverable on:click={onClickBackButton} />
@ -41,7 +43,7 @@
<Icon name={icon} /> <Icon name={icon} />
</AbsTooltip> </AbsTooltip>
{/if} {/if}
<div class="title"> <div class:title={titleCSS}>
{#if customTitleContent} {#if customTitleContent}
<slot name="panel-title-content" /> <slot name="panel-title-content" />
{:else} {:else}
@ -106,6 +108,10 @@
padding: 0 var(--spacing-l); padding: 0 var(--spacing-l);
gap: var(--spacing-m); gap: var(--spacing-m);
} }
.noHeaderBorder {
border-bottom: none !important;
}
.header.borderBottom { .header.borderBottom {
border-bottom: var(--border-light); border-bottom: var(--border-light);
} }

View File

@ -110,7 +110,7 @@
} }
.setup { .setup {
padding-top: var(--spectrum-global-dimension-size-200); padding-top: 9px;
border-left: var(--border-light); border-left: var(--border-light);
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View File

@ -17,7 +17,7 @@ import {
import { import {
getSqlQuery, getSqlQuery,
buildExternalTableId, buildExternalTableId,
convertSqlType, generateColumnDefinition,
finaliseExternalTables, finaliseExternalTables,
SqlClient, SqlClient,
checkExternalTables, checkExternalTables,
@ -429,15 +429,12 @@ class SqlServerIntegration extends Sql implements DatasourcePlus {
const hasDefault = def.COLUMN_DEFAULT const hasDefault = def.COLUMN_DEFAULT
const isAuto = !!autoColumns.find(col => col === name) const isAuto = !!autoColumns.find(col => col === name)
const required = !!requiredColumns.find(col => col === name) const required = !!requiredColumns.find(col => col === name)
schema[name] = { schema[name] = generateColumnDefinition({
autocolumn: isAuto, autocolumn: isAuto,
name: name, name,
constraints: { presence: required && !isAuto && !hasDefault,
presence: required && !isAuto && !hasDefault,
},
...convertSqlType(def.DATA_TYPE),
externalType: def.DATA_TYPE, externalType: def.DATA_TYPE,
} })
} }
tables[tableName] = { tables[tableName] = {
_id: buildExternalTableId(datasourceId, tableName), _id: buildExternalTableId(datasourceId, tableName),

View File

@ -12,12 +12,13 @@ import {
SourceName, SourceName,
Schema, Schema,
TableSourceType, TableSourceType,
FieldType,
} from "@budibase/types" } from "@budibase/types"
import { import {
getSqlQuery, getSqlQuery,
SqlClient, SqlClient,
buildExternalTableId, buildExternalTableId,
convertSqlType, generateColumnDefinition,
finaliseExternalTables, finaliseExternalTables,
checkExternalTables, checkExternalTables,
} from "./utils" } from "./utils"
@ -305,16 +306,17 @@ class MySQLIntegration extends Sql implements DatasourcePlus {
(column.Extra === "auto_increment" || (column.Extra === "auto_increment" ||
column.Extra.toLowerCase().includes("generated")) column.Extra.toLowerCase().includes("generated"))
const required = column.Null !== "YES" const required = column.Null !== "YES"
const constraints = { schema[columnName] = generateColumnDefinition({
presence: required && !isAuto && !hasDefault,
}
schema[columnName] = {
name: columnName, name: columnName,
autocolumn: isAuto, autocolumn: isAuto,
constraints, presence: required && !isAuto && !hasDefault,
...convertSqlType(column.Type),
externalType: column.Type, externalType: column.Type,
} options: column.Type.startsWith("enum")
? column.Type.substring(5, column.Type.length - 1)
.split(",")
.map(str => str.replace(/^'(.*)'$/, "$1"))
: undefined,
})
} }
if (!tables[tableName]) { if (!tables[tableName]) {
tables[tableName] = { tables[tableName] = {

View File

@ -15,7 +15,7 @@ import {
import { import {
buildExternalTableId, buildExternalTableId,
checkExternalTables, checkExternalTables,
convertSqlType, generateColumnDefinition,
finaliseExternalTables, finaliseExternalTables,
getSqlQuery, getSqlQuery,
SqlClient, SqlClient,
@ -250,14 +250,6 @@ class OracleIntegration extends Sql implements DatasourcePlus {
) )
} }
private internalConvertType(column: OracleColumn) {
if (this.isBooleanType(column)) {
return { type: FieldTypes.BOOLEAN }
}
return convertSqlType(column.type)
}
/** /**
* Fetches the tables from the oracle table and assigns them to the datasource. * Fetches the tables from the oracle table and assigns them to the datasource.
* @param datasourceId - datasourceId to fetch * @param datasourceId - datasourceId to fetch
@ -302,13 +294,15 @@ class OracleIntegration extends Sql implements DatasourcePlus {
const columnName = oracleColumn.name const columnName = oracleColumn.name
let fieldSchema = table.schema[columnName] let fieldSchema = table.schema[columnName]
if (!fieldSchema) { if (!fieldSchema) {
fieldSchema = { fieldSchema = generateColumnDefinition({
autocolumn: OracleIntegration.isAutoColumn(oracleColumn), autocolumn: OracleIntegration.isAutoColumn(oracleColumn),
name: columnName, name: columnName,
constraints: { presence: false,
presence: false, externalType: oracleColumn.type,
}, })
...this.internalConvertType(oracleColumn),
if (this.isBooleanType(oracleColumn)) {
fieldSchema.type = FieldTypes.BOOLEAN
} }
table.schema[columnName] = fieldSchema table.schema[columnName] = fieldSchema

View File

@ -16,7 +16,7 @@ import {
import { import {
getSqlQuery, getSqlQuery,
buildExternalTableId, buildExternalTableId,
convertSqlType, generateColumnDefinition,
finaliseExternalTables, finaliseExternalTables,
SqlClient, SqlClient,
checkExternalTables, checkExternalTables,
@ -162,6 +162,14 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
WHERE pg_namespace.nspname = '${this.config.schema}'; WHERE pg_namespace.nspname = '${this.config.schema}';
` `
ENUM_VALUES = () => `
SELECT t.typname,
e.enumlabel
FROM pg_type t
JOIN pg_enum e on t.oid = e.enumtypid
JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace;
`
constructor(config: PostgresConfig) { constructor(config: PostgresConfig) {
super(SqlClient.POSTGRES) super(SqlClient.POSTGRES)
this.config = config this.config = config
@ -303,6 +311,18 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
const tables: { [key: string]: Table } = {} const tables: { [key: string]: Table } = {}
// Fetch enum values
const enumsResponse = await this.client.query(this.ENUM_VALUES())
const enumValues = enumsResponse.rows?.reduce((acc, row) => {
if (!acc[row.typname]) {
return {
[row.typname]: [row.enumlabel],
}
}
acc[row.typname].push(row.enumlabel)
return acc
}, {})
for (let column of columnsResponse.rows) { for (let column of columnsResponse.rows) {
const tableName: string = column.table_name const tableName: string = column.table_name
const columnName: string = column.column_name const columnName: string = column.column_name
@ -333,16 +353,13 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
column.is_generated && column.is_generated !== "NEVER" column.is_generated && column.is_generated !== "NEVER"
const isAuto: boolean = hasNextVal || identity || isGenerated const isAuto: boolean = hasNextVal || identity || isGenerated
const required = column.is_nullable === "NO" const required = column.is_nullable === "NO"
const constraints = { tables[tableName].schema[columnName] = generateColumnDefinition({
presence: required && !hasDefault && !isGenerated,
}
tables[tableName].schema[columnName] = {
autocolumn: isAuto, autocolumn: isAuto,
name: columnName, name: columnName,
constraints, presence: required && !hasDefault && !isGenerated,
...convertSqlType(column.data_type),
externalType: column.data_type, externalType: column.data_type,
} options: enumValues?.[column.udt_name],
})
} }
let finalizedTables = finaliseExternalTables(tables, entities) let finalizedTables = finaliseExternalTables(tables, entities)

View File

@ -67,6 +67,10 @@ const SQL_BOOLEAN_TYPE_MAP = {
tinyint: FieldType.BOOLEAN, tinyint: FieldType.BOOLEAN,
} }
const SQL_OPTIONS_TYPE_MAP = {
"user-defined": FieldType.OPTIONS,
}
const SQL_MISC_TYPE_MAP = { const SQL_MISC_TYPE_MAP = {
json: FieldType.JSON, json: FieldType.JSON,
bigint: FieldType.BIGINT, bigint: FieldType.BIGINT,
@ -78,6 +82,7 @@ const SQL_TYPE_MAP = {
...SQL_STRING_TYPE_MAP, ...SQL_STRING_TYPE_MAP,
...SQL_BOOLEAN_TYPE_MAP, ...SQL_BOOLEAN_TYPE_MAP,
...SQL_MISC_TYPE_MAP, ...SQL_MISC_TYPE_MAP,
...SQL_OPTIONS_TYPE_MAP,
} }
export enum SqlClient { export enum SqlClient {
@ -178,25 +183,49 @@ export function breakRowIdField(_id: string | { _id: string }): any[] {
} }
} }
export function convertSqlType(type: string) { export function generateColumnDefinition(config: {
externalType: string
autocolumn: boolean
name: string
presence: boolean
options?: string[]
}) {
let { externalType, autocolumn, name, presence, options } = config
let foundType = FieldType.STRING let foundType = FieldType.STRING
const lcType = type.toLowerCase() const lowerCaseType = externalType.toLowerCase()
let matchingTypes = [] let matchingTypes = []
for (let [external, internal] of Object.entries(SQL_TYPE_MAP)) { for (let [external, internal] of Object.entries(SQL_TYPE_MAP)) {
if (lcType.includes(external)) { if (lowerCaseType.includes(external)) {
matchingTypes.push({ external, internal }) matchingTypes.push({ external, internal })
} }
} }
//Set the foundType based the longest match // Set the foundType based the longest match
if (matchingTypes.length > 0) { if (matchingTypes.length > 0) {
foundType = matchingTypes.reduce((acc, val) => { foundType = matchingTypes.reduce((acc, val) => {
return acc.external.length >= val.external.length ? acc : val return acc.external.length >= val.external.length ? acc : val
}).internal }).internal
} }
const schema: any = { type: foundType }
const constraints: {
presence: boolean
inclusion?: string[]
} = {
presence,
}
if (foundType === FieldType.OPTIONS) {
constraints.inclusion = options
}
const schema: any = {
type: foundType,
externalType,
autocolumn,
name,
constraints,
}
if (foundType === FieldType.DATETIME) { if (foundType === FieldType.DATETIME) {
schema.dateOnly = SQL_DATE_ONLY_TYPES.includes(lcType) schema.dateOnly = SQL_DATE_ONLY_TYPES.includes(lowerCaseType)
schema.timeOnly = SQL_TIME_ONLY_TYPES.includes(lcType) schema.timeOnly = SQL_TIME_ONLY_TYPES.includes(lowerCaseType)
} }
return schema return schema
} }