onClick(value || text)}>
{#if useIcon}
{:else}
@@ -29,25 +22,27 @@
diff --git a/packages/builder/src/components/userInterface/FlatButtonGroup.svelte b/packages/builder/src/components/userInterface/FlatButtonGroup.svelte
index c9523f4d5a..6789ada5aa 100644
--- a/packages/builder/src/components/userInterface/FlatButtonGroup.svelte
+++ b/packages/builder/src/components/userInterface/FlatButtonGroup.svelte
@@ -46,6 +46,7 @@
diff --git a/packages/builder/src/components/userInterface/LayoutEditor.svelte b/packages/builder/src/components/userInterface/LayoutEditor.svelte
index 0f3efaec0a..b36e6aa4a7 100644
--- a/packages/builder/src/components/userInterface/LayoutEditor.svelte
+++ b/packages/builder/src/components/userInterface/LayoutEditor.svelte
@@ -132,8 +132,8 @@
h3 {
text-transform: uppercase;
font-size: 13px;
- font-weight: 700;
- color: #000333;
+ font-weight: 600;
+ color: var(--ink);
opacity: 0.6;
margin-bottom: 10px;
}
@@ -142,16 +142,15 @@
text-transform: uppercase;
font-size: 10px;
font-weight: 600;
- color: #000333;
+ color: var(--ink);
opacity: 0.4;
- letter-spacing: 1px;
margin-bottom: 10px;
}
h5 {
font-size: 13px;
font-weight: 400;
- color: #000333;
+ color: var(--ink);
opacity: 0.8;
padding-top: 13px;
margin-bottom: 0;
diff --git a/packages/builder/src/components/userInterface/LayoutTemplateControls.svelte b/packages/builder/src/components/userInterface/LayoutTemplateControls.svelte
index dc1395bf0e..05a92d3e77 100644
--- a/packages/builder/src/components/userInterface/LayoutTemplateControls.svelte
+++ b/packages/builder/src/components/userInterface/LayoutTemplateControls.svelte
@@ -50,7 +50,7 @@
diff --git a/packages/builder/src/components/userInterface/OptionSelect.svelte b/packages/builder/src/components/userInterface/OptionSelect.svelte
index 8a1e3685f6..1c85a06392 100644
--- a/packages/builder/src/components/userInterface/OptionSelect.svelte
+++ b/packages/builder/src/components/userInterface/OptionSelect.svelte
@@ -142,24 +142,24 @@
position: relative;
outline: none;
width: 160px;
- height: 32px;
+ height: 36px;
cursor: pointer;
- font-size: 12px;
+ font-size: 14px;
}
.bb-select-anchor {
cursor: pointer;
display: flex;
- padding: 5px 10px;
- background-color: #f2f2f2;
- border-radius: 2px;
- border: 1px solid var(--grey-dark);
+ padding: 0px 12px;
+ height: 36px;
+ background-color: var(--grey-2);
+ border-radius: 5px;
align-items: center;
}
.bb-select-anchor > span {
- color: #565a66;
- font-weight: 500;
+ color: var(--ink);
+ font-weight: 400;
width: 140px;
overflow-x: hidden;
}
@@ -173,8 +173,8 @@
}
.selected {
- color: #565a66;
- font-weight: 500;
+ color: var(--ink);
+ font-weight: 400;
}
.bb-select-menu {
@@ -185,15 +185,15 @@
opacity: 0;
width: 160px;
z-index: 2;
- color: #808192;
- font-weight: 500;
+ color: var(--ink);
+ font-weight: 400;
height: fit-content !important;
border-bottom-left-radius: 2px;
border-bottom-right-radius: 2px;
- border-right: 1px solid var(--grey-dark);
- border-left: 1px solid var(--grey-dark);
- border-bottom: 1px solid var(--grey-dark);
- background-color: #f2f2f2;
+ border-right: 1px solid var(--grey-4);
+ border-left: 1px solid var(--grey-4);
+ border-bottom: 1px solid var(--grey-4);
+ background-color: var(--grey-2);
transform: scale(0);
transition: opacity 0.13s linear, transform 0.12s cubic-bezier(0, 0, 0.2, 1);
overflow-y: auto;
diff --git a/packages/builder/src/components/userInterface/PageLayout.svelte b/packages/builder/src/components/userInterface/PageLayout.svelte
index c2ad4b590b..d64ab670ba 100644
--- a/packages/builder/src/components/userInterface/PageLayout.svelte
+++ b/packages/builder/src/components/userInterface/PageLayout.svelte
@@ -73,12 +73,12 @@
display: inline-block;
transition: 0.2s;
width: 20px;
- color: var(--ink-light);
+ color: var(--grey-7);
}
.icon-big {
- font-size: 24px;
- color: var(--ink-light);
+ font-size: 20px;
+ color: var(--grey-7);
}
:global(svg) {
diff --git a/packages/builder/src/components/userInterface/PageView.svelte b/packages/builder/src/components/userInterface/PageView.svelte
index c00e7591f4..d60a4082de 100644
--- a/packages/builder/src/components/userInterface/PageView.svelte
+++ b/packages/builder/src/components/userInterface/PageView.svelte
@@ -59,7 +59,7 @@
padding: 15px;
}
.help-text {
- color: var(--slate);
+ color: var(--grey-2);
font-size: 10pt;
}
diff --git a/packages/builder/src/components/userInterface/PagesList.svelte b/packages/builder/src/components/userInterface/PagesList.svelte
index 5a78ef7121..df8bdf7d99 100644
--- a/packages/builder/src/components/userInterface/PagesList.svelte
+++ b/packages/builder/src/components/userInterface/PagesList.svelte
@@ -43,22 +43,24 @@
button {
cursor: pointer;
- padding: 8px 16px;
+ padding: 0px 16px;
+ height: 36px;
text-align: center;
background: #ffffff;
- color: var(--ink-light);
+ color: var(--grey-7);
border-radius: 5px;
- font-family: Roboto;
+ font-family: inter;
font-size: 14px;
font-weight: 400;
transition: all 0.3s;
text-rendering: optimizeLegibility;
border: none !important;
transition: 0.2s;
+ outline: none;
}
.active {
- background: var(--ink-light);
- color: var(--white);
+ background: var(--grey-3);
+ color: var(--ink);
}
diff --git a/packages/builder/src/components/userInterface/PropControl.svelte b/packages/builder/src/components/userInterface/PropControl.svelte
index 332f039b03..a7053953f4 100644
--- a/packages/builder/src/components/userInterface/PropControl.svelte
+++ b/packages/builder/src/components/userInterface/PropControl.svelte
@@ -38,7 +38,7 @@
word-wrap: break-word;
font-size: 13px;
font-weight: 400;
- color: #000333;
+ color: var(--ink);
opacity: 0.8;
padding-top: 13px;
margin-bottom: 0;
diff --git a/packages/builder/src/components/userInterface/PropertyControl.svelte b/packages/builder/src/components/userInterface/PropertyControl.svelte
index bd68002b98..b79d01fb32 100644
--- a/packages/builder/src/components/userInterface/PropertyControl.svelte
+++ b/packages/builder/src/components/userInterface/PropertyControl.svelte
@@ -12,7 +12,7 @@
if (v.target) {
let val = props.valueKey ? v.target[props.valueKey] : v.target.value
onChange(key, val)
- }else if(v.detail) {
+ } else if (v.detail) {
onChange(key, v.detail)
} else {
onChange(key, v)
@@ -55,7 +55,6 @@
flex: 0 0 50px;
display: flex;
align-items: center;
- padding: 0px 5px;
font-size: 12px;
font-weight: 400;
text-align: left;
diff --git a/packages/builder/src/components/userInterface/SettingsView.svelte b/packages/builder/src/components/userInterface/SettingsView.svelte
index fdcb286434..5ad260d761 100644
--- a/packages/builder/src/components/userInterface/SettingsView.svelte
+++ b/packages/builder/src/components/userInterface/SettingsView.svelte
@@ -1,34 +1,28 @@
@@ -23,7 +23,8 @@
.root {
height: 100%;
display: flex;
- background: #fafafa;
+ background: var(--grey-1);
+ line-height: 1;
}
.content {
@@ -32,7 +33,6 @@
}
.nav {
- overflow: auto;
flex: 0 1 auto;
width: 300px;
height: 100%;
diff --git a/packages/builder/src/pages/[application]/backend/actions/index.svelte b/packages/builder/src/pages/[application]/backend/actions/index.svelte
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/builder/src/pages/[application]/backend/database/[selectedDatabase]/_layout.svelte b/packages/builder/src/pages/[application]/backend/database/[selectedDatabase]/_layout.svelte
new file mode 100644
index 0000000000..4fa864ce7a
--- /dev/null
+++ b/packages/builder/src/pages/[application]/backend/database/[selectedDatabase]/_layout.svelte
@@ -0,0 +1 @@
+
diff --git a/packages/builder/src/pages/[application]/backend/database/[selectedDatabase]/index.svelte b/packages/builder/src/pages/[application]/backend/database/[selectedDatabase]/index.svelte
index 3ebe117636..a9f5589caf 100644
--- a/packages/builder/src/pages/[application]/backend/database/[selectedDatabase]/index.svelte
+++ b/packages/builder/src/pages/[application]/backend/database/[selectedDatabase]/index.svelte
@@ -1,5 +1,7 @@
-
-
{breadcrumbs}
- {#if $backendUiStore.selectedModel._id}
-
- Create new record
-
- {/if}
-
-{#if $backendUiStore.selectedDatabase._id && $backendUiStore.selectedModel.name}
-
+{#if selectedModel.schema && Object.keys(selectedModel.schema).length === 0}
+
+{:else if $backendUiStore.selectedDatabase._id && selectedModel.name}
+
{:else}
-
- create your first model to start building
-
+
create your first model to start building
{/if}
diff --git a/packages/builder/src/pages/[application]/frontend/_layout.svelte b/packages/builder/src/pages/[application]/frontend/_layout.svelte
index 8bdb95becf..87b064addf 100644
--- a/packages/builder/src/pages/[application]/frontend/_layout.svelte
+++ b/packages/builder/src/pages/[application]/frontend/_layout.svelte
@@ -75,7 +75,7 @@
display: grid;
grid-template-columns: 300px 1fr 300px;
width: 100%;
- background: var(--grey-light);
+ background: var(--grey-1);
flex: 1;
min-height: 0;
align-items: stretch;
@@ -116,10 +116,10 @@
vertical-align: bottom;
grid-column-start: button;
cursor: pointer;
- color: var(--primary75);
+ color: var(--blue);
}
.nav-group-header > div:nth-child(3):hover {
- color: var(--primary75);
+ color: var(--blue);
}
diff --git a/packages/builder/src/pages/[application]/workflow/_layout.svelte b/packages/builder/src/pages/[application]/workflow/_layout.svelte
index 96a0dcbb2f..2746a82d2f 100644
--- a/packages/builder/src/pages/[application]/workflow/_layout.svelte
+++ b/packages/builder/src/pages/[application]/workflow/_layout.svelte
@@ -22,13 +22,14 @@
diff --git a/packages/builder/src/pages/index.svelte b/packages/builder/src/pages/index.svelte
index e54102db1e..0d2f76a007 100644
--- a/packages/builder/src/pages/index.svelte
+++ b/packages/builder/src/pages/index.svelte
@@ -73,7 +73,7 @@
.welcome {
font-size: 42px;
color: var(--ink);
- font-weight: 900;
+ font-weight: 700;
margin: 40px 0px 0px 80px;
}
@@ -136,7 +136,7 @@
.banner-button:hover {
background-color: var(--white);
color: var(--ink);
- border: var(--grey-dark) 1px solid;
+ border: var(--grey-4) 1px solid;
}
.app-section-header {
@@ -149,7 +149,7 @@
.app-section-title {
font-size: 20px;
color: var(--ink);
- font-weight: 700;
+ font-weight: 600;
margin-bottom: 20px;
}
diff --git a/packages/builder/tests/renameScreen.spec.js b/packages/builder/tests/renameScreen.spec.js
deleted file mode 100644
index 9091c029ce..0000000000
--- a/packages/builder/tests/renameScreen.spec.js
+++ /dev/null
@@ -1,53 +0,0 @@
-import { getExactComponent } from "../src/components/userInterface/pagesParsing/searchComponents"
-import { rename } from "../src/components/userInterface/pagesParsing/renameScreen"
-import { componentsAndScreens } from "./testData"
-
-describe("rename component", () => {
- it("should change the name of the component, duh", () => {
- const { screens } = componentsAndScreens()
-
- const result = rename({}, screens, "PrimaryButton", "MainButton")
-
- const newComponent = getExactComponent(result.screens, "MainButton")
- const oldComponent = getExactComponent(result.screens, "Primary")
- expect(oldComponent).toBeUndefined()
- expect(newComponent).toBeDefined()
- expect(newComponent.name).toBe("MainButton")
- })
-
- /* this may be usefull if we have user defined components
- it("should change name of nested _components", () => {
- const {screens} = componentsAndScreens();
- const result = rename({}, screens, "PrimaryButton", "MainButton");
-
- const buttonGroup = getExactComponent(result.screens, "ButtonGroup");
- expect(buttonGroup.props.header[0]._component).toBe("MainButton");
-
- });
- */
-
- it("should change name of page appBody", () => {
- const { screens } = componentsAndScreens()
- const pages = {
- main: {
- appBody: "PrimaryButton",
- },
- }
-
- const result = rename(pages, screens, "PrimaryButton", "MainButton")
- expect(result.pages.main.appBody).toBe("MainButton")
- })
-
- /* this may be usefull if we have user defined components
- it("should return a list of changed components", () => {
- const {screens} = componentsAndScreens();
- const result = rename({}, screens, "PrimaryButton", "MainButton");
-
- expect(result.changedScreens).toEqual(["ButtonGroup"]);
-
- const result2 = rename({}, screens, "common/SmallTextbox", "common/TinyTextBox");
- expect(result2.changedScreens).toEqual(["Field"]);
-
- });
- */
-})
diff --git a/packages/builder/tests/searchComponentsProps.spec.js b/packages/builder/tests/searchComponentsProps.spec.js
index 65f05b064e..461440dfd3 100644
--- a/packages/builder/tests/searchComponentsProps.spec.js
+++ b/packages/builder/tests/searchComponentsProps.spec.js
@@ -5,70 +5,33 @@ import {
} from "../src/components/userInterface/pagesParsing/searchComponents"
import { componentsAndScreens } from "./testData"
-describe("searchAllComponents", () => {
- it("should match component by name", () => {
- const results = searchAllComponents(
- componentsAndScreens().components,
- "Textbox"
- )
-
- expect(results.length).toBe(1)
- expect(results[0].name).toBe("budibase-components/TextBox")
- })
-
- it("should match component by tag", () => {
- const results = searchAllComponents(
- componentsAndScreens().components,
- "record"
- )
-
- expect(results.length).toBe(1)
- expect(results[0].name).toBe("budibase-components/RecordView")
- })
-})
describe("getExactComponent", () => {
it("should get component by name", () => {
- const { components, screens } = componentsAndScreens()
+ const { components } = componentsAndScreens()
const result = getExactComponent(
- [...components, ...screens],
- "common/SmallTextbox"
+ components,
+ "TextBox"
)
expect(result).toBeDefined()
- expect(result.name).toBe("common/SmallTextbox")
+ expect(result._instanceName).toBe("TextBox")
})
- it("should return nothing when no result (should not fail)", () => {
- const { components, screens } = componentsAndScreens()
- const result = getExactComponent([...components, ...screens], "bla/bla/bla")
+ test("Should not find as isScreen is not specified", () => {
+ const { screens } = componentsAndScreens()
+ const result = getExactComponent(screens, "SmallTextbox")
expect(result).not.toBeDefined()
})
-})
-describe("getAncestorProps", () => {
- it("should return props of root component", () => {
- const result = getAncestorProps(
- componentsAndScreens().components,
- "budibase-components/TextBox"
- )
+ test("Should find as isScreen is specified", () => {
+ const { screens } = componentsAndScreens()
+ const result = getExactComponent(screens, "SmallTextbox", true)
- expect(result).toEqual([componentsAndScreens().components[0].props])
- })
+ expect(result).toBeDefined()
+ expect(result.props._instanceName).toBe("SmallTextbox")
- it("should return props of inherited and current component, in order", () => {
- const { components, screens } = componentsAndScreens()
- const allComponentsAndScreens = [...components, ...screens]
-
- const result = getAncestorProps(
- allComponentsAndScreens,
- "common/PasswordBox"
- )
-
- expect(result).toEqual([
- allComponentsAndScreens[0].props,
- { ...allComponentsAndScreens[5].props },
- ])
})
})
+
diff --git a/packages/builder/tests/testData.js b/packages/builder/tests/testData.js
index bc4a73cdab..d2703ad335 100644
--- a/packages/builder/tests/testData.js
+++ b/packages/builder/tests/testData.js
@@ -1,7 +1,7 @@
export const componentsAndScreens = () => ({
components: [
{
- name: "budibase-components/TextBox",
+ _instanceName: "TextBox",
tags: ["Text", "input"],
children: false,
props: {
@@ -12,7 +12,7 @@ export const componentsAndScreens = () => ({
},
},
{
- name: "budibase-components/Button",
+ _instanceName: "Button",
tags: ["input"],
children: true,
props: {
@@ -22,14 +22,14 @@ export const componentsAndScreens = () => ({
},
},
{
- name: "budibase-components/div",
+ _instanceName: "div",
tags: ["input"],
props: {
width: "number",
},
},
{
- name: "budibase-components/RecordView",
+ _instanceName: "Record View",
tags: ["record"],
props: {
data: "state",
@@ -38,9 +38,9 @@ export const componentsAndScreens = () => ({
],
screens: [
{
- name: "common/SmallTextbox",
props: {
_component: "budibase-components/TextBox",
+ _instanceName: "SmallTextbox",
size: "small",
},
},
@@ -50,36 +50,40 @@ export const componentsAndScreens = () => ({
tags: ["mask"],
props: {
_component: "budibase-components/TextBox",
+ _instanceName: "PasswordBox",
isPassword: true,
size: "small",
},
},
{
- name: "PrimaryButton",
props: {
_component: "budibase-components/Button",
+ _instanceName: "PrimaryButton",
css: "btn-primary",
},
},
{
- name: "Screen 1",
route: "",
props: {
_component: "budibase-components/div",
width: 100,
+ _instanceName: "Screen 1",
_children: [
{
_component: "budibase-components/Button",
contentText: "Button 1",
+ _instanceName: "Button 1",
},
{
_component: "budibase-components/Button",
contentText: "Button 2",
+ _instanceName: "Button 2",
},
{
_component: "budibase-components/TextBox",
+ _instanceName: "TextBox",
isPassword: true,
size: "small",
},
@@ -88,9 +92,9 @@ export const componentsAndScreens = () => ({
},
{
- name: "Field",
props: {
_component: "budibase-components/div",
+ _instanceName: "Field",
_children: [
{
_component: "common/SmallTextbox",
diff --git a/packages/cli/src/commands/new/newHandler.js b/packages/cli/src/commands/new/newHandler.js
index 44007acde7..64c974cdf9 100644
--- a/packages/cli/src/commands/new/newHandler.js
+++ b/packages/cli/src/commands/new/newHandler.js
@@ -17,9 +17,7 @@ const run = async opts => {
exec(`cd ${join(opts.dir, opts.applicationId)} && npm install`)
console.log(chalk.green(`Budibase app ${opts.name} created!`))
} catch (error) {
- console.error(
- chalk.red("Error creating new app", JSON.stringify(error, { space: 2 }))
- )
+ console.error(chalk.red("Error creating new app", error))
}
}
@@ -53,7 +51,9 @@ const createAppInstance = async opts => {
const createInstCtx = {
params: {
clientId: process.env.CLIENT_ID,
- applicationId: opts.applicationId,
+ },
+ user: {
+ appId: opts.applicationId,
},
request: {
body: { name: `dev-${process.env.CLIENT_ID}` },
diff --git a/packages/server/builder/assets/Inter-Black.woff b/packages/server/builder/assets/Inter-Black.woff
new file mode 100644
index 0000000000..07800f4b74
Binary files /dev/null and b/packages/server/builder/assets/Inter-Black.woff differ
diff --git a/packages/server/builder/assets/Inter-Black.woff2 b/packages/server/builder/assets/Inter-Black.woff2
new file mode 100644
index 0000000000..9a615e6e83
Binary files /dev/null and b/packages/server/builder/assets/Inter-Black.woff2 differ
diff --git a/packages/server/builder/assets/Inter-Bold.woff b/packages/server/builder/assets/Inter-Bold.woff
new file mode 100644
index 0000000000..61e1c25e64
Binary files /dev/null and b/packages/server/builder/assets/Inter-Bold.woff differ
diff --git a/packages/server/builder/assets/Inter-Bold.woff2 b/packages/server/builder/assets/Inter-Bold.woff2
new file mode 100644
index 0000000000..6c401bb09b
Binary files /dev/null and b/packages/server/builder/assets/Inter-Bold.woff2 differ
diff --git a/packages/server/builder/assets/Inter-ExtraBold.woff b/packages/server/builder/assets/Inter-ExtraBold.woff
new file mode 100644
index 0000000000..433fb3285c
Binary files /dev/null and b/packages/server/builder/assets/Inter-ExtraBold.woff differ
diff --git a/packages/server/builder/assets/Inter-ExtraBold.woff2 b/packages/server/builder/assets/Inter-ExtraBold.woff2
new file mode 100644
index 0000000000..5a08b364d5
Binary files /dev/null and b/packages/server/builder/assets/Inter-ExtraBold.woff2 differ
diff --git a/packages/server/builder/assets/Inter-Medium.woff b/packages/server/builder/assets/Inter-Medium.woff
new file mode 100644
index 0000000000..8c36a6345e
Binary files /dev/null and b/packages/server/builder/assets/Inter-Medium.woff differ
diff --git a/packages/server/builder/assets/Inter-Medium.woff2 b/packages/server/builder/assets/Inter-Medium.woff2
new file mode 100644
index 0000000000..3b31d3350a
Binary files /dev/null and b/packages/server/builder/assets/Inter-Medium.woff2 differ
diff --git a/packages/server/builder/assets/Inter-Regular.woff b/packages/server/builder/assets/Inter-Regular.woff
new file mode 100644
index 0000000000..7d587c40bf
Binary files /dev/null and b/packages/server/builder/assets/Inter-Regular.woff differ
diff --git a/packages/server/builder/assets/Inter-Regular.woff2 b/packages/server/builder/assets/Inter-Regular.woff2
new file mode 100644
index 0000000000..d5ffd2a1f1
Binary files /dev/null and b/packages/server/builder/assets/Inter-Regular.woff2 differ
diff --git a/packages/server/builder/assets/Inter-SemiBold.woff b/packages/server/builder/assets/Inter-SemiBold.woff
new file mode 100644
index 0000000000..99df06cbee
Binary files /dev/null and b/packages/server/builder/assets/Inter-SemiBold.woff differ
diff --git a/packages/server/builder/assets/Inter-SemiBold.woff2 b/packages/server/builder/assets/Inter-SemiBold.woff2
new file mode 100644
index 0000000000..df746af999
Binary files /dev/null and b/packages/server/builder/assets/Inter-SemiBold.woff2 differ
diff --git a/packages/server/package.json b/packages/server/package.json
index ad89654b0e..f725f65abf 100644
--- a/packages/server/package.json
+++ b/packages/server/package.json
@@ -48,6 +48,7 @@
"@sendgrid/mail": "^7.1.1",
"bcryptjs": "^2.4.3",
"dotenv": "^8.2.0",
+ "electron": "^9.0.4",
"electron-is-dev": "^1.2.0",
"electron-unhandled": "^3.0.2",
"electron-updater": "^4.3.1",
@@ -74,7 +75,6 @@
},
"devDependencies": {
"@jest/test-sequencer": "^24.8.0",
- "electron": "^8.2.5",
"electron-builder": "^22.6.0",
"electron-builder-notarize": "^1.1.2",
"eslint": "^6.8.0",
diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js
index ab4820794f..47addee330 100644
--- a/packages/server/src/api/controllers/application.js
+++ b/packages/server/src/api/controllers/application.js
@@ -1,6 +1,6 @@
const CouchDB = require("../../db")
const ClientDb = require("../../db/clientDb")
-const { getPackageForBuilder } = require("../../utilities/builder")
+const { getPackageForBuilder, buildPage } = require("../../utilities/builder")
const newid = require("../../db/newid")
const env = require("../../environment")
const instanceController = require("./instance")
@@ -45,7 +45,7 @@ exports.create = async function(ctx) {
}
const appId = newid()
// insert an appId -> clientId lookup
- const masterDb = new CouchDB("clientAppLookup")
+ const masterDb = new CouchDB("client_app_lookup")
await masterDb.put({
_id: appId,
@@ -111,20 +111,28 @@ const createEmptyAppPackage = async (ctx, app) => {
await updateJsonFile(join(appsFolder, app._id, "package.json"), {
name: npmFriendlyAppName(app.name),
})
- await updateJsonFile(
+
+ const mainJson = await updateJsonFile(
join(appsFolder, app._id, "pages", "main", "page.json"),
app
)
- await updateJsonFile(
+
+ await buildPage(ctx.config, app._id, "main", { page: mainJson })
+
+ const unauthenticatedJson = await updateJsonFile(
join(appsFolder, app._id, "pages", "unauthenticated", "page.json"),
app
)
+ await buildPage(ctx.config, app._id, "unauthenticated", {
+ page: unauthenticatedJson,
+ })
+
return newAppFolder
}
const lookupClientId = async appId => {
- const masterDb = new CouchDB("clientAppLookup")
+ const masterDb = new CouchDB("client_app_lookup")
const { clientId } = await masterDb.get(appId)
return clientId
}
@@ -145,6 +153,7 @@ const updateJsonFile = async (filePath, app) => {
const json = await readFile(filePath, "utf8")
const newJson = sqrl.Render(json, app)
await writeFile(filePath, newJson, "utf8")
+ return JSON.parse(newJson)
}
const runNpmInstall = async newAppFolder => {
diff --git a/packages/server/src/api/controllers/auth.js b/packages/server/src/api/controllers/auth.js
index e9570e270f..4f0ddbf0d8 100644
--- a/packages/server/src/api/controllers/auth.js
+++ b/packages/server/src/api/controllers/auth.js
@@ -11,7 +11,7 @@ exports.authenticate = async ctx => {
if (!username) ctx.throw(400, "Username Required.")
if (!password) ctx.throw(400, "Password Required")
- const masterDb = new CouchDB("clientAppLookup")
+ const masterDb = new CouchDB("client_app_lookup")
const { clientId } = await masterDb.get(ctx.user.appId)
diff --git a/packages/server/src/api/controllers/component.js b/packages/server/src/api/controllers/component.js
index a3b4d9c2bb..3d631bcaec 100644
--- a/packages/server/src/api/controllers/component.js
+++ b/packages/server/src/api/controllers/component.js
@@ -7,7 +7,7 @@ const {
} = require("../../utilities/budibaseDir")
exports.fetchAppComponentDefinitions = async function(ctx) {
- const masterDb = new CouchDB("clientAppLookup")
+ const masterDb = new CouchDB("client_app_lookup")
const { clientId } = await masterDb.get(ctx.params.appId)
const db = new CouchDB(ClientDb.name(clientId))
const app = await db.get(ctx.params.appId)
diff --git a/packages/server/src/api/controllers/instance.js b/packages/server/src/api/controllers/instance.js
index 903d3ff651..4bc22bd650 100644
--- a/packages/server/src/api/controllers/instance.js
+++ b/packages/server/src/api/controllers/instance.js
@@ -8,7 +8,7 @@ exports.create = async function(ctx) {
const appShortId = appId.substring(0, 7)
const instanceId = `inst_${appShortId}_${newid()}`
- const masterDb = new CouchDB("clientAppLookup")
+ const masterDb = new CouchDB("client_app_lookup")
const { clientId } = await masterDb.get(appId)
const db = new CouchDB(instanceId)
diff --git a/packages/server/src/api/controllers/model.js b/packages/server/src/api/controllers/model.js
index e7792195cb..65bc367a08 100644
--- a/packages/server/src/api/controllers/model.js
+++ b/packages/server/src/api/controllers/model.js
@@ -16,16 +16,16 @@ exports.find = async function(ctx) {
ctx.body = model
}
-exports.create = async function(ctx) {
+exports.save = async function(ctx) {
const db = new CouchDB(ctx.user.instanceId)
- const newModel = {
+ const modelToSave = {
type: "model",
- ...ctx.request.body,
_id: newid(),
+ ...ctx.request.body,
}
- const result = await db.post(newModel)
- newModel._rev = result.rev
+ const result = await db.post(modelToSave)
+ modelToSave._rev = result.rev
const { schema } = ctx.request.body
for (let key in schema) {
@@ -33,9 +33,10 @@ exports.create = async function(ctx) {
if (schema[key].type === "link") {
// create the link field in the other model
const linkedModel = await db.get(schema[key].modelId)
- linkedModel.schema[newModel.name] = {
+ linkedModel.schema[modelToSave._id] = {
+ name: modelToSave.name,
type: "link",
- modelId: newModel._id,
+ modelId: modelToSave._id,
constraints: {
type: "array",
},
@@ -47,9 +48,9 @@ exports.create = async function(ctx) {
const designDoc = await db.get("_design/database")
designDoc.views = {
...designDoc.views,
- [`all_${newModel._id}`]: {
+ [`all_${modelToSave._id}`]: {
map: `function(doc) {
- if (doc.modelId === "${newModel._id}") {
+ if (doc.modelId === "${modelToSave._id}") {
emit(doc[doc.key], doc._id);
}
}`,
@@ -58,12 +59,10 @@ exports.create = async function(ctx) {
await db.put(designDoc)
ctx.status = 200
- ctx.message = `Model ${ctx.request.body.name} created successfully.`
- ctx.body = newModel
+ ctx.message = `Model ${ctx.request.body.name} saved successfully.`
+ ctx.body = modelToSave
}
-exports.update = async function() {}
-
exports.destroy = async function(ctx) {
const db = new CouchDB(ctx.user.instanceId)
diff --git a/packages/server/src/api/controllers/record.js b/packages/server/src/api/controllers/record.js
index 4e4af81e01..4efe1acb73 100644
--- a/packages/server/src/api/controllers/record.js
+++ b/packages/server/src/api/controllers/record.js
@@ -43,6 +43,29 @@ exports.save = async function(ctx) {
const response = await db.post(record)
record._rev = response.rev
+ // create links in other tables
+ for (let key in record) {
+ if (model.schema[key] && model.schema[key].type === "link") {
+ const linked = await db.allDocs({
+ include_docs: true,
+ keys: record[key],
+ })
+
+ // add this record to the linked records in attached models
+ const linkedDocs = linked.rows.map(row => {
+ const doc = row.doc
+ return {
+ ...doc,
+ [model._id]: doc[model._id]
+ ? [...doc[model._id], record._id]
+ : [record._id],
+ }
+ })
+
+ await db.bulkDocs(linkedDocs)
+ }
+ }
+
ctx.eventEmitter &&
ctx.eventEmitter.emit(`record:save`, {
record,
@@ -82,7 +105,7 @@ exports.find = async function(ctx) {
const db = new CouchDB(ctx.user.instanceId)
const record = await db.get(ctx.params.recordId)
if (record.modelId !== ctx.params.modelId) {
- ctx.throw(400, "Supplied modelId doe not match the record's modelId")
+ ctx.throw(400, "Supplied modelId does not match the records modelId")
return
}
ctx.body = record
diff --git a/packages/server/src/api/controllers/user.js b/packages/server/src/api/controllers/user.js
index 71816f1c78..7805ad251d 100644
--- a/packages/server/src/api/controllers/user.js
+++ b/packages/server/src/api/controllers/user.js
@@ -41,7 +41,7 @@ exports.create = async function(ctx) {
const response = await database.post(user)
- const masterDb = new CouchDB("clientAppLookup")
+ const masterDb = new CouchDB("client_app_lookup")
const { clientId } = await masterDb.get(appId)
// the clientDB needs to store a map of users against the app
diff --git a/packages/server/src/api/routes/model.js b/packages/server/src/api/routes/model.js
index 10882aa057..00eb46d515 100644
--- a/packages/server/src/api/routes/model.js
+++ b/packages/server/src/api/routes/model.js
@@ -12,8 +12,7 @@ router
authorized(READ_MODEL, ctx => ctx.params.id),
modelController.find
)
- .post("/api/models", authorized(BUILDER), modelController.create)
- // .patch("/api/:instanceId/models", controller.update)
+ .post("/api/models", authorized(BUILDER), modelController.save)
.delete(
"/api/models/:modelId/:revId",
authorized(BUILDER),
diff --git a/packages/server/src/api/routes/tests/model.spec.js b/packages/server/src/api/routes/tests/model.spec.js
index 4d4e7aeb08..89aa9aa25b 100644
--- a/packages/server/src/api/routes/tests/model.spec.js
+++ b/packages/server/src/api/routes/tests/model.spec.js
@@ -45,7 +45,7 @@ describe("/models", () => {
.expect('Content-Type', /json/)
.expect(200)
.end(async (err, res) => {
- expect(res.res.statusMessage).toEqual("Model TestModel created successfully.");
+ expect(res.res.statusMessage).toEqual("Model TestModel saved successfully.");
expect(res.body.name).toEqual("TestModel");
done();
});
@@ -112,7 +112,7 @@ describe("/models", () => {
afterEach(() => {
delete testModel._rev
- })
+ });
it("returns a success response when a model is deleted.", async done => {
request
diff --git a/packages/server/src/utilities/appDirectoryTemplate/pages/main/page.json b/packages/server/src/utilities/appDirectoryTemplate/pages/main/page.json
index 1ae407774e..392496988f 100644
--- a/packages/server/src/utilities/appDirectoryTemplate/pages/main/page.json
+++ b/packages/server/src/utilities/appDirectoryTemplate/pages/main/page.json
@@ -5,7 +5,20 @@
"componentLibraries": ["@budibase/standard-components", "@budibase/materialdesign-components"],
"props" : {
"_component": "@budibase/standard-components/container",
- "_children": [],
+ "_children": [
+ {
+ "_id": "7fcf11e4-6f5b-4085-8e0d-9f3d44c98967",
+ "_component": "##builtin/screenslot",
+ "_styles": {
+ "normal": {},
+ "hover": {},
+ "active": {},
+ "selected": {}
+ },
+ "_code": "",
+ "_children": []
+ }
+ ],
"_id": 0,
"type": "div",
"_styles": {
diff --git a/packages/server/src/utilities/builder/index.js b/packages/server/src/utilities/builder/index.js
index 7b9a6a69ec..f63e34a8cd 100644
--- a/packages/server/src/utilities/builder/index.js
+++ b/packages/server/src/utilities/builder/index.js
@@ -41,7 +41,8 @@ const screenPath = (appPath, pageName, name) =>
module.exports.saveScreen = async (config, appname, pagename, screen) => {
const appPath = appPackageFolder(config, appname)
- const compPath = screenPath(appPath, pagename, screen.name)
+ const compPath = screenPath(appPath, pagename, screen.props._id)
+
await ensureDir(dirname(compPath))
if (screen._css) {
delete screen._css
diff --git a/packages/server/src/utilities/builder/index.template.html b/packages/server/src/utilities/builder/index.template.html
index a21219de9b..91b33cb284 100644
--- a/packages/server/src/utilities/builder/index.template.html
+++ b/packages/server/src/utilities/builder/index.template.html
@@ -11,7 +11,7 @@
diff --git a/packages/standard-components/src/List.svelte b/packages/standard-components/src/List.svelte
index 9e4ddd6c99..8207ef47ee 100644
--- a/packages/standard-components/src/List.svelte
+++ b/packages/standard-components/src/List.svelte
@@ -41,7 +41,7 @@
.list {
display: flex;
flex-direction: column;
- font-family: Roboto;
+ font-family: Inter;
}
.grid {
diff --git a/packages/standard-components/src/Login.svelte b/packages/standard-components/src/Login.svelte
index 0675c65f46..d09cd0ff2b 100644
--- a/packages/standard-components/src/Login.svelte
+++ b/packages/standard-components/src/Login.svelte
@@ -23,7 +23,10 @@
const login = async () => {
loading = true
- const response = await _bb.api.post("/api/authenticate", { username, password })
+ const response = await _bb.api.post("/api/authenticate", {
+ username,
+ password,
+ })
if (response.status === 200) {
const json = await response.json()
localStorage.setItem("budibase:token", json.token)