Merge pull request #1166 from Budibase/bug/minor-fix

Quick fix
This commit is contained in:
Michael Drury 2021-02-23 17:32:35 +00:00 committed by GitHub
commit 92035e982b
26 changed files with 87 additions and 54 deletions

View File

@ -1,5 +1,8 @@
{ {
"baseUrl": "http://localhost:4001/_builder/", "baseUrl": "http://localhost:4005/_builder/",
"video": true, "video": true,
"projectId": "bmbemn" "projectId": "bmbemn",
"env": {
"PORT": "4005"
}
} }

View File

@ -2,7 +2,7 @@ context('Create an Application', () => {
beforeEach(() => { beforeEach(() => {
cy.server() cy.server()
cy.visit('localhost:4001/_builder') cy.visit(`localhost:${Cypress.env("PORT")}/_builder`)
}) })
// https://on.cypress.io/interacting-with-elements // https://on.cypress.io/interacting-with-elements
@ -11,7 +11,7 @@ context('Create an Application', () => {
// https://on.cypress.io/type // https://on.cypress.io/type
cy.createApp('My Cool App', 'This is a description') cy.createApp('My Cool App', 'This is a description')
cy.visit('localhost:4001/_builder') cy.visit(`localhost:${Cypress.env("PORT")}/_builder`)
cy.contains('My Cool App').should('exist') cy.contains('My Cool App').should('exist')
}) })

View File

@ -1,7 +1,7 @@
context("Create a automation", () => { context("Create a automation", () => {
before(() => { before(() => {
cy.server() cy.server()
cy.visit("localhost:4001/_builder") cy.visit(`localhost:${Cypress.env("PORT")}/_builder`)
cy.createApp( cy.createApp(
"Automation Test App", "Automation Test App",

View File

@ -1,6 +1,6 @@
xcontext('Create a Binding', () => { xcontext('Create a Binding', () => {
before(() => { before(() => {
cy.visit('localhost:4001/_builder') cy.visit(`localhost:${Cypress.env("PORT")}/_builder`)
cy.createApp('Binding App', 'Binding App Description') cy.createApp('Binding App', 'Binding App Description')
cy.navigateToFrontend() cy.navigateToFrontend()
}) })

View File

@ -1,7 +1,7 @@
xcontext("Create Components", () => { xcontext("Create Components", () => {
before(() => { before(() => {
cy.server() cy.server()
cy.visit("localhost:4001/_builder") cy.visit(`localhost:${Cypress.env("PORT")}/_builder`)
// https://on.cypress.io/type // https://on.cypress.io/type
cy.createApp("Table App", "Table App Description") cy.createApp("Table App", "Table App Description")
cy.createTable("dog", "name", "age") cy.createTable("dog", "name", "age")

View File

@ -1,6 +1,6 @@
context("Create a Table", () => { context("Create a Table", () => {
before(() => { before(() => {
cy.visit("localhost:4001/_builder") cy.visit(`localhost:${Cypress.env("PORT")}/_builder`)
cy.createApp("Table App", "Table App Description") cy.createApp("Table App", "Table App Description")
}) })

View File

@ -2,7 +2,7 @@ context('Create a User', () => {
before(() => { before(() => {
cy.server() cy.server()
cy.visit('localhost:4001/_builder') cy.visit(`localhost:${Cypress.env("PORT")}/_builder`)
// https://on.cypress.io/type // https://on.cypress.io/type
cy.createApp('User App', 'This app is used to test user creation') cy.createApp('User App', 'This app is used to test user creation')
}) })

View File

@ -8,7 +8,7 @@ function removeSpacing(headers) {
context("Create a View", () => { context("Create a View", () => {
before(() => { before(() => {
cy.visit("localhost:4001/_builder") cy.visit(`localhost:${Cypress.env("PORT")}/_builder`)
cy.createApp("View App", "View App Description") cy.createApp("View App", "View App Description")
cy.createTable("data") cy.createTable("data")
cy.addColumn("data", "group", "Text") cy.addColumn("data", "group", "Text")

View File

@ -2,7 +2,7 @@
context('Screen Tests', () => { context('Screen Tests', () => {
before(() => { before(() => {
cy.server() cy.server()
cy.visit('localhost:4001/_builder') cy.visit(`localhost:${Cypress.env("PORT")}/_builder`)
cy.createApp('Conor Cy App', 'Table App Description') cy.createApp('Conor Cy App', 'Table App Description')
cy.navigateToFrontend() cy.navigateToFrontend()
}) })

View File

@ -6,6 +6,7 @@
const rimraf = require("rimraf") const rimraf = require("rimraf")
const { join, resolve } = require("path") const { join, resolve } = require("path")
const initialiseBudibase = require("../../server/src/utilities/initialiseBudibase") const initialiseBudibase = require("../../server/src/utilities/initialiseBudibase")
const cypressConfig = require("../cypress.json")
const homedir = join(require("os").homedir(), ".budibase") const homedir = join(require("os").homedir(), ".budibase")
@ -14,6 +15,7 @@ rimraf.sync(homedir)
process.env.BUDIBASE_API_KEY = "6BE826CB-6B30-4AEC-8777-2E90464633DE" process.env.BUDIBASE_API_KEY = "6BE826CB-6B30-4AEC-8777-2E90464633DE"
process.env.NODE_ENV = "cypress" process.env.NODE_ENV = "cypress"
process.env.ENABLE_ANALYTICS = "false" process.env.ENABLE_ANALYTICS = "false"
process.env.PORT = cypressConfig.env.PORT
// Stop info logs polluting test outputs // Stop info logs polluting test outputs
process.env.LOG_LEVEL = "error" process.env.LOG_LEVEL = "error"

View File

@ -14,8 +14,8 @@
"cy:run": "cypress run", "cy:run": "cypress run",
"cy:open": "cypress open", "cy:open": "cypress open",
"cy:run:ci": "cypress run --browser electron --record --key f308590b-6070-41af-b970-794a3823d451", "cy:run:ci": "cypress run --browser electron --record --key f308590b-6070-41af-b970-794a3823d451",
"cy:test": "start-server-and-test cy:setup http://localhost:4001/_builder cy:run", "cy:test": "start-server-and-test cy:setup http://localhost:4005/_builder cy:run",
"cy:ci": "start-server-and-test cy:setup http://localhost:4001/_builder cy:run:ci" "cy:ci": "start-server-and-test cy:setup http://localhost:4005/_builder cy:run:ci"
}, },
"jest": { "jest": {
"globals": { "globals": {

View File

@ -125,7 +125,12 @@ export default {
requestFeedbackOnDeploy, requestFeedbackOnDeploy,
submitFeedback, submitFeedback,
highlightFeedbackIcon, highlightFeedbackIcon,
disabled: ifAnalyticsEnabled(disabled), disabled: () => {
if (analyticsEnabled == null) {
return true
}
return ifAnalyticsEnabled(disabled)
},
optIn: ifAnalyticsEnabled(optIn), optIn: ifAnalyticsEnabled(optIn),
optOut: ifAnalyticsEnabled(optOut), optOut: ifAnalyticsEnabled(optOut),
} }

View File

@ -290,7 +290,7 @@ export const getFrontendStore = () => {
...extras, ...extras,
} }
}, },
create: (componentName, presetProps) => { create: async (componentName, presetProps) => {
const selected = get(selectedComponent) const selected = get(selectedComponent)
const asset = get(currentAsset) const asset = get(currentAsset)
const state = get(store) const state = get(store)
@ -346,7 +346,7 @@ export const getFrontendStore = () => {
parentComponent._children.push(componentInstance) parentComponent._children.push(componentInstance)
// Save components and update UI // Save components and update UI
store.actions.preview.saveSelected() await store.actions.preview.saveSelected()
store.update(state => { store.update(state => {
state.currentView = "component" state.currentView = "component"
state.selectedComponentId = componentInstance._id state.selectedComponentId = componentInstance._id
@ -360,7 +360,7 @@ export const getFrontendStore = () => {
return componentInstance return componentInstance
}, },
delete: component => { delete: async component => {
if (!component) { if (!component) {
return return
} }
@ -375,7 +375,7 @@ export const getFrontendStore = () => {
) )
store.actions.components.select(parent) store.actions.components.select(parent)
} }
store.actions.preview.saveSelected() await store.actions.preview.saveSelected()
}, },
copy: (component, cut = false) => { copy: (component, cut = false) => {
const selectedAsset = get(currentAsset) const selectedAsset = get(currentAsset)
@ -487,7 +487,7 @@ export const getFrontendStore = () => {
selected._styles = { normal: {}, hover: {}, active: {} } selected._styles = { normal: {}, hover: {}, active: {} }
await store.actions.preview.saveSelected() await store.actions.preview.saveSelected()
}, },
updateProp: (name, value) => { updateProp: async (name, value) => {
let component = get(selectedComponent) let component = get(selectedComponent)
if (!name || !component) { if (!name || !component) {
return return
@ -497,7 +497,7 @@ export const getFrontendStore = () => {
state.selectedComponentId = component._id state.selectedComponentId = component._id
return state return state
}) })
store.actions.preview.saveSelected() await store.actions.preview.saveSelected()
}, },
links: { links: {
save: async (url, title) => { save: async (url, title) => {

View File

@ -13,7 +13,8 @@
if (production) { if (production) {
return `${appUrl}/${uri}` return `${appUrl}/${uri}`
} else { } else {
return `http://localhost:4001/${uri}`
return `${window.location.origin}/${uri}`
} }
} }

View File

@ -15,7 +15,7 @@
import TableLoadingOverlay from "./TableLoadingOverlay" import TableLoadingOverlay from "./TableLoadingOverlay"
import TableHeader from "./TableHeader" import TableHeader from "./TableHeader"
import "@budibase/svelte-ag-grid/dist/index.css" import "@budibase/svelte-ag-grid/dist/index.css"
import { TableNames } from "constants" import { TableNames, UNEDITABLE_USER_FIELDS } from "constants"
export let schema = {} export let schema = {}
export let data = [] export let data = []
@ -53,6 +53,9 @@
if (isUsersTable) { if (isUsersTable) {
schema.email.displayFieldName = "Email" schema.email.displayFieldName = "Email"
schema.roleId.displayFieldName = "Role" schema.roleId.displayFieldName = "Role"
if (schema.status) {
schema.status.displayFieldName = "Status"
}
} }
} }
@ -83,7 +86,7 @@
if (!allowEditing) { if (!allowEditing) {
return false return false
} }
return !(isUsersTable && ["email", "roleId"].includes(key)) return !(isUsersTable && UNEDITABLE_USER_FIELDS.includes(key))
} }
for (let [key, value] of Object.entries(schema || {})) { for (let [key, value] of Object.entries(schema || {})) {

View File

@ -53,6 +53,7 @@
<Table <Table
title={decodeURI(name)} title={decodeURI(name)}
schema={view.schema} schema={view.schema}
tableId={view.tableId}
{data} {data}
{loading} {loading}
bind:hideAutocolumns> bind:hideAutocolumns>

View File

@ -168,7 +168,9 @@
</div> </div>
{/if} {/if}
<div class="footer"> <div class="footer">
<Button text on:click={addFilter}>Add Filter</Button> <div class="add-filter">
<Button text on:click={addFilter}>Add Filter</Button>
</div>
<div class="buttons"> <div class="buttons">
<Button secondary on:click={onClosed}>Cancel</Button> <Button secondary on:click={onClosed}>Cancel</Button>
<Button primary on:click={saveView}>Save</Button> <Button primary on:click={saveView}>Save</Button>
@ -213,4 +215,8 @@
margin: 0; margin: 0;
font-size: var(--font-size-xs); font-size: var(--font-size-xs);
} }
.add-filter {
margin-right: 16px;
}
</style> </style>

View File

@ -23,7 +23,10 @@
}) })
</script> </script>
<ModalContent title="Webhook Endpoints" confirmText="OK" showCancelButton={false}> <ModalContent
title="Webhook Endpoints"
confirmText="OK"
showCancelButton={false}>
<p>See below the list of deployed webhook URLs.</p> <p>See below the list of deployed webhook URLs.</p>
{#each webhookUrls as webhookUrl} {#each webhookUrls as webhookUrl}
<div> <div>

View File

@ -39,14 +39,14 @@
return enrichedStructure return enrichedStructure
} }
const onItemChosen = (item, idx) => { const onItemChosen = async (item, idx) => {
if (item.isCategory) { if (item.isCategory) {
// Select and open this category // Select and open this category
selectedIndex = idx selectedIndex = idx
popover.show() popover.show()
} else { } else {
// Add this component // Add this component
store.actions.components.create(item.component) await store.actions.components.create(item.component)
popover.hide() popover.hide()
} }
} }

View File

@ -64,8 +64,8 @@
pasteComponent("below") pasteComponent("below")
} }
const deleteComponent = () => { const deleteComponent = async () => {
store.actions.components.delete(component) await store.actions.components.delete(component)
} }
const storeComponentForCopy = (cut = false) => { const storeComponentForCopy = (cut = false) => {

View File

@ -10,7 +10,7 @@ export const FrontendTypes = {
} }
// fields on the user table that cannot be edited // fields on the user table that cannot be edited
export const UNEDITABLE_USER_FIELDS = ["email", "password", "roleId"] export const UNEDITABLE_USER_FIELDS = ["email", "password", "roleId", "status"]
export const LAYOUT_NAMES = { export const LAYOUT_NAMES = {
MASTER: { MASTER: {

View File

@ -8,13 +8,10 @@ CLIENT_ID={{clientId}}
# used to create cookie hashes # used to create cookie hashes
JWT_SECRET={{cookieKey1}} JWT_SECRET={{cookieKey1}}
# port to run http server on
PORT=4001
# error level for koa-pino # error level for koa-pino
LOG_LEVEL=info LOG_LEVEL=info
DEPLOYMENT_CREDENTIALS_URL="https://dt4mpwwap8.execute-api.eu-west-1.amazonaws.com/prod/" DEPLOYMENT_CREDENTIALS_URL="https://dt4mpwwap8.execute-api.eu-west-1.amazonaws.com/prod/"
DEPLOYMENT_DB_URL="https://couchdb.budi.live:5984" DEPLOYMENT_DB_URL="https://couchdb.budi.live:5984"
SENTRY_DSN=https://a34ae347621946bf8acded18e5b7d4b8@o420233.ingest.sentry.io/5338131 SENTRY_DSN=https://a34ae347621946bf8acded18e5b7d4b8@o420233.ingest.sentry.io/5338131
ENABLE_ANALYTICS="true" ENABLE_ANALYTICS="true"

View File

@ -36,7 +36,7 @@
"test:integration": "jest routes --runInBand", "test:integration": "jest routes --runInBand",
"test:watch": "jest --watch", "test:watch": "jest --watch",
"run:docker": "node src/index", "run:docker": "node src/index",
"dev:builder": "nodemon src/index.js", "dev:builder": "PORT=4001 nodemon src/index.js",
"electron": "electron src/electron.js", "electron": "electron src/electron.js",
"build:electron": "electron-builder --dir", "build:electron": "electron-builder --dir",
"publish:electron": "electron-builder -mwl --publish always", "publish:electron": "electron-builder -mwl --publish always",

View File

@ -58,8 +58,10 @@ destroyable(server)
server.on("close", () => console.log("Server Closed")) server.on("close", () => console.log("Server Closed"))
module.exports = server.listen(env.PORT || 4001, async () => { module.exports = server.listen(env.PORT || 0, async () => {
console.log(`Budibase running on ${JSON.stringify(server.address())}`) console.log(`Budibase running on ${JSON.stringify(server.address())}`)
env._set("PORT", server.address().port)
eventEmitter.emitPort(env.PORT)
automations.init() automations.init()
// only init the self hosting DB info in the Pouch, not needed in self hosting prod // only init the self hosting DB info in the Pouch, not needed in self hosting prod
if (!env.CLOUD) { if (!env.CLOUD) {

View File

@ -7,6 +7,7 @@ const { existsSync } = require("fs-extra")
const initialiseBudibase = require("./utilities/initialiseBudibase") const initialiseBudibase = require("./utilities/initialiseBudibase")
const { budibaseAppsDir } = require("./utilities/budibaseDir") const { budibaseAppsDir } = require("./utilities/budibaseDir")
const { openNewGitHubIssue, debugInfo } = require("electron-util") const { openNewGitHubIssue, debugInfo } = require("electron-util")
const eventEmitter = require("./events")
const budibaseDir = budibaseAppsDir() const budibaseDir = budibaseAppsDir()
const envFile = join(budibaseDir, ".env") const envFile = join(budibaseDir, ".env")
@ -17,7 +18,11 @@ async function startApp() {
} }
// evict environment from cache, so it reloads when next asked // evict environment from cache, so it reloads when next asked
delete require.cache[require.resolve("./environment")] delete require.cache[require.resolve("./environment")]
// store the port incase its going to get overridden
const port = process.env.PORT
require("dotenv").config({ path: envFile }) require("dotenv").config({ path: envFile })
// overwrite the port - don't want to use dotenv for the port
require("./environment")._set("PORT", port)
unhandled({ unhandled({
showDialog: true, showDialog: true,
@ -34,9 +39,6 @@ async function startApp() {
}, },
}) })
const APP_URL = "http://localhost:4001/_builder"
const APP_TITLE = "Budibase Builder"
let win let win
function handleRedirect(e, url) { function handleRedirect(e, url) {
@ -46,22 +48,26 @@ async function startApp() {
async function createWindow() { async function createWindow() {
app.server = require("./app") app.server = require("./app")
win = new BrowserWindow({ eventEmitter.on("internal:port", port => {
width: 1920, const APP_URL = `http://localhost:${port}/_builder`
height: 1080, const APP_TITLE = "Budibase Builder"
icon: join(__dirname, "..", "build", "icons", "512x512.png"), win = new BrowserWindow({
}) width: 1920,
win.setTitle(APP_TITLE) height: 1080,
win.loadURL(APP_URL) icon: join(__dirname, "..", "build", "icons", "512x512.png"),
if (isDev) { })
win.webContents.openDevTools() win.setTitle(APP_TITLE)
} else { win.loadURL(APP_URL)
autoUpdater.checkForUpdatesAndNotify() if (isDev) {
} win.webContents.openDevTools()
} else {
autoUpdater.checkForUpdatesAndNotify()
}
// open _blank in default browser // open _blank in default browser
win.webContents.on("new-window", handleRedirect) win.webContents.on("new-window", handleRedirect)
win.webContents.on("will-navigate", handleRedirect) win.webContents.on("will-navigate", handleRedirect)
})
} }
app.whenReady().then(createWindow) app.whenReady().then(createWindow)

View File

@ -19,6 +19,10 @@ class BudibaseEmitter extends EventEmitter {
emitTable(eventName, appId, table = null) { emitTable(eventName, appId, table = null) {
tableEmission({ emitter: this, eventName, appId, table }) tableEmission({ emitter: this, eventName, appId, table })
} }
emitPort(portNumber) {
this.emit("internal:port", portNumber)
}
} }
const emitter = new BudibaseEmitter() const emitter = new BudibaseEmitter()