From 883ac0d008c432fdb36b6d4bc1222050bd8228bf Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 8 Nov 2023 16:27:20 +0000 Subject: [PATCH 01/17] Dedupe and improve logic around selecting available datasources for saving and duplicating rows --- .../actions/DuplicateRow.svelte | 65 +++------------ .../ButtonActionEditor/actions/SaveRow.svelte | 58 ++------------ .../ButtonActionEditor/actions/utils.js | 79 +++++++++++++++++++ 3 files changed, 97 insertions(+), 105 deletions(-) create mode 100644 packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/utils.js diff --git a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/DuplicateRow.svelte b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/DuplicateRow.svelte index 18711497ff..94364367a8 100644 --- a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/DuplicateRow.svelte +++ b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/DuplicateRow.svelte @@ -2,27 +2,20 @@ import { Select, Label, Body, Checkbox, Input } from "@budibase/bbui" import { store, currentAsset } from "builderStore" import { tables, viewsV2 } from "stores/backend" - import { - getContextProviderComponents, - getSchemaForDatasourcePlus, - } from "builderStore/dataBinding" + import { getSchemaForDatasourcePlus } from "builderStore/dataBinding" import SaveFields from "./SaveFields.svelte" + import { getDatasourceLikeProviders } from "components/design/settings/controls/ButtonActionEditor/actions/utils" export let parameters export let bindings = [] + export let nested - $: formComponents = getContextProviderComponents( - $currentAsset, - $store.selectedComponentId, - "form" - ) - $: schemaComponents = getContextProviderComponents( - $currentAsset, - $store.selectedComponentId, - "schema" - ) - $: providerOptions = getProviderOptions(formComponents, schemaComponents) - $: schemaFields = getSchemaFields($currentAsset, parameters?.tableId) + $: providerOptions = getDatasourceLikeProviders({ + asset: $currentAsset, + componentId: $store.selectedComponentId, + nested, + }) + $: schemaFields = getSchemaFields(parameters?.tableId) $: tableOptions = $tables.list.map(table => ({ label: table.name, resourceId: table._id, @@ -33,44 +26,8 @@ })) $: options = [...(tableOptions || []), ...(viewOptions || [])] - // Gets a context definition of a certain type from a component definition - const extractComponentContext = (component, contextType) => { - const def = store.actions.components.getDefinition(component?._component) - if (!def) { - return null - } - const contexts = Array.isArray(def.context) ? def.context : [def.context] - return contexts.find(context => context?.type === contextType) - } - - // Gets options for valid context keys which provide valid data to submit - const getProviderOptions = (formComponents, schemaComponents) => { - const formContexts = formComponents.map(component => ({ - component, - context: extractComponentContext(component, "form"), - })) - const schemaContexts = schemaComponents.map(component => ({ - component, - context: extractComponentContext(component, "schema"), - })) - const allContexts = formContexts.concat(schemaContexts) - - return allContexts.map(({ component, context }) => { - let runtimeBinding = component._id - if (context.suffix) { - runtimeBinding += `-${context.suffix}` - } - return { - label: component._instanceName, - value: runtimeBinding, - } - }) - } - - const getSchemaFields = (asset, tableId) => { - const { schema } = getSchemaForDatasourcePlus(tableId) - delete schema._id - delete schema._rev + const getSchemaFields = resourceId => { + const { schema } = getSchemaForDatasourcePlus(resourceId) return Object.values(schema || {}) } diff --git a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/SaveRow.svelte b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/SaveRow.svelte index 27b6463ffa..9f70272d78 100644 --- a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/SaveRow.svelte +++ b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/SaveRow.svelte @@ -2,29 +2,19 @@ import { Select, Label, Body, Checkbox, Input } from "@budibase/bbui" import { store, currentAsset } from "builderStore" import { tables, viewsV2 } from "stores/backend" - import { - getContextProviderComponents, - getSchemaForDatasourcePlus, - } from "builderStore/dataBinding" + import { getSchemaForDatasourcePlus } from "builderStore/dataBinding" import SaveFields from "./SaveFields.svelte" + import { getDatasourceLikeProviders } from "components/design/settings/controls/ButtonActionEditor/actions/utils" export let parameters export let bindings = [] export let nested - $: formComponents = getContextProviderComponents( - $currentAsset, - $store.selectedComponentId, - "form", - { includeSelf: nested } - ) - $: schemaComponents = getContextProviderComponents( - $currentAsset, - $store.selectedComponentId, - "schema", - { includeSelf: nested } - ) - $: providerOptions = getProviderOptions(formComponents, schemaComponents) + $: providerOptions = getDatasourceLikeProviders({ + asset: $currentAsset, + componentId: $store.selectedComponentId, + nested, + }) $: schemaFields = getSchemaFields(parameters?.tableId) $: tableOptions = $tables.list.map(table => ({ label: table.name, @@ -36,40 +26,6 @@ })) $: options = [...(tableOptions || []), ...(viewOptions || [])] - // Gets a context definition of a certain type from a component definition - const extractComponentContext = (component, contextType) => { - const def = store.actions.components.getDefinition(component?._component) - if (!def) { - return null - } - const contexts = Array.isArray(def.context) ? def.context : [def.context] - return contexts.find(context => context?.type === contextType) - } - - // Gets options for valid context keys which provide valid data to submit - const getProviderOptions = (formComponents, schemaComponents) => { - const formContexts = formComponents.map(component => ({ - component, - context: extractComponentContext(component, "form"), - })) - const schemaContexts = schemaComponents.map(component => ({ - component, - context: extractComponentContext(component, "schema"), - })) - const allContexts = formContexts.concat(schemaContexts) - - return allContexts.map(({ component, context }) => { - let runtimeBinding = component._id - if (context.suffix) { - runtimeBinding += `-${context.suffix}` - } - return { - label: component._instanceName, - value: runtimeBinding, - } - }) - } - const getSchemaFields = resourceId => { const { schema } = getSchemaForDatasourcePlus(resourceId) return Object.values(schema || {}) diff --git a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/utils.js b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/utils.js new file mode 100644 index 0000000000..371671f455 --- /dev/null +++ b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/utils.js @@ -0,0 +1,79 @@ +import { getContextProviderComponents } from "builderStore/dataBinding" +import { store } from "builderStore" + +// Generates bindings for all components that provider "datasource like" +// contexts. This includes "form" contexts and "schema" contexts. This is used +// by various button actions as candidates for whole "row" objects. +// Some examples are saving rows or duplicating rows. +export const getDatasourceLikeProviders = ({ asset, componentId, nested }) => { + // Get all form context providers + const formComponents = getContextProviderComponents( + asset, + componentId, + "form", + { includeSelf: nested } + ) + + // Get all schema context providers + const schemaComponents = getContextProviderComponents( + asset, + componentId, + "schema", + { includeSelf: nested } + ) + + // Generate contexts for all form providers + const formContexts = formComponents.map(component => ({ + component, + context: extractComponentContext(component, "form"), + })) + + // Generate contexts for all schema providers + const schemaContexts = schemaComponents.map(component => ({ + component, + context: extractComponentContext(component, "schema"), + })) + + // Check for duplicate contexts by the same component. In this case, attempt + // to label contexts with their suffixes + schemaContexts.forEach(schemaContext => { + // Check if we have a form context for this component + const id = schemaContext.component._id + const existing = formContexts.find(x => x.component._id === id) + if (existing) { + if (existing.context.suffix) { + existing.readableSuffix = ` (${existing.context.suffix})` + } + if (schemaContext.context.suffix) { + schemaContext.readableSuffix = ` (${schemaContext.context.suffix})` + } + } + }) + + // Generate bindings for all contexts + const allContexts = formContexts.concat(schemaContexts) + return allContexts.map(({ component, context, readableSuffix }) => { + let readableBinding = component._instanceName + let runtimeBinding = component._id + if (context.suffix) { + runtimeBinding += `-${context.suffix}` + } + if (readableSuffix) { + readableBinding += readableSuffix + } + return { + label: readableBinding, + value: runtimeBinding, + } + }) +} + +// Gets a context definition of a certain type from a component definition +const extractComponentContext = (component, contextType) => { + const def = store.actions.components.getDefinition(component?._component) + if (!def) { + return null + } + const contexts = Array.isArray(def.context) ? def.context : [def.context] + return contexts.find(context => context?.type === contextType) +} From 6b7e410f0d48ee6ba39bffce9db3ec14e3c5cb0a Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 9 Nov 2023 09:47:19 +0000 Subject: [PATCH 02/17] Update casing --- .../settings/controls/ButtonActionEditor/actions/utils.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/utils.js b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/utils.js index 371671f455..aa076fdd3e 100644 --- a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/utils.js +++ b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/utils.js @@ -1,5 +1,6 @@ import { getContextProviderComponents } from "builderStore/dataBinding" import { store } from "builderStore" +import { capitalise } from "helpers" // Generates bindings for all components that provider "datasource like" // contexts. This includes "form" contexts and "schema" contexts. This is used @@ -42,10 +43,12 @@ export const getDatasourceLikeProviders = ({ asset, componentId, nested }) => { const existing = formContexts.find(x => x.component._id === id) if (existing) { if (existing.context.suffix) { - existing.readableSuffix = ` (${existing.context.suffix})` + const suffix = capitalise(existing.context.suffix) + existing.readableSuffix = ` - ${suffix}` } if (schemaContext.context.suffix) { - schemaContext.readableSuffix = ` (${schemaContext.context.suffix})` + const suffix = capitalise(schemaContext.context.suffix) + schemaContext.readableSuffix = ` - ${suffix}` } } }) From 223a82f71746ada05e186a362f860b2906626b1c Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 9 Nov 2023 11:07:32 +0000 Subject: [PATCH 03/17] Ensure metadata is not null before registering datasources for automatic hot reloading --- .../client/src/components/context/Provider.svelte | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/client/src/components/context/Provider.svelte b/packages/client/src/components/context/Provider.svelte index 19a5c3a462..3fffaaf7fa 100644 --- a/packages/client/src/components/context/Provider.svelte +++ b/packages/client/src/components/context/Provider.svelte @@ -45,12 +45,13 @@ // Register any "refresh datasource" actions with a singleton store // so we can easily refresh data at all levels for any datasource if (type === ActionTypes.RefreshDatasource) { - const { dataSource } = metadata || {} - dataSourceStore.actions.registerDataSource( - dataSource, - instanceId, - callback - ) + if (metadata?.dataSource) { + dataSourceStore.actions.registerDataSource( + metadata.dataSource, + instanceId, + callback + ) + } } }) } From 1f3e56fdc152f6768fc26737b4b04f42471bfbcc Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 9 Nov 2023 11:10:52 +0000 Subject: [PATCH 04/17] Allow grids to provide a refresh datasource action --- .../src/components/app/GridBlock.svelte | 20 ++++++++++++++----- packages/client/src/sdk.js | 2 ++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/client/src/components/app/GridBlock.svelte b/packages/client/src/components/app/GridBlock.svelte index 801e1a4d0a..0b1c12524a 100644 --- a/packages/client/src/components/app/GridBlock.svelte +++ b/packages/client/src/components/app/GridBlock.svelte @@ -27,8 +27,12 @@ builderStore, notificationStore, enrichButtonActions, + ActionTypes, + createContextStore, } = getContext("sdk") + let grid + $: columnWhitelist = columns?.map(col => col.name) $: schemaOverrides = getSchemaOverrides(columns) $: enrichedButtons = enrichButtons(buttons) @@ -53,11 +57,16 @@ text: settings.text, type: settings.type, onClick: async row => { - // We add a fake context binding in here, which allows us to pretend - // that the grid provides a "schema" binding - that lets us use the - // clicked row in things like save row actions - const enrichedContext = { ...get(context), [get(component).id]: row } - const fn = enrichButtonActions(settings.onClick, enrichedContext) + // Create a fake, ephemeral context to run the buttons actions with + const id = get(component).id + const gridContext = createContextStore(context) + gridContext.actions.provideData(id, row) + gridContext.actions.provideAction( + id, + ActionTypes.RefreshDatasource, + () => grid?.getContext()?.rows.actions.refreshData() + ) + const fn = enrichButtonActions(settings.onClick, get(gridContext)) return await fn?.({ row }) }, })) @@ -69,6 +78,7 @@ class:in-builder={$builderStore.inBuilder} > Date: Thu, 9 Nov 2023 11:22:50 +0000 Subject: [PATCH 05/17] Update button actions to support suffixed actions from blocks --- .../builder/src/builderStore/dataBinding.js | 32 ++++++++++++++++--- .../actions/ChangeFormStep.svelte | 12 ++++--- .../actions/ClearForm.svelte | 12 ++++--- .../actions/RefreshDataProvider.svelte | 12 ++++--- .../actions/ScrollTo.svelte | 32 +++++++++++++------ .../actions/UpdateFieldValue.svelte | 32 +++++++++++++------ .../actions/ValidateForm.svelte | 12 ++++--- 7 files changed, 101 insertions(+), 43 deletions(-) diff --git a/packages/builder/src/builderStore/dataBinding.js b/packages/builder/src/builderStore/dataBinding.js index 8445bf9e6d..246590a22e 100644 --- a/packages/builder/src/builderStore/dataBinding.js +++ b/packages/builder/src/builderStore/dataBinding.js @@ -228,7 +228,12 @@ export const getContextProviderComponents = ( /** * Gets all data provider components above a component. */ -export const getActionProviderComponents = (asset, componentId, actionType) => { +export const getActionProviders = ( + asset, + componentId, + actionType, + options = { includeSelf: false } +) => { if (!asset || !componentId) { return [] } @@ -236,13 +241,30 @@ export const getActionProviderComponents = (asset, componentId, actionType) => { // Get the component tree leading up to this component, ignoring the component // itself const path = findComponentPath(asset.props, componentId) - path.pop() + if (!options?.includeSelf) { + path.pop() + } - // Filter by only data provider components - return path.filter(component => { + // Find matching contexts and generate bindings + let providers = [] + path.forEach(component => { const def = store.actions.components.getDefinition(component._component) - return def?.actions?.includes(actionType) + const actions = (def?.actions || []).map(action => { + return typeof action === "string" ? { type: action } : action + }) + const action = actions.find(x => x.type === actionType) + if (action) { + let runtimeBinding = component._id + if (action.suffix) { + runtimeBinding += `-${action.suffix}` + } + providers.push({ + readableBinding: component._instanceName, + runtimeBinding, + }) + } }) + return providers } /** diff --git a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ChangeFormStep.svelte b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ChangeFormStep.svelte index 81a2119474..5905d240dc 100644 --- a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ChangeFormStep.svelte +++ b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ChangeFormStep.svelte @@ -1,17 +1,19 @@ @@ -17,8 +19,8 @@ x._instanceName} - getOptionValue={x => x._id} + getOptionLabel={x => x.readableBinding} + getOptionValue={x => x.runtimeBinding} /> diff --git a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ScrollTo.svelte b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ScrollTo.svelte index 49a93d71dd..e73884495d 100644 --- a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ScrollTo.svelte +++ b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ScrollTo.svelte @@ -1,22 +1,36 @@
@@ -24,8 +38,8 @@ x._instanceName} - getOptionValue={x => x._id} + getOptionLabel={x => x.readableBinding} + getOptionValue={x => x.runtimeBinding} /> x._instanceName} - getOptionValue={x => x._id} + getOptionLabel={x => x.readableBinding} + getOptionValue={x => x.runtimeBinding} />
From 8d1bcfd8b529179b9061a0ba489659af3c0823b2 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 9 Nov 2023 12:38:31 +0000 Subject: [PATCH 06/17] Expose additional actions and context from blocks to utilise new capabilities --- packages/client/manifest.json | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/client/manifest.json b/packages/client/manifest.json index 378d8c3493..806d1aff44 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -6106,6 +6106,24 @@ "defaultValue": "spectrum--medium" } ], + "actions": [ + { + "type": "ValidateForm", + "suffix": "form" + }, + { + "type": "ClearForm", + "suffix": "form" + }, + { + "type": "UpdateFieldValue", + "suffix": "form" + }, + { + "type": "ScrollTo", + "suffix": "form" + } + ], "context": [ { "type": "form", @@ -6361,7 +6379,8 @@ ], "context": { "type": "schema" - } + }, + "actions": ["RefreshDatasource"] }, "bbreferencefield": { "devComment": "As bb reference is only used for user subtype for now, we are using user for icon and labels", From 103e933df80ff27dae8c430a3a0c61edd361419b Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 9 Nov 2023 12:38:40 +0000 Subject: [PATCH 07/17] Ensure button group component has default props --- packages/client/src/components/app/ButtonGroup.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/client/src/components/app/ButtonGroup.svelte b/packages/client/src/components/app/ButtonGroup.svelte index 87b0990701..4954704b1b 100644 --- a/packages/client/src/components/app/ButtonGroup.svelte +++ b/packages/client/src/components/app/ButtonGroup.svelte @@ -3,9 +3,9 @@ import Block from "../Block.svelte" export let buttons = [] - export let direction - export let hAlign - export let vAlign + export let direction = "row" + export let hAlign = "left" + export let vAlign = "top" export let gap = "S" From 5653d78038c6fb62917c1e11171316264d05772d Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 20 Nov 2023 10:31:51 +0000 Subject: [PATCH 08/17] Update pro --- packages/pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pro b/packages/pro index e202f415d9..2cf6f28380 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit e202f415d9fa540d08cc2ba6e27394fbc22f357b +Subproject commit 2cf6f28380d3ab22128b8a889d622fd5adfa31fc From 90ae387fbd9d149fda02cadf6524141ca0603f1f Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 20 Nov 2023 15:46:16 +0100 Subject: [PATCH 09/17] Fix import/export --- packages/frontend-core/src/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/frontend-core/src/index.js b/packages/frontend-core/src/index.js index f51be616f8..37951dc776 100644 --- a/packages/frontend-core/src/index.js +++ b/packages/frontend-core/src/index.js @@ -1,6 +1,5 @@ export { createAPIClient } from "./api" export { fetchData } from "./fetch" -export { Utils } from "./utils" export * as Constants from "./constants" export * from "./stores" export * from "./utils" From 0874489585a15032dd58e4c76db142cf3d96831b Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 20 Nov 2023 15:46:24 +0100 Subject: [PATCH 10/17] Configure import/export --- .eslintrc.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index f6f03c6523..c921f88410 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -57,7 +57,8 @@ "destructuredArrayIgnorePattern": "^_" } ], - "import/no-relative-packages": "error" + "import/no-relative-packages": "error", + "import/export": "error" }, "globals": { "GeolocationPositionError": true From 4d27ff1dc099848a3901a5c5f2a6192863c87fe3 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 20 Nov 2023 16:15:43 +0100 Subject: [PATCH 11/17] eslint import/no-duplicates --- .eslintrc.json | 3 ++- packages/backend-core/src/configs/configs.ts | 7 +++---- packages/backend-core/src/installation.ts | 3 +-- packages/backend-core/src/security/roles.ts | 3 +-- packages/backend-core/src/users/db.ts | 3 +-- packages/bbui/src/Drawer/Drawer.svelte | 5 ++--- packages/bbui/src/Popover/Popover.svelte | 5 ++--- packages/builder/src/builderStore/index.js | 3 +-- packages/builder/src/builderStore/websocket.js | 6 ++---- .../AutomationBuilder/FlowChart/FlowChart.svelte | 5 ++--- .../AutomationPanel/CreateAutomationModal.svelte | 5 ++--- .../AutomationPanel/UpdateAutomationModal.svelte | 5 ++--- .../automation/SetupPanel/AutomationBlockSetup.svelte | 5 ++--- .../automation/Shared/CreateWebhookModal.svelte | 5 ++--- .../backend/DataTable/modals/CreateEditUser.svelte | 8 +++----- .../backend/DataTable/modals/EditRoles.svelte | 5 ++--- .../modals/UpdateDatasourceModal.svelte | 5 ++--- .../popovers/EditDatasourcePopover.svelte | 5 ++--- .../backend/Datasources/CreateEditRelationship.svelte | 10 ++++------ .../TableNavigator/modals/CreateTableModal.svelte | 8 +++----- .../components/common/bindings/BindingPanel.svelte | 10 ++++------ .../ButtonActionEditor/ButtonActionEditor.svelte | 5 ++--- .../controls/DataSourceSelect/DataSourceSelect.svelte | 5 ++--- .../controls/DraggableList/DraggableList.svelte | 5 ++--- .../settings/controls/EditComponentPopover.svelte | 5 ++--- .../FieldConfiguration/FieldConfiguration.svelte | 5 ++--- .../builder/src/components/settings/ThemeModal.svelte | 5 ++--- packages/builder/src/pages/builder/admin/index.svelte | 5 ++--- .../app/[application]/automation/_layout.svelte | 5 ++--- .../CreateExternalDatasourceModal/index.svelte | 5 ++--- .../Authentication/RestAuthenticationBuilder.svelte | 5 ++--- .../Component/ComponentSettingsPanel.svelte | 5 ++--- .../_components/Screen/GeneralPanel.svelte | 5 ++--- .../_components/ComponentList/ComponentTree.svelte | 11 +++++------ .../[screenId]/_components/ComponentList/index.svelte | 5 ++--- packages/builder/src/pages/builder/auth/forgot.svelte | 5 ++--- packages/builder/src/pages/builder/auth/login.svelte | 5 ++--- packages/builder/src/pages/builder/auth/reset.svelte | 5 ++--- .../builder/src/pages/builder/invite/index.svelte | 5 ++--- .../users/_components/AppRoleTableRenderer.svelte | 5 ++--- packages/cli/src/plugins/index.ts | 3 +-- packages/cli/src/utils.ts | 3 +-- .../client/src/components/app/DateRangePicker.svelte | 5 ++--- .../src/components/app/forms/CodeScanner.svelte | 5 ++--- packages/client/src/components/app/table/Table.svelte | 5 ++--- .../src/components/grid/cells/AttachmentCell.svelte | 5 ++--- .../src/components/grid/cells/GutterCell.svelte | 5 ++--- .../src/components/grid/layout/NewRow.svelte | 5 ++--- packages/pro | 2 +- packages/server/src/api/controllers/analytics.ts | 3 +-- packages/server/src/api/controllers/automation.ts | 3 +-- packages/server/src/api/controllers/component.ts | 3 +-- packages/server/src/api/controllers/dev.ts | 3 +-- packages/server/src/api/controllers/table/utils.ts | 10 ++++------ .../src/api/routes/tests/utilities/TestFunctions.ts | 3 +-- packages/server/src/automations/triggers.ts | 3 +-- packages/server/src/integrations/base/sql.ts | 3 +-- packages/server/src/koa.ts | 3 +-- .../src/migrations/functions/backfill/global.ts | 3 +-- packages/server/src/sdk/app/backups/imports.ts | 11 +++++------ packages/server/src/threads/query.ts | 3 +-- .../server/src/utilities/fileSystem/filesystem.ts | 6 ++---- packages/server/src/utilities/rowProcessor/index.ts | 3 +-- packages/server/src/websockets/websocket.ts | 3 +-- packages/worker/src/index.ts | 3 +-- .../src/account-api/api/AccountInternalAPIClient.ts | 3 +-- qa-core/src/public-api/api/apis/RowAPI.ts | 3 +-- qa-core/src/types/appPackage.ts | 3 +-- 68 files changed, 128 insertions(+), 200 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index c921f88410..a0111a6322 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -58,7 +58,8 @@ } ], "import/no-relative-packages": "error", - "import/export": "error" + "import/export": "error", + "import/no-duplicates": "error" }, "globals": { "GeolocationPositionError": true diff --git a/packages/backend-core/src/configs/configs.ts b/packages/backend-core/src/configs/configs.ts index 0c83ed005d..0d189e3f7d 100644 --- a/packages/backend-core/src/configs/configs.ts +++ b/packages/backend-core/src/configs/configs.ts @@ -17,7 +17,6 @@ import { DocumentType, SEPARATOR } from "../constants" import { CacheKey, TTL, withCache } from "../cache" import * as context from "../context" import env from "../environment" -import environment from "../environment" // UTILS @@ -181,10 +180,10 @@ export async function getGoogleDatasourceConfig(): Promise< } export function getDefaultGoogleConfig(): GoogleInnerConfig | undefined { - if (environment.GOOGLE_CLIENT_ID && environment.GOOGLE_CLIENT_SECRET) { + if (env.GOOGLE_CLIENT_ID && env.GOOGLE_CLIENT_SECRET) { return { - clientID: environment.GOOGLE_CLIENT_ID!, - clientSecret: environment.GOOGLE_CLIENT_SECRET!, + clientID: env.GOOGLE_CLIENT_ID!, + clientSecret: env.GOOGLE_CLIENT_SECRET!, activated: true, } } diff --git a/packages/backend-core/src/installation.ts b/packages/backend-core/src/installation.ts index 17eda2004d..6b79b91a37 100644 --- a/packages/backend-core/src/installation.ts +++ b/packages/backend-core/src/installation.ts @@ -1,7 +1,6 @@ import { newid } from "./utils" import * as events from "./events" -import { StaticDatabases } from "./db" -import { doWithDB } from "./db" +import { StaticDatabases , doWithDB } from "./db" import { Installation, IdentityType, Database } from "@budibase/types" import * as context from "./context" import semver from "semver" diff --git a/packages/backend-core/src/security/roles.ts b/packages/backend-core/src/security/roles.ts index 0d33031de5..f1dc0c7cfd 100644 --- a/packages/backend-core/src/security/roles.ts +++ b/packages/backend-core/src/security/roles.ts @@ -1,7 +1,6 @@ import { BuiltinPermissionID, PermissionLevel } from "./permissions" -import { prefixRoleID, getRoleParams, DocumentType, SEPARATOR } from "../db" +import { prefixRoleID, getRoleParams, DocumentType, SEPARATOR , doWithDB } from "../db" import { getAppDB } from "../context" -import { doWithDB } from "../db" import { Screen, Role as RoleDoc } from "@budibase/types" import cloneDeep from "lodash/fp/cloneDeep" diff --git a/packages/backend-core/src/users/db.ts b/packages/backend-core/src/users/db.ts index bd85097bbd..152ff89fdb 100644 --- a/packages/backend-core/src/users/db.ts +++ b/packages/backend-core/src/users/db.ts @@ -1,6 +1,5 @@ import env from "../environment" import * as eventHelpers from "./events" -import * as accounts from "../accounts" import * as accountSdk from "../accounts" import * as cache from "../cache" import { getGlobalDB, getIdentity, getTenantId } from "../context" @@ -467,7 +466,7 @@ export class UserDB { if (!env.SELF_HOSTED && !env.DISABLE_ACCOUNT_PORTAL) { // root account holder can't be deleted from inside budibase const email = dbUser.email - const account = await accounts.getAccount(email) + const account = await accountSdk.getAccount(email) if (account) { if (dbUser.userId === getIdentity()!._id) { throw new HTTPError('Please visit "Account" to delete this user', 400) diff --git a/packages/bbui/src/Drawer/Drawer.svelte b/packages/bbui/src/Drawer/Drawer.svelte index 421d12615f..e2060c9a09 100644 --- a/packages/bbui/src/Drawer/Drawer.svelte +++ b/packages/bbui/src/Drawer/Drawer.svelte @@ -3,9 +3,8 @@ import Button from "../Button/Button.svelte" import Body from "../Typography/Body.svelte" import Heading from "../Typography/Heading.svelte" - import { setContext } from "svelte" - import { createEventDispatcher } from "svelte" - import { generate } from "shortid" + import { setContext , createEventDispatcher } from "svelte" + import { generate } from "shortid" export let title export let fillWidth diff --git a/packages/bbui/src/Popover/Popover.svelte b/packages/bbui/src/Popover/Popover.svelte index 4c4b818440..58cd92ddaa 100644 --- a/packages/bbui/src/Popover/Popover.svelte +++ b/packages/bbui/src/Popover/Popover.svelte @@ -1,12 +1,11 @@ diff --git a/packages/builder/src/pages/builder/admin/index.svelte b/packages/builder/src/pages/builder/admin/index.svelte index ede9d85808..c758f5c7e5 100644 --- a/packages/builder/src/pages/builder/admin/index.svelte +++ b/packages/builder/src/pages/builder/admin/index.svelte @@ -1,11 +1,10 @@ diff --git a/packages/builder/src/pages/builder/admin/index.svelte b/packages/builder/src/pages/builder/admin/index.svelte index c758f5c7e5..9723c6b621 100644 --- a/packages/builder/src/pages/builder/admin/index.svelte +++ b/packages/builder/src/pages/builder/admin/index.svelte @@ -1,10 +1,18 @@ diff --git a/packages/bbui/src/OptionSelectDnD/OptionSelectDnD.svelte b/packages/bbui/src/OptionSelectDnD/OptionSelectDnD.svelte index 8b13135b33..d4ecda246d 100644 --- a/packages/bbui/src/OptionSelectDnD/OptionSelectDnD.svelte +++ b/packages/bbui/src/OptionSelectDnD/OptionSelectDnD.svelte @@ -4,6 +4,7 @@ import Icon from "../Icon/Icon.svelte" import Popover from "../Popover/Popover.svelte" import { onMount } from "svelte" + const flipDurationMs = 150 export let constraints diff --git a/packages/bbui/src/SideNavigation/Item.svelte b/packages/bbui/src/SideNavigation/Item.svelte index dab88b05bc..40d0af0d6e 100644 --- a/packages/bbui/src/SideNavigation/Item.svelte +++ b/packages/bbui/src/SideNavigation/Item.svelte @@ -1,7 +1,9 @@ diff --git a/packages/bbui/src/Table/ArrayRenderer.svelte b/packages/bbui/src/Table/ArrayRenderer.svelte index 637454dbca..303397054a 100644 --- a/packages/bbui/src/Table/ArrayRenderer.svelte +++ b/packages/bbui/src/Table/ArrayRenderer.svelte @@ -1,6 +1,7 @@ diff --git a/packages/builder/src/components/common/renderers/DateTimeRenderer.svelte b/packages/builder/src/components/common/renderers/DateTimeRenderer.svelte index 8bf9499b98..c0fb251dc0 100644 --- a/packages/builder/src/components/common/renderers/DateTimeRenderer.svelte +++ b/packages/builder/src/components/common/renderers/DateTimeRenderer.svelte @@ -1,5 +1,6 @@ diff --git a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ContinueIf.svelte b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ContinueIf.svelte index f284e24645..91b70e0c45 100644 --- a/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ContinueIf.svelte +++ b/packages/builder/src/components/design/settings/controls/ButtonActionEditor/actions/ContinueIf.svelte @@ -2,6 +2,7 @@ import { Select, Body } from "@budibase/bbui" import { onMount } from "svelte" import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte" + export let parameters export let bindings diff --git a/packages/builder/src/components/design/settings/controls/FlatButtonGroup/index.js b/packages/builder/src/components/design/settings/controls/FlatButtonGroup/index.js index 5221ae4ef4..a1903695f4 100644 --- a/packages/builder/src/components/design/settings/controls/FlatButtonGroup/index.js +++ b/packages/builder/src/components/design/settings/controls/FlatButtonGroup/index.js @@ -1,2 +1,3 @@ import FlatButtonGroup from "./FlatButtonGroup.svelte" + export default FlatButtonGroup diff --git a/packages/builder/src/components/integration/QueryViewerBindingBuilder.svelte b/packages/builder/src/components/integration/QueryViewerBindingBuilder.svelte index 3d74e3f6b6..f8a14a6dd1 100644 --- a/packages/builder/src/components/integration/QueryViewerBindingBuilder.svelte +++ b/packages/builder/src/components/integration/QueryViewerBindingBuilder.svelte @@ -1,6 +1,7 @@ diff --git a/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/relationship/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/relationship/index.svelte index f0baf88ffe..cecec0ab53 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/relationship/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/relationship/index.svelte @@ -1,5 +1,6 @@ diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ComponentInfoSection.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ComponentInfoSection.svelte index e73e6d7841..169dfa7934 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ComponentInfoSection.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ComponentInfoSection.svelte @@ -1,6 +1,7 @@ diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/DatasourceTemplateRow.svelte b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/DatasourceTemplateRow.svelte index dac0aaed6e..0db89cfe74 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/DatasourceTemplateRow.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/DatasourceTemplateRow.svelte @@ -1,5 +1,6 @@ diff --git a/packages/builder/src/pages/builder/app/[application]/settings/automation-history/_components/StatusRenderer.svelte b/packages/builder/src/pages/builder/app/[application]/settings/automation-history/_components/StatusRenderer.svelte index fd289163b4..7dd42ad6a6 100644 --- a/packages/builder/src/pages/builder/app/[application]/settings/automation-history/_components/StatusRenderer.svelte +++ b/packages/builder/src/pages/builder/app/[application]/settings/automation-history/_components/StatusRenderer.svelte @@ -1,5 +1,6 @@ diff --git a/packages/builder/src/pages/builder/portal/account/auditLogs/_components/TimeRenderer.svelte b/packages/builder/src/pages/builder/portal/account/auditLogs/_components/TimeRenderer.svelte index b6c0262b47..e1867092c0 100644 --- a/packages/builder/src/pages/builder/portal/account/auditLogs/_components/TimeRenderer.svelte +++ b/packages/builder/src/pages/builder/portal/account/auditLogs/_components/TimeRenderer.svelte @@ -1,6 +1,7 @@ diff --git a/packages/builder/src/pages/builder/portal/index.svelte b/packages/builder/src/pages/builder/portal/index.svelte index 5426d52fae..8651ae5e08 100644 --- a/packages/builder/src/pages/builder/portal/index.svelte +++ b/packages/builder/src/pages/builder/portal/index.svelte @@ -1,4 +1,5 @@ diff --git a/packages/builder/src/pages/builder/portal/settings/index.svelte b/packages/builder/src/pages/builder/portal/settings/index.svelte index 842fe01be8..09ead3e410 100644 --- a/packages/builder/src/pages/builder/portal/settings/index.svelte +++ b/packages/builder/src/pages/builder/portal/settings/index.svelte @@ -1,4 +1,5 @@ diff --git a/packages/builder/src/pages/builder/portal/users/groups/_components/UsersTableRenderer.svelte b/packages/builder/src/pages/builder/portal/users/groups/_components/UsersTableRenderer.svelte index 2adc0c82ae..c701f582a2 100644 --- a/packages/builder/src/pages/builder/portal/users/groups/_components/UsersTableRenderer.svelte +++ b/packages/builder/src/pages/builder/portal/users/groups/_components/UsersTableRenderer.svelte @@ -1,5 +1,6 @@ diff --git a/packages/builder/src/pages/builder/portal/users/index.svelte b/packages/builder/src/pages/builder/portal/users/index.svelte index 4dbb81f7c6..b876b2866c 100644 --- a/packages/builder/src/pages/builder/portal/users/index.svelte +++ b/packages/builder/src/pages/builder/portal/users/index.svelte @@ -1,4 +1,5 @@ diff --git a/packages/builder/src/pages/builder/portal/users/users/_components/RolesTagsTableRenderer.svelte b/packages/builder/src/pages/builder/portal/users/users/_components/RolesTagsTableRenderer.svelte index 7e63045edd..402344dedd 100644 --- a/packages/builder/src/pages/builder/portal/users/users/_components/RolesTagsTableRenderer.svelte +++ b/packages/builder/src/pages/builder/portal/users/users/_components/RolesTagsTableRenderer.svelte @@ -1,5 +1,6 @@