From 8e3d823401c68e71cb5438392c44e5633f6b8f4d Mon Sep 17 00:00:00 2001 From: Joe <49767913+joebudi@users.noreply.github.com> Date: Wed, 3 Jun 2020 15:13:39 +0100 Subject: [PATCH 01/21] login component UI update Input styles updates Labels removed Button redesigned Title/name added to ui and settings *Logo and preview broke for login component and page - Another issue --- .../userInterface/temporaryPanelStructure.js | 16 ++- packages/standard-components/components.json | 1 + packages/standard-components/src/Login.svelte | 121 +++++++++++------- 3 files changed, 91 insertions(+), 47 deletions(-) diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 55036b2da5..f95937a927 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -267,7 +267,21 @@ export default { "A component that automatically generates a login screen for your app.", icon: "ri-login-box-fill", children: [], - properties: { design: { ...all } }, + properties: { + design: { ...all }, + settings: [ + { + label: "Name", + key: "name", + control: Input, + }, + { + label: "Logo", + key: "logo", + control: Input, + }, + ], + }, }, { name: "Table", diff --git a/packages/standard-components/components.json b/packages/standard-components/components.json index f9c800489e..c069a2fe01 100644 --- a/packages/standard-components/components.json +++ b/packages/standard-components/components.json @@ -59,6 +59,7 @@ "props": { "logo": "asset", "loginRedirect": "string", + "name": "string", "usernameLabel": { "type": "string", "default": "Username" diff --git a/packages/standard-components/src/Login.svelte b/packages/standard-components/src/Login.svelte index 65aa5302eb..bced8ae866 100644 --- a/packages/standard-components/src/Login.svelte +++ b/packages/standard-components/src/Login.svelte @@ -1,10 +1,9 @@
-

{model.name}

+

{modelDef.name}

{#each fields as field}
{/each} From 65ee282a2c2c13201c9ae7f5f48362c19e1dc00e Mon Sep 17 00:00:00 2001 From: Conor_Mack Date: Wed, 3 Jun 2020 16:19:04 +0100 Subject: [PATCH 05/21] Screen and page latest --- .../builder/src/builderStore/store/index.js | 10 ++++ .../ComponentPropertiesPanel.svelte | 52 +++++++++++++++---- .../userInterface/FrontendNavigatePane.svelte | 1 + .../userInterface/SettingsView.svelte | 4 +- .../userInterface/propertyCategories.js | 16 ++++-- .../userInterface/temporaryPanelStructure.js | 5 +- 6 files changed, 72 insertions(+), 16 deletions(-) diff --git a/packages/builder/src/builderStore/store/index.js b/packages/builder/src/builderStore/store/index.js index 9f91550bca..3572e4e344 100644 --- a/packages/builder/src/builderStore/store/index.js +++ b/packages/builder/src/builderStore/store/index.js @@ -69,6 +69,7 @@ export const getStore = () => { store.getPathToComponent = getPathToComponent(store) store.addTemplatedComponent = addTemplatedComponent(store) store.setMetadataProp = setMetadataProp(store) + store.editPageOrScreen = editPageOrScreen(store) return store } @@ -171,6 +172,15 @@ const createScreen = store => (screenName, route, layoutComponentName) => { }) } +const editPageOrScreen = store => (key, value) => { + store.update(state => { + state.currentPreviewItem[key] = value + _saveCurrentPreviewItem(state) + + return state + }) +} + const setCurrentScreen = store => screenName => { store.update(s => { const screen = getExactComponent(s.screens, screenName) diff --git a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte index 60279aa9a1..62a3c91c3e 100644 --- a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte +++ b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte @@ -1,5 +1,6 @@ diff --git a/packages/builder/src/components/userInterface/SettingsView.svelte b/packages/builder/src/components/userInterface/SettingsView.svelte index 36b2ab9c75..76619867e3 100644 --- a/packages/builder/src/components/userInterface/SettingsView.svelte +++ b/packages/builder/src/components/userInterface/SettingsView.svelte @@ -9,7 +9,9 @@ export let componentInstance = {} export let onChange = () => {} - const propExistsOnComponentDef = prop => prop in componentDefinition.props + let pageScreenProps = ["name", "favicon", "description", "route"] + + const propExistsOnComponentDef = prop => pageScreenProps.includes(prop) || prop in componentDefinition.props function handleChange(key, data) { data.target ? onChange(key, data.target.value) : onChange(key, data) diff --git a/packages/builder/src/components/userInterface/propertyCategories.js b/packages/builder/src/components/userInterface/propertyCategories.js index 59458edd49..18572ea6ba 100644 --- a/packages/builder/src/components/userInterface/propertyCategories.js +++ b/packages/builder/src/components/userInterface/propertyCategories.js @@ -2,10 +2,18 @@ import Input from "../common/Input.svelte" import OptionSelect from "./OptionSelect.svelte" import InputGroup from "../common/Inputs/InputGroup.svelte" import FlatButtonGroup from "./FlatButtonGroup.svelte" -// import Colorpicker from "../common/Colorpicker.svelte" -/* - TODO: Allow for default values for all properties -*/ + + +export const screen = [ + { label: "Name", key: "name", control: Input }, + { label: "Description", key: "description", control: Input }, + { label: "Route", key: "route", control: Input }, +] + +export const page = [ + { label: "Name", key: "name", control: Input }, + { label: "Favicon", key: "favicon", control: Input }, +] export const layout = [ { diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index be9d874dea..9c0dfc1bd8 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -334,7 +334,10 @@ export default { "A component for handling the navigation within your app.", icon: "ri-navigation-fill", children: [], - properties: { design: { ...all } }, + properties: { + design: { ...all }, + settings: [{ label: "Logo URL", key: "logoUrl", control: Input }, ], + }, }, ], }, From ca0d1b6b2bf918a1cf7af156fae7865b5f29d188 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 3 Jun 2020 16:44:01 +0100 Subject: [PATCH 06/21] updating page title prop --- .../userInterface/ComponentPropertiesPanel.svelte | 13 +++++-------- .../components/userInterface/SettingsView.svelte | 5 +++-- .../components/userInterface/propertyCategories.js | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte index 62a3c91c3e..8ce0a57939 100644 --- a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte +++ b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte @@ -71,18 +71,15 @@ } } - $: console.log("COMP INSTA NEW", componentInstanceNew) - const onStyleChanged = store.setComponentStyle function onPropChanged(key, value) { - if($store.currentFrontEndType === "page") { + if($store.currentFrontEndType === "page" || ($store.currentFrontEndType === "screen" && $store.currentView !== "component")) { store.editPageOrScreen(key, value) - }else if($store.currentFrontEndType === "screen" && $store.currentView !== "component") { - store.editPageOrScreen(key, value) - }else { - store.setComponentProp(key, value) - } + return; + } + + store.setComponentProp(key, value) } function walkProps(component, action) { diff --git a/packages/builder/src/components/userInterface/SettingsView.svelte b/packages/builder/src/components/userInterface/SettingsView.svelte index 76619867e3..cb6f73aae0 100644 --- a/packages/builder/src/components/userInterface/SettingsView.svelte +++ b/packages/builder/src/components/userInterface/SettingsView.svelte @@ -9,12 +9,13 @@ export let componentInstance = {} export let onChange = () => {} - let pageScreenProps = ["name", "favicon", "description", "route"] + let pageScreenProps = ["title", "favicon", "description", "route"] const propExistsOnComponentDef = prop => pageScreenProps.includes(prop) || prop in componentDefinition.props function handleChange(key, data) { - data.target ? onChange(key, data.target.value) : onChange(key, data) + const value = data.target ? data.target.value : data + onChange(key, value) } diff --git a/packages/builder/src/components/userInterface/propertyCategories.js b/packages/builder/src/components/userInterface/propertyCategories.js index 18572ea6ba..b1e329c863 100644 --- a/packages/builder/src/components/userInterface/propertyCategories.js +++ b/packages/builder/src/components/userInterface/propertyCategories.js @@ -11,7 +11,7 @@ export const screen = [ ] export const page = [ - { label: "Name", key: "name", control: Input }, + { label: "Title", key: "title", control: Input }, { label: "Favicon", key: "favicon", control: Input }, ] From 47162d806bf175b7c929453d85b4878f930dd5bd Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Wed, 3 Jun 2020 17:05:36 +0100 Subject: [PATCH 07/21] logic to not use builder:token for apps running in dev --- packages/builder/src/builderStore/api.js | 11 ++++---- .../components/start/CreateAppModal.svelte | 11 ++------ .../src/pages/[application]/_reset.svelte | 3 ++- packages/builder/src/pages/index.svelte | 4 +-- .../server/src/middleware/authenticated.js | 25 +++++++++++++------ 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/packages/builder/src/builderStore/api.js b/packages/builder/src/builderStore/api.js index 04dcce6cb9..c132b01fc0 100644 --- a/packages/builder/src/builderStore/api.js +++ b/packages/builder/src/builderStore/api.js @@ -3,6 +3,7 @@ const apiCall = method => async (url, body) => { method: method, headers: { "Content-Type": "application/json", + "User-Agent": "Budibase Builder", }, body: body && JSON.stringify(body), }) @@ -14,11 +15,11 @@ const apiCall = method => async (url, body) => { return response } -const post = apiCall("POST") -const get = apiCall("GET") -const patch = apiCall("PATCH") -const del = apiCall("DELETE") -const put = apiCall("PUT") +export const post = apiCall("POST") +export const get = apiCall("GET") +export const patch = apiCall("PATCH") +export const del = apiCall("DELETE") +export const put = apiCall("PUT") export default { post, diff --git a/packages/builder/src/components/start/CreateAppModal.svelte b/packages/builder/src/components/start/CreateAppModal.svelte index d2232f7604..f012860194 100644 --- a/packages/builder/src/components/start/CreateAppModal.svelte +++ b/packages/builder/src/components/start/CreateAppModal.svelte @@ -5,6 +5,7 @@ import { AppsIcon, InfoIcon, CloseIcon } from "components/common/Icons/" import { getContext } from "svelte" import { fade } from "svelte/transition" + import { post } from "builderStore/api" const { open, close } = getContext("simple-modal") @@ -33,15 +34,7 @@ const data = { name, description } loading = true try { - const response = await fetch("/api/applications", { - method: "POST", // *GET, POST, PUT, DELETE, etc. - credentials: "same-origin", // include, *same-origin, omit - headers: { - "Content-Type": "application/json", - // 'Content-Type': 'application/x-www-form-urlencoded', - }, - body: JSON.stringify(data), // body data type must match "Content-Type" header - }) + const response = await post("/api/applications", data) const res = await response.json() diff --git a/packages/builder/src/pages/[application]/_reset.svelte b/packages/builder/src/pages/[application]/_reset.svelte index d973ba7517..2eec749c8f 100644 --- a/packages/builder/src/pages/[application]/_reset.svelte +++ b/packages/builder/src/pages/[application]/_reset.svelte @@ -1,6 +1,7 @@ -{#if panelDefinition.length > 0} +{#if panelDefinition && panelDefinition.length > 0} {#each panelDefinition as definition} {#if propExistsOnComponentDef(definition.key)} { if (!username) ctx.throw(400, "Username Required.") if (!password) ctx.throw(400, "Password Required") - // TODO: Don't use this. It can't be relied on - const referer = ctx.request.headers.referer.split("/") - const appId = referer[3] - // find the instance that the user is associated with const db = new CouchDB(ClientDb.name(env.CLIENT_ID)) - const app = await db.get(appId) + const app = await db.get(ctx.params.appId) const instanceId = app.userInstanceMap[username] if (!instanceId) diff --git a/packages/server/src/api/routes/auth.js b/packages/server/src/api/routes/auth.js index b4b68e8929..fa95a3a5e6 100644 --- a/packages/server/src/api/routes/auth.js +++ b/packages/server/src/api/routes/auth.js @@ -3,6 +3,6 @@ const controller = require("../controllers/auth") const router = Router() -router.post("/api/authenticate", controller.authenticate) +router.post("/:appId/api/authenticate", controller.authenticate) module.exports = router From 71f9b4f8322cccef6fadc107585afd0490ba9cb6 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 3 Jun 2020 20:38:46 +0100 Subject: [PATCH 14/21] charttype prop for datachart --- .../userInterface/temporaryPanelStructure.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 305441654e..747a71f10a 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -323,7 +323,20 @@ export default { label: "Chart Type", key: "type", control: OptionSelect, - options: ["column2d", "password"], + options: [ + "column2d", + "column3d", + "line", + "area2d", + "bar2d", + "bar3d", + "pie2d", + "pie3d", + "doughnut2d", + "doughnut3d", + "pareto2d", + "pareto3d" + ] }, ], }, From e74c68595694b5e0c49e773be55fcb3b5dd36e35 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 3 Jun 2020 20:44:35 +0100 Subject: [PATCH 15/21] lint --- packages/builder/src/builderStore/loadComponentLibraries.js | 2 +- .../src/components/userInterface/temporaryPanelStructure.js | 6 +++--- packages/client/src/state/bbComponentApi.js | 2 +- packages/server/src/api/controllers/auth.js | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/builder/src/builderStore/loadComponentLibraries.js b/packages/builder/src/builderStore/loadComponentLibraries.js index f7ceec303f..9d534f86fe 100644 --- a/packages/builder/src/builderStore/loadComponentLibraries.js +++ b/packages/builder/src/builderStore/loadComponentLibraries.js @@ -1,4 +1,4 @@ -import { get } from "builderStore/api"; +import { get } from "builderStore/api" /** * Fetches the definitions for component library components. This includes diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 747a71f10a..b1b4eaaa93 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -324,7 +324,7 @@ export default { key: "type", control: OptionSelect, options: [ - "column2d", + "column2d", "column3d", "line", "area2d", @@ -335,8 +335,8 @@ export default { "doughnut2d", "doughnut3d", "pareto2d", - "pareto3d" - ] + "pareto3d", + ], }, ], }, diff --git a/packages/client/src/state/bbComponentApi.js b/packages/client/src/state/bbComponentApi.js index e7a0412012..be918d3048 100644 --- a/packages/client/src/state/bbComponentApi.js +++ b/packages/client/src/state/bbComponentApi.js @@ -27,7 +27,7 @@ export const bbFactory = ({ method: method, headers: { "Content-Type": "application/json", - "x-user-agent": "Budibase Builder" + "x-user-agent": "Budibase Builder", }, body: body && JSON.stringify(body), }) diff --git a/packages/server/src/api/controllers/auth.js b/packages/server/src/api/controllers/auth.js index 80547200e5..de88c29643 100644 --- a/packages/server/src/api/controllers/auth.js +++ b/packages/server/src/api/controllers/auth.js @@ -12,7 +12,8 @@ exports.authenticate = async ctx => { // find the instance that the user is associated with const db = new CouchDB(ClientDb.name(env.CLIENT_ID)) - const app = await db.get(ctx.params.appId) + const appId = ctx.params.appId + const app = await db.get(appId) const instanceId = app.userInstanceMap[username] if (!instanceId) From 9581bec421e352904fbf333787fc742935fd11e4 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 3 Jun 2020 20:54:17 +0100 Subject: [PATCH 16/21] fixing tests --- packages/server/src/api/routes/tests/couchTestUtils.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/server/src/api/routes/tests/couchTestUtils.js b/packages/server/src/api/routes/tests/couchTestUtils.js index d382a2108e..f70fc0ced1 100644 --- a/packages/server/src/api/routes/tests/couchTestUtils.js +++ b/packages/server/src/api/routes/tests/couchTestUtils.js @@ -176,8 +176,7 @@ const createUserWithPermissions = async ( const designDoc = await db.get("_design/database") const loginResult = await request - .post(`/api/authenticate`) - .set("Referer", `http://localhost:4001/${designDoc.metadata.applicationId}`) + .post(`/${designDoc.metadata.applicationId}/api/authenticate`) .send({ username, password }) // returning necessary request headers From 98050f4c2a68201e24d4c636f5e224a7e4e4545a Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 3 Jun 2020 21:10:48 +0100 Subject: [PATCH 17/21] Revert "Settings for Pages and Screens" --- .../builder/src/builderStore/store/index.js | 10 ---- .../ComponentPropertiesPanel.svelte | 51 +++++-------------- .../userInterface/FrontendNavigatePane.svelte | 1 - .../userInterface/SettingsView.svelte | 7 +-- .../userInterface/propertyCategories.js | 15 ++---- 5 files changed, 19 insertions(+), 65 deletions(-) diff --git a/packages/builder/src/builderStore/store/index.js b/packages/builder/src/builderStore/store/index.js index 3572e4e344..9f91550bca 100644 --- a/packages/builder/src/builderStore/store/index.js +++ b/packages/builder/src/builderStore/store/index.js @@ -69,7 +69,6 @@ export const getStore = () => { store.getPathToComponent = getPathToComponent(store) store.addTemplatedComponent = addTemplatedComponent(store) store.setMetadataProp = setMetadataProp(store) - store.editPageOrScreen = editPageOrScreen(store) return store } @@ -172,15 +171,6 @@ const createScreen = store => (screenName, route, layoutComponentName) => { }) } -const editPageOrScreen = store => (key, value) => { - store.update(state => { - state.currentPreviewItem[key] = value - _saveCurrentPreviewItem(state) - - return state - }) -} - const setCurrentScreen = store => screenName => { store.update(s => { const screen = getExactComponent(s.screens, screenName) diff --git a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte index 48d7bb0835..60279aa9a1 100644 --- a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte +++ b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte @@ -1,6 +1,5 @@ diff --git a/packages/builder/src/components/userInterface/SettingsView.svelte b/packages/builder/src/components/userInterface/SettingsView.svelte index 7e79883a2b..99e704d1d9 100644 --- a/packages/builder/src/components/userInterface/SettingsView.svelte +++ b/packages/builder/src/components/userInterface/SettingsView.svelte @@ -9,13 +9,10 @@ export let componentInstance = {} export let onChange = () => {} - let pageScreenProps = ["title", "favicon", "description", "route"] - - const propExistsOnComponentDef = prop => pageScreenProps.includes(prop) || prop in componentDefinition.props + const propExistsOnComponentDef = prop => prop in componentDefinition.props function handleChange(key, data) { - const value = data.target ? data.target.value : data - onChange(key, value) + data.target ? onChange(key, data.target.value) : onChange(key, data) } diff --git a/packages/builder/src/components/userInterface/propertyCategories.js b/packages/builder/src/components/userInterface/propertyCategories.js index f9d9e6b892..59458edd49 100644 --- a/packages/builder/src/components/userInterface/propertyCategories.js +++ b/packages/builder/src/components/userInterface/propertyCategories.js @@ -2,17 +2,10 @@ import Input from "../common/Input.svelte" import OptionSelect from "./OptionSelect.svelte" import InputGroup from "../common/Inputs/InputGroup.svelte" import FlatButtonGroup from "./FlatButtonGroup.svelte" - -export const screen = [ - { label: "Name", key: "name", control: Input }, - { label: "Description", key: "description", control: Input }, - { label: "Route", key: "route", control: Input }, -] - -export const page = [ - { label: "Title", key: "title", control: Input }, - { label: "Favicon", key: "favicon", control: Input }, -] +// import Colorpicker from "../common/Colorpicker.svelte" +/* + TODO: Allow for default values for all properties +*/ export const layout = [ { From fb2e873e2fde2263cad825f649d411b124a37ee7 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 3 Jun 2020 21:23:56 +0100 Subject: [PATCH 18/21] fix budibase apps dir --- packages/server/.env.template | 5 +---- packages/server/src/api/controllers/application.js | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/server/.env.template b/packages/server/.env.template index 3593f96ee8..170d391520 100644 --- a/packages/server/.env.template +++ b/packages/server/.env.template @@ -15,7 +15,4 @@ JWT_SECRET={{cookieKey1}} PORT=4001 # error level for koa-pino -LOG_LEVEL=error - -# Budibase app directory -BUDIBASE_DIR=~/.budibase \ No newline at end of file +LOG_LEVEL=error \ No newline at end of file diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js index 8953d5af21..9bd015c86a 100644 --- a/packages/server/src/api/controllers/application.js +++ b/packages/server/src/api/controllers/application.js @@ -6,6 +6,7 @@ const env = require("../../environment") const instanceController = require("./instance") const { resolve, join } = require("path") const { copy, exists, readFile, writeFile } = require("fs-extra") +const { budibaseAppsDir } = require("../../utilities/budibaseDir") const { exec } = require("child_process") const sqrl = require("squirrelly") @@ -73,7 +74,7 @@ const createEmptyAppPackage = async (ctx, app) => { "appDirectoryTemplate" ) - const appsFolder = env.BUDIBASE_DIR + const appsFolder = budibaseAppsDir() const newAppFolder = resolve(appsFolder, app._id) if (await exists(newAppFolder)) { From 32d1ca641b95a171036f7201a9a9a84af615042a Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Wed, 3 Jun 2020 22:12:09 +0100 Subject: [PATCH 19/21] bugfix: data components hitting correct url again --- packages/client/src/state/bbComponentApi.js | 2 +- packages/server/src/utilities/builder/buildPage.js | 2 +- packages/standard-components/src/Login.svelte | 13 ++++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/client/src/state/bbComponentApi.js b/packages/client/src/state/bbComponentApi.js index be918d3048..7366a90f5c 100644 --- a/packages/client/src/state/bbComponentApi.js +++ b/packages/client/src/state/bbComponentApi.js @@ -23,7 +23,7 @@ export const bbFactory = ({ } const apiCall = method => (url, body) => - fetch(relativeUrl(url), { + fetch(url, { method: method, headers: { "Content-Type": "application/json", diff --git a/packages/server/src/utilities/builder/buildPage.js b/packages/server/src/utilities/builder/buildPage.js index f1b5d6d724..3d44cb8072 100644 --- a/packages/server/src/utilities/builder/buildPage.js +++ b/packages/server/src/utilities/builder/buildPage.js @@ -45,7 +45,7 @@ const copyClientLib = async (appPath, pageName) => { const buildIndexHtml = async (config, appId, pageName, appPath, pkg) => { const appPublicPath = publicPath(appPath, pageName) - const appRootPath = appId + const appRootPath = rootPath(config, appId) const stylesheetUrl = s => s.startsWith("http") ? s : `/${rootPath(config, appId)}/${s}` diff --git a/packages/standard-components/src/Login.svelte b/packages/standard-components/src/Login.svelte index 58a2860be8..34168d01f4 100644 --- a/packages/standard-components/src/Login.svelte +++ b/packages/standard-components/src/Login.svelte @@ -25,9 +25,16 @@ const login = async () => { loading = true - const response = await _bb.api.post("/api/authenticate", { - username, - password, + const response = await fetch(_bb.relativeUrl("/api/authenticate"), { + body: JSON.stringify({ + username, + password, + }), + headers: { + "Content-Type": "application/json", + "x-user-agent": "Budibase Builder", + }, + method: "POST", }) if (response.status === 200) { From 94a98684272caee5ec0b02e00ad1a9dd4deb9712 Mon Sep 17 00:00:00 2001 From: Joe <49767913+joebudi@users.noreply.github.com> Date: Wed, 3 Jun 2020 22:49:55 +0100 Subject: [PATCH 20/21] Form and button update --- .../ComponentPropertiesPanel.svelte | 49 +++++++---- .../userInterface/SettingsView.svelte | 5 +- .../standard-components/src/Button.svelte | 30 ++++--- .../standard-components/src/DataForm.svelte | 83 +++++++++++++++++-- 4 files changed, 125 insertions(+), 42 deletions(-) diff --git a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte index 48d7bb0835..d54fdb8916 100644 --- a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte +++ b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte @@ -1,6 +1,6 @@ - -

{modelDef.name}

-
+ +
{#each fields as field} -
+
+
{/each} +
+ +
- From 5fa8e3ca6337246ea23184330e3feffc9f80b8e4 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Wed, 3 Jun 2020 22:52:33 +0100 Subject: [PATCH 21/21] bugfix: screenRouter hijacks link clicks and routes when applicable --- packages/client/src/render/screenRouter.js | 22 ++++++++++++++++++++ packages/standard-components/src/Link.svelte | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/client/src/render/screenRouter.js b/packages/client/src/render/screenRouter.js index 262ed65f66..64319102f8 100644 --- a/packages/client/src/render/screenRouter.js +++ b/packages/client/src/render/screenRouter.js @@ -56,8 +56,30 @@ export const screenRouter = ({ screens, onScreenSelected, appRootPath }) => { } } + function click(e) { + const x = e.target.closest("a") + const y = x && x.getAttribute("href") + + if ( + e.ctrlKey || + e.metaKey || + e.altKey || + e.shiftKey || + e.button || + e.defaultPrevented + ) + return + + const target = x.target || "_self" + if (!y || target !== "_self" || x.host !== location.host) return + + e.preventDefault() + route(y) + } + addEventListener("popstate", route) addEventListener("pushstate", route) + addEventListener("click", click) return route } diff --git a/packages/standard-components/src/Link.svelte b/packages/standard-components/src/Link.svelte index d557df6abd..ef0b71d62e 100644 --- a/packages/standard-components/src/Link.svelte +++ b/packages/standard-components/src/Link.svelte @@ -13,7 +13,7 @@ $: target = openInNewTab ? "_blank" : "_self" -{text} +{text}