From 7d8cb16824d34cdc3fae80e169395ec7ddd6a687 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 13 Oct 2020 10:59:24 +0100 Subject: [PATCH 01/12] prevent duplicate table names --- .../popovers/CreateEditColumnPopover.svelte | 22 ++++++++++--------- .../modals/CreateTableModal.svelte | 17 ++++++++++++-- .../popovers/EditTablePopover.svelte | 19 ++++++++++++++-- .../standard-components/src/Navigation.svelte | 12 ++++++---- 4 files changed, 52 insertions(+), 18 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/popovers/CreateEditColumnPopover.svelte b/packages/builder/src/components/backend/DataTable/popovers/CreateEditColumnPopover.svelte index 2e2ad6f158..bc076266e5 100644 --- a/packages/builder/src/components/backend/DataTable/popovers/CreateEditColumnPopover.svelte +++ b/packages/builder/src/components/backend/DataTable/popovers/CreateEditColumnPopover.svelte @@ -65,16 +65,18 @@
- + {#if !originalName} + + {/if} {#if field.type !== 'link'} model.name === tableName)) { + error = `Table with name ${tableName} already exists. Please choose another name.` + return + } + error = "" } async function saveTable() { @@ -61,12 +72,14 @@ title="Create Table" confirmText="Create" onConfirm={saveTable} - disabled={!name || (dataImport && !dataImport.valid)}> + disabled={error || !name || (dataImport && !dataImport.valid)}> + on:input={checkValid} + bind:value={name} + {error} />
diff --git a/packages/builder/src/components/backend/ModelNavigator/popovers/EditTablePopover.svelte b/packages/builder/src/components/backend/ModelNavigator/popovers/EditTablePopover.svelte index 028b78a1e8..36ccbb4800 100644 --- a/packages/builder/src/components/backend/ModelNavigator/popovers/EditTablePopover.svelte +++ b/packages/builder/src/components/backend/ModelNavigator/popovers/EditTablePopover.svelte @@ -11,6 +11,8 @@ let dropdown let editing let confirmDeleteDialog + let error = "" + let originalName = table.name $: fields = Object.keys(table.schema) @@ -39,6 +41,15 @@ notifier.success("Table renamed successfully") hideEditor() } + + function checkValid(evt) { + const tableName = evt.target.value + if (originalName !== tableName && $backendUiStore.models.some(model => model.name === tableName)) { + error = `Table with name ${tableName} already exists. Please choose another name.` + return + } + error = "" + }
@@ -48,7 +59,11 @@ {#if editing}
Edit Table
- + + {error} /> diff --git a/packages/builder/src/pages/[application]/_reset.svelte b/packages/builder/src/pages/[application]/_reset.svelte index 7174bd14d7..b7199d27fe 100644 --- a/packages/builder/src/pages/[application]/_reset.svelte +++ b/packages/builder/src/pages/[application]/_reset.svelte @@ -68,7 +68,10 @@ window.open(`/${application}`)}> + on:click={() => { + document.cookie = 'budibase:token=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;' + window.open(`/${application}`) + }}>
@@ -77,7 +80,7 @@ {#await promise}
- {:then result} + {:then results} {:catch error}

Something went wrong: {error.message}

diff --git a/packages/server/src/api/controllers/auth.js b/packages/server/src/api/controllers/auth.js index ac436399a9..0fed3337f8 100644 --- a/packages/server/src/api/controllers/auth.js +++ b/packages/server/src/api/controllers/auth.js @@ -41,7 +41,7 @@ exports.authenticate = async ctx => { dbUser = await instanceDb.get(generateUserID(username)) } catch (_) { // do not want to throw a 404 - as this could be - // used to dtermine valid usernames + // used to determine valid usernames ctx.throw(401, "Invalid Credentials") } diff --git a/packages/server/src/api/controllers/static.js b/packages/server/src/api/controllers/static.js index 5aaa9ab125..2abb0069ab 100644 --- a/packages/server/src/api/controllers/static.js +++ b/packages/server/src/api/controllers/static.js @@ -1,6 +1,5 @@ const send = require("koa-send") const { resolve, join } = require("../../utilities/centralPath") -const jwt = require("jsonwebtoken") const fetch = require("node-fetch") const fs = require("fs-extra") const uuid = require("uuid") @@ -13,8 +12,8 @@ const { } = require("../../utilities/budibaseDir") const CouchDB = require("../../db") const setBuilderToken = require("../../utilities/builder/setBuilderToken") -const { ANON_LEVEL_ID } = require("../../utilities/accessLevels") const fileProcessor = require("../../utilities/fileProcessor") +const { AuthTypes } = require("../../constants") exports.serveBuilder = async function(ctx) { let builderPath = resolve(__dirname, "../../../builder") @@ -136,7 +135,8 @@ exports.performLocalFileProcessing = async function(ctx) { } exports.serveApp = async function(ctx) { - const mainOrAuth = ctx.auth.authenticated ? "main" : "unauthenticated" + const mainOrAuth = + ctx.auth.authenticated === AuthTypes.APP ? "main" : "unauthenticated" // default to homedir const appPath = resolve( @@ -146,26 +146,7 @@ exports.serveApp = async function(ctx) { mainOrAuth ) - let appId = ctx.params.appId - if (process.env.CLOUD) { - appId = ctx.subdomains[1] - } - - // only set the appId cookie for /appId .. we COULD check for valid appIds - // but would like to avoid that DB hit - const looksLikeAppId = /^(app_)?[0-9a-f]{32}$/.test(appId) - if (looksLikeAppId && !ctx.auth.authenticated) { - const anonUser = { - userId: "ANON", - accessLevelId: ANON_LEVEL_ID, - appId, - } - const anonToken = jwt.sign(anonUser, ctx.config.jwtSecret) - ctx.cookies.set("budibase:token", anonToken, { - path: "/", - httpOnly: false, - }) - } + const appId = ctx.user.appId if (process.env.CLOUD) { const S3_URL = `https://${appId}.app.budi.live/assets/${appId}/${mainOrAuth}/${ctx.file || @@ -200,7 +181,8 @@ exports.serveAttachment = async function(ctx) { exports.serveAppAsset = async function(ctx) { // default to homedir - const mainOrAuth = ctx.auth.authenticated ? "main" : "unauthenticated" + const mainOrAuth = + ctx.auth.authenticated === AuthTypes.APP ? "main" : "unauthenticated" const appPath = resolve( budibaseAppsDir(), diff --git a/packages/server/src/constants/index.js b/packages/server/src/constants/index.js new file mode 100644 index 0000000000..cae1cde3e8 --- /dev/null +++ b/packages/server/src/constants/index.js @@ -0,0 +1,7 @@ +const AuthTypes = { + APP: "app", + BUILDER: "builder", + EXTERNAL: "external", +} + +exports.AuthTypes = AuthTypes diff --git a/packages/server/src/middleware/authenticated.js b/packages/server/src/middleware/authenticated.js index 1203ea0033..3a2c2ec9a9 100644 --- a/packages/server/src/middleware/authenticated.js +++ b/packages/server/src/middleware/authenticated.js @@ -7,6 +7,8 @@ const { BUILDER_LEVEL_ID, ANON_LEVEL_ID, } = require("../utilities/accessLevels") +const environment = require("../environment") +const { AuthTypes } = require("../constants") module.exports = async (ctx, next) => { if (ctx.path === "/_builder") { @@ -17,36 +19,28 @@ module.exports = async (ctx, next) => { const appToken = ctx.cookies.get("budibase:token") const builderToken = ctx.cookies.get("builder:token") - if (builderToken) { - try { - const jwtPayload = jwt.verify(builderToken, ctx.config.jwtSecret) - ctx.auth = { - apiKey: jwtPayload.apiKey, - authenticated: jwtPayload.accessLevelId === BUILDER_LEVEL_ID, - } - ctx.user = { - ...jwtPayload, - accessLevel: await getAccessLevel( - jwtPayload.instanceId, - jwtPayload.accessLevelId - ), - } - } catch (_) { - // empty: do nothing - } - - await next() - return + let token + // if running locally in the builder itself + if (!environment.CLOUD && !appToken) { + token = builderToken + ctx.auth.authenticated = AuthTypes.BUILDER + } else { + token = appToken + ctx.auth.authenticated = AuthTypes.APP } - if (!appToken) { + if (!token) { ctx.auth.authenticated = false + ctx.user = { + appId: process.env.CLOUD ? ctx.subdomains[1] : ctx.params.appId, + } await next() return } try { - const jwtPayload = jwt.verify(appToken, ctx.config.jwtSecret) + const jwtPayload = jwt.verify(token, ctx.config.jwtSecret) + ctx.auth.apiKey = jwtPayload.apiKey ctx.user = { ...jwtPayload, accessLevel: await getAccessLevel( @@ -54,10 +48,6 @@ module.exports = async (ctx, next) => { jwtPayload.accessLevelId ), } - ctx.auth = { - authenticated: ctx.user.accessLevelId !== ANON_LEVEL_ID, - apiKey: jwtPayload.apiKey, - } } catch (err) { ctx.throw(err.status || STATUS_CODES.FORBIDDEN, err.text) } diff --git a/packages/server/src/middleware/authorized.js b/packages/server/src/middleware/authorized.js index bd09029471..238b2cab3d 100644 --- a/packages/server/src/middleware/authorized.js +++ b/packages/server/src/middleware/authorized.js @@ -7,6 +7,7 @@ const { } = require("../utilities/accessLevels") const environment = require("../environment") const { apiKeyTable } = require("../db/dynamoClient") +const { AuthTypes } = require("../constants") module.exports = (permName, getItemId) => async (ctx, next) => { if ( @@ -21,8 +22,7 @@ module.exports = (permName, getItemId) => async (ctx, next) => { if (apiKeyInfo) { ctx.auth = { - authenticated: true, - external: true, + authenticated: AuthTypes.EXTERNAL, apiKey: ctx.headers["x-api-key"], } ctx.user = { @@ -42,6 +42,10 @@ module.exports = (permName, getItemId) => async (ctx, next) => { ctx.throw(403, "User not found") } + if (ctx.user.accessLevel._id === ADMIN_LEVEL_ID) { + return next() + } + if (ctx.user.accessLevel._id === BUILDER_LEVEL_ID) { return next() } @@ -53,10 +57,6 @@ module.exports = (permName, getItemId) => async (ctx, next) => { const permissionId = ({ name, itemId }) => name + (itemId ? `-${itemId}` : "") - if (ctx.user.accessLevel._id === ADMIN_LEVEL_ID) { - return next() - } - const thisPermissionId = permissionId({ name: permName, itemId: getItemId && getItemId(ctx), diff --git a/packages/server/src/utilities/accessLevels.js b/packages/server/src/utilities/accessLevels.js index 201007527c..ada3f36880 100644 --- a/packages/server/src/utilities/accessLevels.js +++ b/packages/server/src/utilities/accessLevels.js @@ -21,7 +21,6 @@ module.exports.PRETTY_ACCESS_LEVELS = { [module.exports.ADMIN_LEVEL_ID]: "Admin", [module.exports.POWERUSER_LEVEL_ID]: "Power user", [module.exports.BUILDER_LEVEL_ID]: "Builder", - [module.exports.ANON_LEVEL_ID]: "Anonymous", } module.exports.adminPermissions = [ { diff --git a/packages/standard-components/src/Test/TestApp.svelte b/packages/standard-components/src/Test/TestApp.svelte index 13504e1e15..1ad2cc484e 100644 --- a/packages/standard-components/src/Test/TestApp.svelte +++ b/packages/standard-components/src/Test/TestApp.svelte @@ -35,7 +35,7 @@ {#await _appPromise} loading -{:then _bb} +{:then [object Object]}
{/await} From 72746c6e07bb06241a25a08619caf259dd94c152 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 13 Oct 2020 21:37:55 +0100 Subject: [PATCH 07/12] fixing funky svelte prettier issue --- packages/standard-components/src/Test/TestApp.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/standard-components/src/Test/TestApp.svelte b/packages/standard-components/src/Test/TestApp.svelte index 1ad2cc484e..13504e1e15 100644 --- a/packages/standard-components/src/Test/TestApp.svelte +++ b/packages/standard-components/src/Test/TestApp.svelte @@ -35,7 +35,7 @@ {#await _appPromise} loading -{:then [object Object]} +{:then _bb}
{/await} From 2ae3191758f1420f97851baf71e56669889ea826 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 14 Oct 2020 13:09:03 +0100 Subject: [PATCH 08/12] fix csv import --- packages/server/src/utilities/csvParser.js | 3 ++- packages/server/src/utilities/fileProcessor.js | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/server/src/utilities/csvParser.js b/packages/server/src/utilities/csvParser.js index 872ee5f8a4..aacb599676 100644 --- a/packages/server/src/utilities/csvParser.js +++ b/packages/server/src/utilities/csvParser.js @@ -7,6 +7,7 @@ const VALIDATORS = { } const PARSERS = { + number: attribute => Number(attribute), datetime: attribute => new Date(attribute).toISOString(), } @@ -24,7 +25,7 @@ function parse(path, parsers) { } } }) - result.fromFile(path).subscribe(row => { + result.subscribe((row, lineNumber) => { // For each CSV row parse all the columns that need parsed for (let key in parsers) { if (!schema[key] || schema[key].success) { diff --git a/packages/server/src/utilities/fileProcessor.js b/packages/server/src/utilities/fileProcessor.js index 3e580e9e37..4c219b758f 100644 --- a/packages/server/src/utilities/fileProcessor.js +++ b/packages/server/src/utilities/fileProcessor.js @@ -1,5 +1,5 @@ const fs = require("fs") -const sharp = require("sharp") +// const sharp = require("sharp") const fsPromises = fs.promises const FORMATS = { @@ -7,14 +7,14 @@ const FORMATS = { } async function processImage(file) { - const imgMeta = await sharp(file.path) - .resize(300) - .toFile(file.outputPath) + // const imgMeta = await sharp(file.path) + // .resize(300) + // .toFile(file.outputPath) - return { - ...file, - ...imgMeta, - } + // return { + // ...file, + // ...imgMeta, + // } } async function process(file) { From 79b50dc0b7c01a22e7d41b1ba74aaa7df0ce6d35 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 14 Oct 2020 13:21:43 +0100 Subject: [PATCH 09/12] lint --- package.json | 2 +- .../BlockList/AutomationBlock.svelte | 4 +--- .../automation/SetupPanel/SetupPanel.svelte | 5 +---- .../components/backend/DataTable/Table.svelte | 3 ++- .../backend/DataTable/TablePagination.svelte | 17 +++++++++-------- .../Notification/NotificationDisplay.svelte | 4 +--- .../src/components/common/Switcher.svelte | 4 ---- .../src/components/settings/Integration.svelte | 4 +--- .../builder/src/components/start/AppCard.svelte | 4 +++- .../src/components/start/TemplateList.svelte | 7 +++---- .../components/userInterface/CategoryTab.svelte | 1 - .../userInterface/ComponentDropdownMenu.svelte | 4 +--- .../ComponentPropertiesPanel.svelte | 3 --- .../userInterface/ComponentSelectionList.svelte | 1 - .../userInterface/ComponentsHierarchy.svelte | 3 --- .../ComponentsHierarchyChildren.svelte | 1 - .../userInterface/ComponentsPaneSwitcher.svelte | 4 ---- .../components/userInterface/DesignView.svelte | 1 - .../EventsEditor/StateBindingCascader.svelte | 4 +--- .../EventsEditor/actions/CreateRow.svelte | 1 - .../EventsEditor/actions/SaveRow.svelte | 1 - .../EventsEditor/actions/UpdateRow.svelte | 1 - .../userInterface/IconSelect/IconSelect.svelte | 4 +--- .../userInterface/ItemTab/Item.svelte | 4 +--- .../userInterface/NewScreenModal.svelte | 2 -- .../backend/table/[selectedTable]/index.svelte | 4 +--- .../[application]/backend/table/index.svelte | 4 +--- .../backend/view/[selectedView]/index.svelte | 4 +--- packages/server/src/utilities/csvParser.js | 2 +- packages/server/src/utilities/fileProcessor.js | 17 ++++++++--------- packages/standard-components/src/Card.svelte | 4 +--- .../src/CardHorizontal.svelte | 4 +--- .../src/DataGrid/AttachmentCell/Button.svelte | 13 +------------ .../src/DataGrid/Component.svelte | 4 +++- packages/standard-components/src/Login.svelte | 4 +--- packages/standard-components/src/Text.svelte | 4 +--- .../src/attachments/AttachmentList.svelte | 4 +--- yarn.lock | 11 +++++------ 38 files changed, 52 insertions(+), 116 deletions(-) diff --git a/package.json b/package.json index 5a7d40fe1c..1ca7218bd4 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "eslint-plugin-svelte3": "^2.7.3", "lerna": "3.14.1", "prettier": "^1.19.1", - "prettier-plugin-svelte": "^0.7.0", + "prettier-plugin-svelte": "^1.4.0", "rimraf": "^3.0.2", "rollup-plugin-replace": "^2.2.0", "svelte": "^3.28.0" diff --git a/packages/builder/src/components/automation/AutomationPanel/BlockList/AutomationBlock.svelte b/packages/builder/src/components/automation/AutomationPanel/BlockList/AutomationBlock.svelte index b8ac6638ae..2419999475 100644 --- a/packages/builder/src/components/automation/AutomationPanel/BlockList/AutomationBlock.svelte +++ b/packages/builder/src/components/automation/AutomationPanel/BlockList/AutomationBlock.svelte @@ -23,9 +23,7 @@ class="automation-block hoverable" on:click={addBlockToAutomation} data-cy={stepId}> -
- -
+

{blockDefinition.name}

{blockDefinition.description}

diff --git a/packages/builder/src/components/automation/SetupPanel/SetupPanel.svelte b/packages/builder/src/components/automation/SetupPanel/SetupPanel.svelte index f2b7a8b711..37ca1f2252 100644 --- a/packages/builder/src/components/automation/SetupPanel/SetupPanel.svelte +++ b/packages/builder/src/components/automation/SetupPanel/SetupPanel.svelte @@ -62,10 +62,7 @@ {#if $automationStore.selectedBlock} {:else if $automationStore.selectedAutomation} -
- Automation - {automation.name} -
+
Automation {automation.name}
{/if}
diff --git a/packages/builder/src/components/backend/DataTable/Table.svelte b/packages/builder/src/components/backend/DataTable/Table.svelte index dde114a76c..4c0dc06d39 100644 --- a/packages/builder/src/components/backend/DataTable/Table.svelte +++ b/packages/builder/src/components/backend/DataTable/Table.svelte @@ -108,7 +108,8 @@
selectRelationship(row, header)}> - {row[header] ? row[header].length : 0} related row(s) + {row[header] ? row[header].length : 0} + related row(s)
{:else if schema[header].type === 'attachment'} diff --git a/packages/builder/src/components/backend/DataTable/TablePagination.svelte b/packages/builder/src/components/backend/DataTable/TablePagination.svelte index ccb7d0fc4c..ca5a58700d 100644 --- a/packages/builder/src/components/backend/DataTable/TablePagination.svelte +++ b/packages/builder/src/components/backend/DataTable/TablePagination.svelte @@ -49,9 +49,7 @@ - {#if currentPage > 3} - - {/if} + {#if currentPage > 3}{/if} {#each pagesAroundCurrent as idx} - {/if} + {#if currentPage < numPages - 4}{/if}
diff --git a/packages/builder/src/components/common/Notification/NotificationDisplay.svelte b/packages/builder/src/components/common/Notification/NotificationDisplay.svelte index ad32f228cb..55adef2fbf 100644 --- a/packages/builder/src/components/common/Notification/NotificationDisplay.svelte +++ b/packages/builder/src/components/common/Notification/NotificationDisplay.svelte @@ -31,9 +31,7 @@ style="background: {themes[notification.type]};" transition:fly={{ y: -30 }}>
{notification.message}
- {#if notification.icon} - - {/if} + {#if notification.icon}{/if}
{/each}
diff --git a/packages/builder/src/components/common/Switcher.svelte b/packages/builder/src/components/common/Switcher.svelte index 9119aada4b..707bbfcc64 100644 --- a/packages/builder/src/components/common/Switcher.svelte +++ b/packages/builder/src/components/common/Switcher.svelte @@ -12,15 +12,12 @@
-
- {#each tabs as tab} {/each} -
@@ -34,7 +31,6 @@ {/if}
-
--> + diff --git a/packages/standard-components/src/DataGrid/Component.svelte b/packages/standard-components/src/DataGrid/Component.svelte index b7a277435d..6a2a6ded61 100644 --- a/packages/standard-components/src/DataGrid/Component.svelte +++ b/packages/standard-components/src/DataGrid/Component.svelte @@ -123,7 +123,9 @@ {#if selectedRows.length > 0} - Delete {selectedRows.length} row(s) + Delete + {selectedRows.length} + row(s) {/if}
diff --git a/packages/standard-components/src/Login.svelte b/packages/standard-components/src/Login.svelte index b7435def58..6f2acb2d97 100644 --- a/packages/standard-components/src/Login.svelte +++ b/packages/standard-components/src/Login.svelte @@ -42,9 +42,7 @@
{#if logo} -
- logo -
+
logo
{/if} {#if title} diff --git a/packages/standard-components/src/Text.svelte b/packages/standard-components/src/Text.svelte index 96fc09e025..55b8fb762b 100644 --- a/packages/standard-components/src/Text.svelte +++ b/packages/standard-components/src/Text.svelte @@ -33,6 +33,4 @@ {text} {:else if isTag('sup')} {text} -{:else} - {text} -{/if} +{:else}{text}{/if} diff --git a/packages/standard-components/src/attachments/AttachmentList.svelte b/packages/standard-components/src/attachments/AttachmentList.svelte index bb58d5b0a3..52f61e2d8e 100644 --- a/packages/standard-components/src/attachments/AttachmentList.svelte +++ b/packages/standard-components/src/attachments/AttachmentList.svelte @@ -12,9 +12,7 @@
{#if FILE_TYPES.IMAGE.includes(file.extension.toLowerCase())} preview of {file.name} - {:else} - - {/if} + {:else}{/if}
{file.name} diff --git a/yarn.lock b/yarn.lock index 9b84e373af..0c0f88a3d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3690,11 +3690,10 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier-plugin-svelte@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/prettier-plugin-svelte/-/prettier-plugin-svelte-0.7.0.tgz#5ac0b9f194e0450c88ff1e167cbf3b32d2642df2" - dependencies: - tslib "^1.9.3" +prettier-plugin-svelte@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/prettier-plugin-svelte/-/prettier-plugin-svelte-1.4.0.tgz#bb992759fb77ec2c3545d454a7c60f7a258cb745" + integrity sha512-KXO2He7Kql0Lz4DdlzVli1j2JTDUR9jPV/DqyfnJmY1pCeSV1qZkxgdsyYma35W6OLrCAr/G6yKdmzo+75u2Ng== prettier@^1.19.1: version "1.19.1" @@ -4529,7 +4528,7 @@ trim-off-newlines@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" -tslib@^1.9.0, tslib@^1.9.3: +tslib@^1.9.0: version "1.10.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" From 4be3014e91d3351902cfab196d7c59d5540b0b2e Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 14 Oct 2020 15:06:48 +0100 Subject: [PATCH 10/12] update row_save event --- .../userInterface/temporaryPanelStructure.js | 74 +++++++++---------- packages/server/src/api/controllers/row.js | 24 +++--- 2 files changed, 45 insertions(+), 53 deletions(-) diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 7914e1a43a..36a6c8e073 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -1165,14 +1165,6 @@ export default { }, children: [], }, - // { - // name: "Map", - // _component: "@budibase/standard-components/datamap", - // description: "Shiny map", - // icon: "ri-map-pin-line", - // properties: { design: { ...all } }, - // children: [], - // }, ], }, { @@ -1206,39 +1198,39 @@ export default { ], }, }, - { - name: "Login", - _component: "@budibase/standard-components/login", - description: - "A component that automatically generates a login screen for your app.", - icon: "ri-login-box-line", - children: [], - properties: { - design: { ...all }, - settings: [ - { - label: "Name", - key: "name", - control: Input, - }, - { - label: "Logo", - key: "logo", - control: Input, - }, - { - label: "Title", - key: "title", - control: Input, - }, - { - label: "Button Text", - key: "buttonText", - control: Input, - }, - ], - }, - }, + // { + // name: "Login", + // _component: "@budibase/standard-components/login", + // description: + // "A component that automatically generates a login screen for your app.", + // icon: "ri-login-box-line", + // children: [], + // properties: { + // design: { ...all }, + // settings: [ + // { + // label: "Name", + // key: "name", + // control: Input, + // }, + // { + // label: "Logo", + // key: "logo", + // control: Input, + // }, + // { + // label: "Title", + // key: "title", + // control: Input, + // }, + // { + // label: "Button Text", + // key: "buttonText", + // control: Input, + // }, + // ], + // }, + // }, ], }, ], diff --git a/packages/server/src/api/controllers/row.js b/packages/server/src/api/controllers/row.js index 9c39149bae..8466cfcc33 100644 --- a/packages/server/src/api/controllers/row.js +++ b/packages/server/src/api/controllers/row.js @@ -12,16 +12,16 @@ const { cloneDeep } = require("lodash") const TABLE_VIEW_BEGINS_WITH = `all${SEPARATOR}${DocumentTypes.TABLE}${SEPARATOR}` validateJs.extend(validateJs.validators.datetime, { - parse: function(value) { + parse: function (value) { return new Date(value).getTime() }, // Input is a unix timestamp - format: function(value) { + format: function (value) { return new Date(value).toISOString() }, }) -exports.patch = async function(ctx) { +exports.patch = async function (ctx) { const instanceId = ctx.user.instanceId const db = new CouchDB(instanceId) let row = await db.get(ctx.params.id) @@ -67,7 +67,7 @@ exports.patch = async function(ctx) { ctx.message = `${table.name} updated successfully.` } -exports.save = async function(ctx) { +exports.save = async function (ctx) { const instanceId = ctx.user.instanceId const db = new CouchDB(instanceId) let row = ctx.request.body @@ -107,7 +107,7 @@ exports.save = async function(ctx) { // make sure link rows are up to date row = await linkRows.updateLinks({ instanceId, - eventType: linkRows.EventType.RECORD_SAVE, + eventType: linkRows.EventType.ROW_SAVE, row, tableId: row.tableId, table, @@ -134,7 +134,7 @@ exports.save = async function(ctx) { ctx.message = `${table.name} created successfully` } -exports.fetchView = async function(ctx) { +exports.fetchView = async function (ctx) { const instanceId = ctx.user.instanceId const db = new CouchDB(instanceId) const { stats, group, field } = ctx.query @@ -166,7 +166,7 @@ exports.fetchView = async function(ctx) { ctx.body = await linkRows.attachLinkInfo(instanceId, response.rows) } -exports.fetchTableRows = async function(ctx) { +exports.fetchTableRows = async function (ctx) { const instanceId = ctx.user.instanceId const db = new CouchDB(instanceId) const response = await db.allDocs( @@ -181,7 +181,7 @@ exports.fetchTableRows = async function(ctx) { ) } -exports.search = async function(ctx) { +exports.search = async function (ctx) { const instanceId = ctx.user.instanceId const db = new CouchDB(instanceId) const response = await db.allDocs({ @@ -194,7 +194,7 @@ exports.search = async function(ctx) { ) } -exports.find = async function(ctx) { +exports.find = async function (ctx) { const instanceId = ctx.user.instanceId const db = new CouchDB(instanceId) const row = await db.get(ctx.params.rowId) @@ -205,7 +205,7 @@ exports.find = async function(ctx) { ctx.body = await linkRows.attachLinkInfo(instanceId, row) } -exports.destroy = async function(ctx) { +exports.destroy = async function (ctx) { const instanceId = ctx.user.instanceId const db = new CouchDB(instanceId) const row = await db.get(ctx.params.rowId) @@ -227,7 +227,7 @@ exports.destroy = async function(ctx) { ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:delete`, instanceId, row) } -exports.validate = async function(ctx) { +exports.validate = async function (ctx) { const errors = await validate({ instanceId: ctx.user.instanceId, tableId: ctx.params.tableId, @@ -253,7 +253,7 @@ async function validate({ instanceId, tableId, row, table }) { return { valid: Object.keys(errors).length === 0, errors } } -exports.fetchEnrichedRow = async function(ctx) { +exports.fetchEnrichedRow = async function (ctx) { const instanceId = ctx.user.instanceId const db = new CouchDB(instanceId) const tableId = ctx.params.tableId From 802b05815d3e6edfa185962c4e69d90316d1bae7 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 14 Oct 2020 15:13:22 +0100 Subject: [PATCH 11/12] lint --- packages/server/src/api/controllers/row.js | 22 +++++++++---------- .../src/DataGrid/AttachmentCell/Button.svelte | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/server/src/api/controllers/row.js b/packages/server/src/api/controllers/row.js index 8466cfcc33..4042336741 100644 --- a/packages/server/src/api/controllers/row.js +++ b/packages/server/src/api/controllers/row.js @@ -12,16 +12,16 @@ const { cloneDeep } = require("lodash") const TABLE_VIEW_BEGINS_WITH = `all${SEPARATOR}${DocumentTypes.TABLE}${SEPARATOR}` validateJs.extend(validateJs.validators.datetime, { - parse: function (value) { + parse: function(value) { return new Date(value).getTime() }, // Input is a unix timestamp - format: function (value) { + format: function(value) { return new Date(value).toISOString() }, }) -exports.patch = async function (ctx) { +exports.patch = async function(ctx) { const instanceId = ctx.user.instanceId const db = new CouchDB(instanceId) let row = await db.get(ctx.params.id) @@ -67,7 +67,7 @@ exports.patch = async function (ctx) { ctx.message = `${table.name} updated successfully.` } -exports.save = async function (ctx) { +exports.save = async function(ctx) { const instanceId = ctx.user.instanceId const db = new CouchDB(instanceId) let row = ctx.request.body @@ -134,7 +134,7 @@ exports.save = async function (ctx) { ctx.message = `${table.name} created successfully` } -exports.fetchView = async function (ctx) { +exports.fetchView = async function(ctx) { const instanceId = ctx.user.instanceId const db = new CouchDB(instanceId) const { stats, group, field } = ctx.query @@ -166,7 +166,7 @@ exports.fetchView = async function (ctx) { ctx.body = await linkRows.attachLinkInfo(instanceId, response.rows) } -exports.fetchTableRows = async function (ctx) { +exports.fetchTableRows = async function(ctx) { const instanceId = ctx.user.instanceId const db = new CouchDB(instanceId) const response = await db.allDocs( @@ -181,7 +181,7 @@ exports.fetchTableRows = async function (ctx) { ) } -exports.search = async function (ctx) { +exports.search = async function(ctx) { const instanceId = ctx.user.instanceId const db = new CouchDB(instanceId) const response = await db.allDocs({ @@ -194,7 +194,7 @@ exports.search = async function (ctx) { ) } -exports.find = async function (ctx) { +exports.find = async function(ctx) { const instanceId = ctx.user.instanceId const db = new CouchDB(instanceId) const row = await db.get(ctx.params.rowId) @@ -205,7 +205,7 @@ exports.find = async function (ctx) { ctx.body = await linkRows.attachLinkInfo(instanceId, row) } -exports.destroy = async function (ctx) { +exports.destroy = async function(ctx) { const instanceId = ctx.user.instanceId const db = new CouchDB(instanceId) const row = await db.get(ctx.params.rowId) @@ -227,7 +227,7 @@ exports.destroy = async function (ctx) { ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:delete`, instanceId, row) } -exports.validate = async function (ctx) { +exports.validate = async function(ctx) { const errors = await validate({ instanceId: ctx.user.instanceId, tableId: ctx.params.tableId, @@ -253,7 +253,7 @@ async function validate({ instanceId, tableId, row, table }) { return { valid: Object.keys(errors).length === 0, errors } } -exports.fetchEnrichedRow = async function (ctx) { +exports.fetchEnrichedRow = async function(ctx) { const instanceId = ctx.user.instanceId const db = new CouchDB(instanceId) const tableId = ctx.params.tableId diff --git a/packages/standard-components/src/DataGrid/AttachmentCell/Button.svelte b/packages/standard-components/src/DataGrid/AttachmentCell/Button.svelte index 3d8e6364b7..f2fc24fd92 100644 --- a/packages/standard-components/src/DataGrid/AttachmentCell/Button.svelte +++ b/packages/standard-components/src/DataGrid/AttachmentCell/Button.svelte @@ -27,4 +27,4 @@ on:newRow={() => dispatch('newRow')} /> --> - + From 8132c77f8c6da60cc1491ed53f03db7bf88d5b76 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 14 Oct 2020 16:47:53 +0100 Subject: [PATCH 12/12] don't show login component on logged in page, fix auth for app assets --- .../ComponentPropertiesPanel.svelte | 12 ---- .../ComponentSelectionList.svelte | 22 +----- .../userInterface/ItemTab/Tab.svelte | 10 ++- .../userInterface/temporaryPanelStructure.js | 67 ++++++++++--------- .../server/src/middleware/authenticated.js | 6 +- packages/server/src/middleware/authorized.js | 3 + .../src/DataGrid/AttachmentCell/Button.svelte | 2 +- 7 files changed, 51 insertions(+), 71 deletions(-) diff --git a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte index 800905202d..1331ce0bdb 100644 --- a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte +++ b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte @@ -1,21 +1,10 @@ {#if !list.isCategory} - + {/if} {#each list.children as item} - handleClick(item)} /> + {#if !item.showOnPages || item.showOnPages.includes($store.currentPageName)} + handleClick(item)} /> + {/if} {/each} --> +