From 1b5ac7415096fa3653d0ac5a3c01e25fc11ccf29 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 26 Feb 2021 09:55:38 +0000 Subject: [PATCH 01/12] Fix crash when schema doesnt exist for a datasource --- packages/builder/src/builderStore/dataBinding.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/builderStore/dataBinding.js b/packages/builder/src/builderStore/dataBinding.js index 429ba1c683..dee0b86fb3 100644 --- a/packages/builder/src/builderStore/dataBinding.js +++ b/packages/builder/src/builderStore/dataBinding.js @@ -120,7 +120,7 @@ const getContextBindings = (asset, componentId) => { tableName = info.table?.name // Add _id and _rev fields for certain types - if (datasource.type === "table" || datasource.type === "link") { + if (schema && ["table", "link"].includes(datasource.type)) { schema["_id"] = { type: "string" } schema["_rev"] = { type: "string" } } From ac46cbdb14cb08efc7d4b367645975a66483c003 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 26 Feb 2021 09:57:06 +0000 Subject: [PATCH 02/12] Add button action for login --- .../EventsEditor/actions/LogIn.svelte | 36 +++++++++++++++++++ .../EventsEditor/actions/index.js | 5 +++ packages/client/src/utils/buttonActions.js | 8 ++++- 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/LogIn.svelte diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/LogIn.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/LogIn.svelte new file mode 100644 index 0000000000..c49369bf29 --- /dev/null +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/LogIn.svelte @@ -0,0 +1,36 @@ + + +
+ + (parameters.email = value.detail)} + {bindings} /> + + (parameters.password = value.detail)} + {bindings} /> +
+ + diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/index.js b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/index.js index e851bdb4be..95140f200a 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/index.js +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/index.js @@ -4,6 +4,7 @@ import DeleteRow from "./DeleteRow.svelte" import ExecuteQuery from "./ExecuteQuery.svelte" import TriggerAutomation from "./TriggerAutomation.svelte" import ValidateForm from "./ValidateForm.svelte" +import LogIn from "./LogIn.svelte" // defines what actions are available, when adding a new one // the component is the setup panel for the action @@ -35,4 +36,8 @@ export default [ name: "Validate Form", component: ValidateForm, }, + { + name: "Log In", + component: LogIn, + }, ] diff --git a/packages/client/src/utils/buttonActions.js b/packages/client/src/utils/buttonActions.js index cadb046514..e56960d376 100644 --- a/packages/client/src/utils/buttonActions.js +++ b/packages/client/src/utils/buttonActions.js @@ -1,5 +1,5 @@ import { get } from "svelte/store" -import { routeStore, builderStore } from "../store" +import { routeStore, builderStore, authStore } from "../store" import { saveRow, deleteRow, executeQuery, triggerAutomation } from "../api" import { ActionTypes } from "../constants" @@ -68,6 +68,11 @@ const refreshDatasourceHandler = async (action, context) => { ) } +const loginHandler = async action => { + const { email, password } = action.parameters + await authStore.actions.logIn({ email, password }) +} + const handlerMap = { ["Save Row"]: saveRowHandler, ["Delete Row"]: deleteRowHandler, @@ -76,6 +81,7 @@ const handlerMap = { ["Trigger Automation"]: triggerAutomationHandler, ["Validate Form"]: validateFormHandler, ["Refresh Datasource"]: refreshDatasourceHandler, + ["Log In"]: loginHandler, } /** From dd0fee3dc37a06d3a46023a9d41861c5465826ec Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 26 Feb 2021 09:57:36 +0000 Subject: [PATCH 03/12] Pull enriched user when logging in to client app so that relationships are available as bindings --- packages/client/src/store/auth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/store/auth.js b/packages/client/src/store/auth.js index 29ded50ac7..8158e343c4 100644 --- a/packages/client/src/store/auth.js +++ b/packages/client/src/store/auth.js @@ -21,7 +21,7 @@ const createAuthStore = () => { const logIn = async ({ email, password }) => { const user = await API.logIn({ email, password }) if (!user.error) { - store.set(user) + await fetchUser() await initialise() goToDefaultRoute() } From 624ad79c95c3aaf0c444440032bd04b49b58c449 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 26 Feb 2021 09:58:11 +0000 Subject: [PATCH 04/12] Add background image component --- .../design/AppPreview/componentStructure.json | 1 + packages/standard-components/manifest.json | 18 ++++++++++++ .../src/BackgroundImage.svelte | 28 +++++++++++++++++++ packages/standard-components/src/index.js | 1 + 4 files changed, 48 insertions(+) create mode 100644 packages/standard-components/src/BackgroundImage.svelte diff --git a/packages/builder/src/components/design/AppPreview/componentStructure.json b/packages/builder/src/components/design/AppPreview/componentStructure.json index 87bef3d3a1..bae4b009e9 100644 --- a/packages/builder/src/components/design/AppPreview/componentStructure.json +++ b/packages/builder/src/components/design/AppPreview/componentStructure.json @@ -49,6 +49,7 @@ "heading", "text", "image", + "backgroundimage", "link", "icon", "embed" diff --git a/packages/standard-components/manifest.json b/packages/standard-components/manifest.json index cb321f1bb9..73b6e72377 100644 --- a/packages/standard-components/manifest.json +++ b/packages/standard-components/manifest.json @@ -294,6 +294,19 @@ } ] }, + "backgroundimage": { + "name": "Background Image", + "description": "A background image", + "icon": "ri-image-line", + "styleable": true, + "settings": [ + { + "type": "text", + "label": "URL", + "key": "url" + } + ] + }, "icon": { "name": "Icon", "description": "A basic component for displaying icons", @@ -394,6 +407,11 @@ "type": "boolean", "label": "New Tab", "key": "openInNewTab" + }, + { + "type": "boolean", + "label": "External", + "key": "external" } ] }, diff --git a/packages/standard-components/src/BackgroundImage.svelte b/packages/standard-components/src/BackgroundImage.svelte new file mode 100644 index 0000000000..332ae11049 --- /dev/null +++ b/packages/standard-components/src/BackgroundImage.svelte @@ -0,0 +1,28 @@ + + +
+
+
+ + diff --git a/packages/standard-components/src/index.js b/packages/standard-components/src/index.js index 14886e2a17..a9d8920895 100644 --- a/packages/standard-components/src/index.js +++ b/packages/standard-components/src/index.js @@ -31,5 +31,6 @@ export { default as cardhorizontal } from "./CardHorizontal.svelte" export { default as cardstat } from "./CardStat.svelte" export { default as icon } from "./Icon.svelte" export { default as search } from "./Search.svelte" +export { default as backgroundimage } from "./BackgroundImage.svelte" export * from "./charts" export * from "./forms" From 0988f27f15b65450b4652a97a03e970086046aee Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 26 Feb 2021 09:58:24 +0000 Subject: [PATCH 05/12] Add external setting for links --- packages/standard-components/src/Link.svelte | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/standard-components/src/Link.svelte b/packages/standard-components/src/Link.svelte index 5ae1ae75c4..0ada211eb7 100644 --- a/packages/standard-components/src/Link.svelte +++ b/packages/standard-components/src/Link.svelte @@ -7,11 +7,19 @@ export let url = "" export let text = "" export let openInNewTab = false + export let external = false $: target = openInNewTab ? "_blank" : "_self" - - {text} - - +{#if external} + + {text} + + +{:else} + + {text} + + +{/if} From 5ea2ad9010377c1047946ae065bd1faa8bdbab86 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 26 Feb 2021 10:03:26 +0000 Subject: [PATCH 06/12] Fix permissions when fetching enriched rows --- packages/server/src/utilities/security/permissions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/utilities/security/permissions.js b/packages/server/src/utilities/security/permissions.js index 083de730b5..e6028ac2da 100644 --- a/packages/server/src/utilities/security/permissions.js +++ b/packages/server/src/utilities/security/permissions.js @@ -156,7 +156,7 @@ exports.doesHaveResourcePermission = ( break } } - return foundMain && foundSub + return foundMain || foundSub } exports.doesHaveBasePermission = (permType, permLevel, permissionIds) => { From a67a8fb957324274898c488cfc2dbed0dde77c78 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 26 Feb 2021 14:04:12 +0000 Subject: [PATCH 07/12] Add log out button action --- .../EventsEditor/actions/LogOut.svelte | 17 +++++++++++++++++ .../EventsEditor/actions/index.js | 5 +++++ packages/client/src/utils/buttonActions.js | 5 +++++ 3 files changed, 27 insertions(+) create mode 100644 packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/LogOut.svelte diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/LogOut.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/LogOut.svelte new file mode 100644 index 0000000000..0dd6d58ff1 --- /dev/null +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/LogOut.svelte @@ -0,0 +1,17 @@ + + +
This action doesn't require any additional settings.
+ + diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/index.js b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/index.js index 95140f200a..4700ea5c8f 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/index.js +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/index.js @@ -5,6 +5,7 @@ import ExecuteQuery from "./ExecuteQuery.svelte" import TriggerAutomation from "./TriggerAutomation.svelte" import ValidateForm from "./ValidateForm.svelte" import LogIn from "./LogIn.svelte" +import LogOut from "./LogOut.svelte" // defines what actions are available, when adding a new one // the component is the setup panel for the action @@ -40,4 +41,8 @@ export default [ name: "Log In", component: LogIn, }, + { + name: "Log Out", + component: LogOut, + }, ] diff --git a/packages/client/src/utils/buttonActions.js b/packages/client/src/utils/buttonActions.js index e56960d376..4d2865d586 100644 --- a/packages/client/src/utils/buttonActions.js +++ b/packages/client/src/utils/buttonActions.js @@ -73,6 +73,10 @@ const loginHandler = async action => { await authStore.actions.logIn({ email, password }) } +const logoutHandler = async () => { + await authStore.actions.logOut() +} + const handlerMap = { ["Save Row"]: saveRowHandler, ["Delete Row"]: deleteRowHandler, @@ -82,6 +86,7 @@ const handlerMap = { ["Validate Form"]: validateFormHandler, ["Refresh Datasource"]: refreshDatasourceHandler, ["Log In"]: loginHandler, + ["Log Out"]: logoutHandler, } /** From d27dff02616963e088c64e97aaff641f879ed984 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 26 Feb 2021 14:04:31 +0000 Subject: [PATCH 08/12] Make user data source refreshable in client apps --- packages/client/src/components/ClientApp.svelte | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/client/src/components/ClientApp.svelte b/packages/client/src/components/ClientApp.svelte index e204209526..e8ab668ef2 100644 --- a/packages/client/src/components/ClientApp.svelte +++ b/packages/client/src/components/ClientApp.svelte @@ -11,6 +11,7 @@ screenStore, authStore, } from "../store" + import { TableNames, ActionTypes } from "../constants" // Provide contexts setContext("sdk", SDK) @@ -25,10 +26,20 @@ await authStore.actions.fetchUser() loaded = true }) + + // Register this as a refreshable datasource so that user changes cause + // the user object to be refreshed + $: actions = [ + { + type: ActionTypes.RefreshDatasource, + callback: () => authStore.actions.fetchUser(), + metadata: { datasource: { type: "table", tableId: TableNames.USERS } }, + }, + ] {#if loaded && $screenStore.activeLayout} - + From e7f4b9c241f297f857b7cffe2ce4805cfd6da211 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 26 Feb 2021 14:04:44 +0000 Subject: [PATCH 09/12] Center background image component --- packages/standard-components/src/BackgroundImage.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/standard-components/src/BackgroundImage.svelte b/packages/standard-components/src/BackgroundImage.svelte index 332ae11049..9575efd74f 100644 --- a/packages/standard-components/src/BackgroundImage.svelte +++ b/packages/standard-components/src/BackgroundImage.svelte @@ -23,6 +23,6 @@ width: 100%; background-repeat: no-repeat; background-size: cover; - background-position: top center; + background-position: center center; } From a3e959daa82b3bce00f04ef6d913e42edb4f3cd8 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 1 Mar 2021 14:05:54 +0000 Subject: [PATCH 10/12] Add position option to background image --- packages/standard-components/manifest.json | 44 +++++++++++++++++++ .../src/BackgroundImage.svelte | 14 +++++- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/packages/standard-components/manifest.json b/packages/standard-components/manifest.json index 73b6e72377..3843fe9dd3 100644 --- a/packages/standard-components/manifest.json +++ b/packages/standard-components/manifest.json @@ -304,6 +304,50 @@ "type": "text", "label": "URL", "key": "url" + }, + { + "type": "select", + "label": "Position", + "key": "position", + "defaultValue": "center center", + "options": [ + { + "label": "Center Top", + "value": "center top" + }, + { + "label": "Center", + "value": "center center" + }, + { + "label": "Center Bottom", + "value": "center bottom" + }, + { + "label": "Left Top", + "value": "left top" + }, + { + "label": "Left Center", + "value": "left center" + }, + { + "label": "Left Bottom", + "value": "left bottom" + }, + { + "label": "Right Top", + "value": "right top" + }, + { + "label": "Right Center", + "value": "right center" + }, + { + "label": "Right Bottom", + "value": "right bottom" + } + ] } ] }, diff --git a/packages/standard-components/src/BackgroundImage.svelte b/packages/standard-components/src/BackgroundImage.svelte index 9575efd74f..c78cdc87b6 100644 --- a/packages/standard-components/src/BackgroundImage.svelte +++ b/packages/standard-components/src/BackgroundImage.svelte @@ -4,8 +4,18 @@ const { styleable } = getContext("sdk") const component = getContext("component") - export let url = "" - $: style = url ? `background-image: url("${url}")` : "" + export let url + export let position + + let style = "" + $: { + if (url) { + style += `background-image: url("${url}");` + } + if (position) { + style += `background-position: ${position};` + } + }
From 78865ddef4ec8934f5437f7f612a9aef80ec31c6 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 1 Mar 2021 14:13:11 +0000 Subject: [PATCH 11/12] Add password field component --- .../design/AppPreview/componentStructure.json | 1 + packages/standard-components/manifest.json | 28 +++++++++++++++++++ .../src/forms/PasswordField.svelte | 5 ++++ .../standard-components/src/forms/index.js | 1 + 4 files changed, 35 insertions(+) create mode 100644 packages/standard-components/src/forms/PasswordField.svelte diff --git a/packages/builder/src/components/design/AppPreview/componentStructure.json b/packages/builder/src/components/design/AppPreview/componentStructure.json index bae4b009e9..16109b5a96 100644 --- a/packages/builder/src/components/design/AppPreview/componentStructure.json +++ b/packages/builder/src/components/design/AppPreview/componentStructure.json @@ -12,6 +12,7 @@ "fieldgroup", "stringfield", "numberfield", + "passwordfield", "optionsfield", "booleanfield", "longformfield", diff --git a/packages/standard-components/manifest.json b/packages/standard-components/manifest.json index 3843fe9dd3..14b20dd9ad 100644 --- a/packages/standard-components/manifest.json +++ b/packages/standard-components/manifest.json @@ -1295,6 +1295,34 @@ } ] }, + "passwordfield": { + "name": "Password Field", + "icon": "ri-lock-password-line", + "styleable": true, + "settings": [ + { + "type": "field/string", + "label": "Field", + "key": "field" + }, + { + "type": "text", + "label": "Label", + "key": "label" + }, + { + "type": "text", + "label": "Placeholder", + "key": "placeholder" + }, + { + "type": "boolean", + "label": "Disabled", + "key": "disabled", + "defaultValue": false + } + ] + }, "optionsfield": { "name": "Options Picker", "icon": "ri-file-list-line", diff --git a/packages/standard-components/src/forms/PasswordField.svelte b/packages/standard-components/src/forms/PasswordField.svelte new file mode 100644 index 0000000000..71edd4f97f --- /dev/null +++ b/packages/standard-components/src/forms/PasswordField.svelte @@ -0,0 +1,5 @@ + + + diff --git a/packages/standard-components/src/forms/index.js b/packages/standard-components/src/forms/index.js index 3998424db3..fed371278b 100644 --- a/packages/standard-components/src/forms/index.js +++ b/packages/standard-components/src/forms/index.js @@ -8,3 +8,4 @@ export { default as longformfield } from "./LongFormField.svelte" export { default as datetimefield } from "./DateTimeField.svelte" export { default as attachmentfield } from "./AttachmentField.svelte" export { default as relationshipfield } from "./RelationshipField.svelte" +export { default as passwordfield } from "./PasswordField.svelte" From 5b00041fee59bc549d8ff4127062cca6de8836e7 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 1 Mar 2021 14:56:30 +0000 Subject: [PATCH 12/12] Remove obsolete code from log out button action component --- .../EventsEditor/actions/LogOut.svelte | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/LogOut.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/LogOut.svelte index 0dd6d58ff1..2b0aad8342 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/LogOut.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/LogOut.svelte @@ -1,13 +1,3 @@ - -
This action doesn't require any additional settings.