From 383c2a6c0a82a6ffbe2dcc306ed8796fdf202f14 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 9 Feb 2021 13:18:59 +0000 Subject: [PATCH 1/8] Quick fix to make sure all relationships link to a valid, existing doc. --- packages/server/src/db/linkedRows/LinkController.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/server/src/db/linkedRows/LinkController.js b/packages/server/src/db/linkedRows/LinkController.js index 061a9ac1ae..dd55ed898f 100644 --- a/packages/server/src/db/linkedRows/LinkController.js +++ b/packages/server/src/db/linkedRows/LinkController.js @@ -138,6 +138,13 @@ class LinkController { // iterate through the link IDs in the row field, see if any don't exist already for (let linkId of rowField) { if (linkId && linkId !== "" && linkDocIds.indexOf(linkId) === -1) { + // first check the doc we're linking to exists + try { + await this._db.get(linkId) + } catch (err) { + // skip links that don't exist + continue + } operations.push( new LinkDocument( table._id, From a1de336db93c33919172e0a5465375d6e55b6983 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 9 Feb 2021 13:20:53 +0000 Subject: [PATCH 2/8] Make sure both directions exist. --- packages/server/src/db/linkedRows/LinkController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/db/linkedRows/LinkController.js b/packages/server/src/db/linkedRows/LinkController.js index dd55ed898f..5102e50f02 100644 --- a/packages/server/src/db/linkedRows/LinkController.js +++ b/packages/server/src/db/linkedRows/LinkController.js @@ -140,7 +140,7 @@ class LinkController { if (linkId && linkId !== "" && linkDocIds.indexOf(linkId) === -1) { // first check the doc we're linking to exists try { - await this._db.get(linkId) + await Promise.all([this._db.get(linkId), this._db.get(row._id)]) } catch (err) { // skip links that don't exist continue From c7b110ff5c8de71b6a6f6b3c321ea1e2cfa5c3bf Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 9 Feb 2021 13:31:20 +0000 Subject: [PATCH 3/8] Fix keying in component design properties --- .../PropertiesPanel/PropertyControls/PropertyGroup.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/PropertyGroup.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/PropertyGroup.svelte index b04954c06f..93be958d55 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/PropertyGroup.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/PropertyGroup.svelte @@ -25,7 +25,7 @@ {#if open}
- {#each properties as prop (`${componentInstance._id}-${prop.key}`)} + {#each properties as prop (`${componentInstance._id}-${prop.key}-${prop.label}`)} Date: Tue, 9 Feb 2021 14:01:54 +0000 Subject: [PATCH 4/8] Add sprectrum theme compatibility to autoscreens form text --- .../store/screenTemplates/rowDetailScreen.js | 2 ++ .../store/screenTemplates/utils/Component.js | 5 +++++ .../store/screenTemplates/utils/commonComponents.js | 13 +++++++++++++ 3 files changed, 20 insertions(+) diff --git a/packages/builder/src/builderStore/store/screenTemplates/rowDetailScreen.js b/packages/builder/src/builderStore/store/screenTemplates/rowDetailScreen.js index 783bcf40aa..0ffb1de59f 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/rowDetailScreen.js +++ b/packages/builder/src/builderStore/store/screenTemplates/rowDetailScreen.js @@ -9,6 +9,7 @@ import { makeSaveButton, makeTableFormComponents, makeMainForm, + spectrumColor, } from "./utils/commonComponents" export default function(tables) { @@ -52,6 +53,7 @@ function generateTitleContainer(table, title, formId) { background: "transparent", color: "#4285f4", }) + .customStyle(spectrumColor(700)) .text("Delete") .customProps({ className: "", diff --git a/packages/builder/src/builderStore/store/screenTemplates/utils/Component.js b/packages/builder/src/builderStore/store/screenTemplates/utils/Component.js index 1e588895af..182736a1d5 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/utils/Component.js +++ b/packages/builder/src/builderStore/store/screenTemplates/utils/Component.js @@ -29,6 +29,11 @@ export class Component extends BaseStructure { return this } + customStyle(styling) { + this._json._styles.custom = styling + return this + } + instanceName(name) { this._json._instanceName = name return this diff --git a/packages/builder/src/builderStore/store/screenTemplates/utils/commonComponents.js b/packages/builder/src/builderStore/store/screenTemplates/utils/commonComponents.js index 8c6bfe646b..391d1b3c11 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/utils/commonComponents.js +++ b/packages/builder/src/builderStore/store/screenTemplates/utils/commonComponents.js @@ -3,6 +3,15 @@ import { Component } from "./Component" import { rowListUrl } from "../rowListScreen" import { backendUiStore } from "builderStore" +export function spectrumColor(number) { + // Acorn throws a parsing error in this file if the word g-l-o-b-a-l is found + // (without dashes - I can't even type it in a comment). + // God knows why. It seems to think optional chaining further down the + // file is invalid if the word g-l-o-b-a-l is found - hence the reason this + // statement is split into parts. + return "color: var(--spectrum-glo" + `bal-color-gray-${number});` +} + export function makeLinkComponent(tableName) { return new Component("@budibase/standard-components/link") .normalStyle({ @@ -12,6 +21,7 @@ export function makeLinkComponent(tableName) { .hoverStyle({ color: "#4285f4", }) + .customStyle(spectrumColor(700)) .text(tableName) .customProps({ url: `/${tableName.toLowerCase()}`, @@ -52,6 +62,7 @@ export function makeBreadcrumbContainer(tableName, text, capitalise = false) { "margin-right": "4px", "margin-left": "4px", }) + .customStyle(spectrumColor(700)) .text(">") .instanceName("Arrow") @@ -64,6 +75,7 @@ export function makeBreadcrumbContainer(tableName, text, capitalise = false) { const identifierText = new Component("@budibase/standard-components/text") .type("none") .normalStyle(textStyling) + .customStyle(spectrumColor(700)) .text(text) .instanceName("Identifier") @@ -132,6 +144,7 @@ export function makeTitleContainer(title) { "margin-left": "0px", flex: "1 1 auto", }) + .customStyle(spectrumColor(900)) .type("h3") .instanceName("Title") .text(title) From 009f6312731825005ef90fbb6f1fbe4c6d9aa9bd Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 9 Feb 2021 14:07:33 +0000 Subject: [PATCH 5/8] Remove placeholder setting from relationship field as it is never displayed --- packages/standard-components/manifest.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/standard-components/manifest.json b/packages/standard-components/manifest.json index 5694e3c5b3..cbebe1986c 100644 --- a/packages/standard-components/manifest.json +++ b/packages/standard-components/manifest.json @@ -1294,12 +1294,6 @@ "type": "text", "label": "Label", "key": "label" - }, - { - "type": "text", - "label": "Placeholder", - "key": "placeholder", - "placeholder": "Choose an option" } ] } From 33b800549358cd7497d260ac766f6789b56a2cf4 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 9 Feb 2021 14:37:42 +0000 Subject: [PATCH 6/8] Fix multiselect not being wrapped in CreateEditRow modal --- .../src/components/backend/DataTable/RowFieldControl.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte b/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte index bddb66e4c9..3390b95288 100644 --- a/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte +++ b/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte @@ -36,7 +36,9 @@ {:else if type === 'boolean'} {:else if type === 'link'} - +
+ +
{:else if type === 'longform'}
From 9b21eb78b6c10e858fc8601977b15e09da08d50e Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 9 Feb 2021 14:50:02 +0000 Subject: [PATCH 7/8] Fix relationships not being saved for new rows --- packages/server/src/db/linkedRows/LinkController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/db/linkedRows/LinkController.js b/packages/server/src/db/linkedRows/LinkController.js index 5102e50f02..dd55ed898f 100644 --- a/packages/server/src/db/linkedRows/LinkController.js +++ b/packages/server/src/db/linkedRows/LinkController.js @@ -140,7 +140,7 @@ class LinkController { if (linkId && linkId !== "" && linkDocIds.indexOf(linkId) === -1) { // first check the doc we're linking to exists try { - await Promise.all([this._db.get(linkId), this._db.get(row._id)]) + await this._db.get(linkId) } catch (err) { // skip links that don't exist continue From 4c53e4bcec550fe187ffdcb621a7cf82ae9a3653 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 9 Feb 2021 15:24:56 +0000 Subject: [PATCH 8/8] Fix server query tests --- .../server/src/api/routes/tests/query.spec.js | 87 ++++++++++--------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/packages/server/src/api/routes/tests/query.spec.js b/packages/server/src/api/routes/tests/query.spec.js index 3262845ca3..e97887846e 100644 --- a/packages/server/src/api/routes/tests/query.spec.js +++ b/packages/server/src/api/routes/tests/query.spec.js @@ -1,10 +1,10 @@ -const { +const { supertest, createApplication, defaultHeaders, builderEndpointShouldBlockNormalUsers, getDocument, - insertDocument + insertDocument, } = require("./couchTestUtils") let { generateDatasourceID, generateQueryID } = require("../../../db/utils") @@ -21,11 +21,11 @@ const TEST_DATASOURCE = { const TEST_QUERY = { _id: generateQueryID(DATASOURCE_ID), datasourceId: DATASOURCE_ID, - name:"New Query", - parameters:[], - fields:{}, - schema:{}, - queryVerb:"read", + name: "New Query", + parameters: [], + fields: {}, + schema: {}, + queryVerb: "read", } describe("/queries", () => { @@ -37,8 +37,8 @@ describe("/queries", () => { let query beforeAll(async () => { - ({ request, server } = await supertest()) - }); + ;({ request, server } = await supertest()) + }) afterAll(() => { server.close() @@ -47,7 +47,7 @@ describe("/queries", () => { beforeEach(async () => { app = await createApplication(request) appId = app.instance._id - }); + }) async function createDatasource() { return await insertDocument(appId, TEST_DATASOURCE) @@ -63,65 +63,68 @@ describe("/queries", () => { .post(`/api/queries`) .send(TEST_QUERY) .set(defaultHeaders(appId)) - .expect('Content-Type', /json/) + .expect("Content-Type", /json/) .expect(200) - expect(res.res.statusMessage).toEqual(`Query ${TEST_QUERY.name} saved successfully.`); - expect(res.body).toEqual({ - _rev: res.body._rev, - ...TEST_QUERY, - }); + expect(res.res.statusMessage).toEqual( + `Query ${TEST_QUERY.name} saved successfully.` + ) + expect(res.body).toEqual({ + _rev: res.body._rev, + ...TEST_QUERY, }) - }); + }) + }) describe("fetch", () => { let datasource beforeEach(async () => { datasource = await createDatasource() - }); + }) afterEach(() => { delete datasource._rev - }); + }) it("returns all the queries from the server", async () => { const query = await createQuery() const res = await request .get(`/api/queries`) .set(defaultHeaders(appId)) - .expect('Content-Type', /json/) + .expect("Content-Type", /json/) .expect(200) - const queries = res.body; - expect(queries).toEqual([ - { - "_rev": query.rev, - ...TEST_QUERY - } - ]); + const queries = res.body + expect(queries).toEqual([ + { + _rev: query.rev, + ...TEST_QUERY, + readable: true, + }, + ]) }) it("should apply authorization to endpoint", async () => { - await builderEndpointShouldBlockNormalUsers({ - request, - method: "GET", - url: `/api/datasources`, - appId: appId, - }) + await builderEndpointShouldBlockNormalUsers({ + request, + method: "GET", + url: `/api/datasources`, + appId: appId, }) - }); + }) + }) describe("destroy", () => { - let datasource; + let datasource beforeEach(async () => { datasource = await createDatasource() - }); + }) afterEach(() => { delete datasource._rev - }); + }) it("deletes a query and returns a success message", async () => { const query = await createQuery() @@ -134,10 +137,10 @@ describe("/queries", () => { const res = await request .get(`/api/queries`) .set(defaultHeaders(appId)) - .expect('Content-Type', /json/) + .expect("Content-Type", /json/) .expect(200) - - expect(res.body).toEqual([]) + + expect(res.body).toEqual([]) }) it("should apply authorization to endpoint", async () => { @@ -148,5 +151,5 @@ describe("/queries", () => { appId: appId, }) }) - }); -}); + }) +})