Merge branch 'master' of github.com:Budibase/budibase into feature/sql-query-aliasing
This commit is contained in:
commit
88c54bcc1d
|
@ -38,10 +38,10 @@ jobs:
|
||||||
submodules: ${{ env.IS_OSS_CONTRIBUTOR == 'false' }}
|
submodules: ${{ env.IS_OSS_CONTRIBUTOR == 'false' }}
|
||||||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }}
|
token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }}
|
||||||
|
|
||||||
- name: Use Node.js 18.x
|
- name: Use Node.js 20.x
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18.x
|
node-version: 20.x
|
||||||
cache: yarn
|
cache: yarn
|
||||||
- run: yarn --frozen-lockfile
|
- run: yarn --frozen-lockfile
|
||||||
- run: yarn lint
|
- run: yarn lint
|
||||||
|
@ -56,10 +56,10 @@ jobs:
|
||||||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }}
|
token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Use Node.js 18.x
|
- name: Use Node.js 20.x
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18.x
|
node-version: 20.x
|
||||||
cache: yarn
|
cache: yarn
|
||||||
- run: yarn --frozen-lockfile
|
- run: yarn --frozen-lockfile
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Use Node.js 18.x
|
- name: Use Node.js 20.x
|
||||||
uses: azure/setup-helm@v3
|
uses: azure/setup-helm@v3
|
||||||
- run: cd charts/budibase && helm lint .
|
- run: cd charts/budibase && helm lint .
|
||||||
|
|
||||||
|
@ -98,10 +98,10 @@ jobs:
|
||||||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }}
|
token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Use Node.js 18.x
|
- name: Use Node.js 20.x
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18.x
|
node-version: 20.x
|
||||||
cache: yarn
|
cache: yarn
|
||||||
- run: yarn --frozen-lockfile
|
- run: yarn --frozen-lockfile
|
||||||
- name: Test
|
- name: Test
|
||||||
|
@ -122,10 +122,10 @@ jobs:
|
||||||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }}
|
token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Use Node.js 18.x
|
- name: Use Node.js 20.x
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18.x
|
node-version: 20.x
|
||||||
cache: yarn
|
cache: yarn
|
||||||
- run: yarn --frozen-lockfile
|
- run: yarn --frozen-lockfile
|
||||||
- name: Test worker
|
- name: Test worker
|
||||||
|
@ -146,10 +146,10 @@ jobs:
|
||||||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }}
|
token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Use Node.js 18.x
|
- name: Use Node.js 20.x
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18.x
|
node-version: 20.x
|
||||||
cache: yarn
|
cache: yarn
|
||||||
- run: yarn --frozen-lockfile
|
- run: yarn --frozen-lockfile
|
||||||
- name: Test server
|
- name: Test server
|
||||||
|
@ -171,10 +171,10 @@ jobs:
|
||||||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }}
|
token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Use Node.js 18.x
|
- name: Use Node.js 20.x
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18.x
|
node-version: 20.x
|
||||||
cache: yarn
|
cache: yarn
|
||||||
- run: yarn --frozen-lockfile
|
- run: yarn --frozen-lockfile
|
||||||
- name: Test
|
- name: Test
|
||||||
|
@ -194,10 +194,10 @@ jobs:
|
||||||
submodules: ${{ env.IS_OSS_CONTRIBUTOR == 'false' }}
|
submodules: ${{ env.IS_OSS_CONTRIBUTOR == 'false' }}
|
||||||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }}
|
token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }}
|
||||||
|
|
||||||
- name: Use Node.js 18.x
|
- name: Use Node.js 20.x
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18.x
|
node-version: 20.x
|
||||||
cache: yarn
|
cache: yarn
|
||||||
- run: yarn --frozen-lockfile
|
- run: yarn --frozen-lockfile
|
||||||
- name: Build packages
|
- name: Build packages
|
||||||
|
|
|
@ -16,8 +16,8 @@ jobs:
|
||||||
days-before-pr-stale: 7
|
days-before-pr-stale: 7
|
||||||
stale-issue-label: stale
|
stale-issue-label: stale
|
||||||
exempt-pr-labels: pinned,security,roadmap
|
exempt-pr-labels: pinned,security,roadmap
|
||||||
|
|
||||||
days-before-pr-close: 7
|
days-before-pr-close: 7
|
||||||
|
days-before-issue-close: 30
|
||||||
|
|
||||||
- uses: actions/stale@v8
|
- uses: actions/stale@v8
|
||||||
with:
|
with:
|
||||||
|
@ -26,6 +26,7 @@ jobs:
|
||||||
days-before-stale: 30
|
days-before-stale: 30
|
||||||
only-issue-labels: bug,High priority
|
only-issue-labels: bug,High priority
|
||||||
stale-issue-label: warn
|
stale-issue-label: warn
|
||||||
|
days-before-close: 30
|
||||||
|
|
||||||
- uses: actions/stale@v8
|
- uses: actions/stale@v8
|
||||||
with:
|
with:
|
||||||
|
@ -34,6 +35,7 @@ jobs:
|
||||||
days-before-stale: 90
|
days-before-stale: 90
|
||||||
only-issue-labels: bug,Medium priority
|
only-issue-labels: bug,Medium priority
|
||||||
stale-issue-label: warn
|
stale-issue-label: warn
|
||||||
|
days-before-close: 30
|
||||||
|
|
||||||
- uses: actions/stale@v8
|
- uses: actions/stale@v8
|
||||||
with:
|
with:
|
||||||
|
@ -43,5 +45,4 @@ jobs:
|
||||||
stale-issue-label: stale
|
stale-issue-label: stale
|
||||||
only-issue-labels: bug
|
only-issue-labels: bug
|
||||||
stale-issue-message: "This issue has been automatically marked as stale because it has not had any activity for six months."
|
stale-issue-message: "This issue has been automatically marked as stale because it has not had any activity for six months."
|
||||||
|
|
||||||
days-before-close: 30
|
days-before-close: 30
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
nodejs 18.17.0
|
nodejs 20.10.0
|
||||||
python 3.10.0
|
python 3.10.0
|
||||||
yarn 1.22.19
|
yarn 1.22.19
|
||||||
|
|
|
@ -252,4 +252,10 @@ spec:
|
||||||
{{ end }}
|
{{ end }}
|
||||||
restartPolicy: Always
|
restartPolicy: Always
|
||||||
serviceAccountName: ""
|
serviceAccountName: ""
|
||||||
|
{{ if .Values.services.apps.ndots }}
|
||||||
|
dnsConfig:
|
||||||
|
options:
|
||||||
|
- name: ndots
|
||||||
|
value: {{ .Values.services.apps.ndots | quote }}
|
||||||
|
{{ end }}
|
||||||
status: {}
|
status: {}
|
||||||
|
|
|
@ -227,6 +227,7 @@ spec:
|
||||||
resources:
|
resources:
|
||||||
{{- toYaml . | nindent 10 }}
|
{{- toYaml . | nindent 10 }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ if .Values.services.automationWorkers.command }}
|
||||||
command:
|
command:
|
||||||
{{- toYaml .Values.services.automationWorkers.command | nindent 10 }}
|
{{- toYaml .Values.services.automationWorkers.command | nindent 10 }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -251,6 +252,11 @@ spec:
|
||||||
{{ end }}
|
{{ end }}
|
||||||
restartPolicy: Always
|
restartPolicy: Always
|
||||||
serviceAccountName: ""
|
serviceAccountName: ""
|
||||||
{{ if .Values.services.automationWorkers.command }}}
|
{{ if .Values.services.automationWorkers.ndots }}
|
||||||
|
dnsConfig:
|
||||||
|
options:
|
||||||
|
- name: ndots
|
||||||
|
value: {{ .Values.services.automationWorkers.ndots | quote }}
|
||||||
|
{{ end }}
|
||||||
status: {}
|
status: {}
|
||||||
{{- end }}
|
{{- end }}
|
|
@ -109,4 +109,10 @@ spec:
|
||||||
{{- toYaml .Values.services.proxy.args | nindent 8 }}
|
{{- toYaml .Values.services.proxy.args | nindent 8 }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
volumes:
|
volumes:
|
||||||
|
{{ if .Values.services.proxy.ndots }}
|
||||||
|
dnsConfig:
|
||||||
|
options:
|
||||||
|
- name: ndots
|
||||||
|
value: {{ .Values.services.proxy.ndots | quote }}
|
||||||
|
{{ end }}
|
||||||
status: {}
|
status: {}
|
||||||
|
|
|
@ -238,4 +238,10 @@ spec:
|
||||||
{{ end }}
|
{{ end }}
|
||||||
restartPolicy: Always
|
restartPolicy: Always
|
||||||
serviceAccountName: ""
|
serviceAccountName: ""
|
||||||
|
{{ if .Values.services.worker.ndots }}
|
||||||
|
dnsConfig:
|
||||||
|
options:
|
||||||
|
- name: ndots
|
||||||
|
value: {{ .Values.services.worker.ndots | quote }}
|
||||||
|
{{ end }}
|
||||||
status: {}
|
status: {}
|
||||||
|
|
|
@ -90,7 +90,7 @@ Component libraries are collections of components as well as the definition of t
|
||||||
|
|
||||||
#### 1. Prerequisites
|
#### 1. Prerequisites
|
||||||
|
|
||||||
- NodeJS version `18.x.x`
|
- NodeJS version `20.x.x`
|
||||||
- Python version `3.x`
|
- Python version `3.x`
|
||||||
|
|
||||||
### Using asdf (recommended)
|
### Using asdf (recommended)
|
||||||
|
|
|
@ -76,6 +76,6 @@ done
|
||||||
|
|
||||||
# CouchDB needs the `_users` and `_replicator` databases to exist before it will
|
# CouchDB needs the `_users` and `_replicator` databases to exist before it will
|
||||||
# function correctly, so we create them here.
|
# function correctly, so we create them here.
|
||||||
curl -X PUT http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@localhost:5984/_users
|
curl -X PUT -u "${COUCHDB_USER}:${COUCHDB_PASSWORD}" http://localhost:5984/_users
|
||||||
curl -X PUT http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@localhost:5984/_replicator
|
curl -X PUT -u "${COUCHDB_USER}:${COUCHDB_PASSWORD}" http://localhost:5984/_replicator
|
||||||
sleep infinity
|
sleep infinity
|
|
@ -26,7 +26,7 @@ services:
|
||||||
BB_ADMIN_USER_EMAIL: ${BB_ADMIN_USER_EMAIL}
|
BB_ADMIN_USER_EMAIL: ${BB_ADMIN_USER_EMAIL}
|
||||||
BB_ADMIN_USER_PASSWORD: ${BB_ADMIN_USER_PASSWORD}
|
BB_ADMIN_USER_PASSWORD: ${BB_ADMIN_USER_PASSWORD}
|
||||||
PLUGINS_DIR: ${PLUGINS_DIR}
|
PLUGINS_DIR: ${PLUGINS_DIR}
|
||||||
OFFLINE_MODE: ${OFFLINE_MODE}
|
OFFLINE_MODE: ${OFFLINE_MODE:-}
|
||||||
depends_on:
|
depends_on:
|
||||||
- worker-service
|
- worker-service
|
||||||
- redis-service
|
- redis-service
|
||||||
|
@ -53,7 +53,7 @@ services:
|
||||||
INTERNAL_API_KEY: ${INTERNAL_API_KEY}
|
INTERNAL_API_KEY: ${INTERNAL_API_KEY}
|
||||||
REDIS_URL: redis-service:6379
|
REDIS_URL: redis-service:6379
|
||||||
REDIS_PASSWORD: ${REDIS_PASSWORD}
|
REDIS_PASSWORD: ${REDIS_PASSWORD}
|
||||||
OFFLINE_MODE: ${OFFLINE_MODE}
|
OFFLINE_MODE: ${OFFLINE_MODE:-}
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis-service
|
- redis-service
|
||||||
- minio-service
|
- minio-service
|
||||||
|
@ -109,7 +109,7 @@ services:
|
||||||
redis-service:
|
redis-service:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
image: redis
|
image: redis
|
||||||
command: redis-server --requirepass ${REDIS_PASSWORD}
|
command: redis-server --requirepass "${REDIS_PASSWORD}"
|
||||||
volumes:
|
volumes:
|
||||||
- redis_data:/data
|
- redis_data:/data
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM node:18-slim as build
|
FROM node:20-slim as build
|
||||||
|
|
||||||
# install node-gyp dependencies
|
# install node-gyp dependencies
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends g++ make python3 jq
|
RUN apt-get update && apt-get install -y --no-install-recommends g++ make python3 jq
|
||||||
|
@ -42,7 +42,7 @@ COPY packages/string-templates packages/string-templates
|
||||||
FROM budibase/couchdb as runner
|
FROM budibase/couchdb as runner
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
ENV TARGETARCH $TARGETARCH
|
ENV TARGETARCH $TARGETARCH
|
||||||
ENV NODE_MAJOR 18
|
ENV NODE_MAJOR 20
|
||||||
#TARGETBUILD can be set to single (for single docker image) or aas (for azure app service)
|
#TARGETBUILD can be set to single (for single docker image) or aas (for azure app service)
|
||||||
# e.g. docker build --build-arg TARGETBUILD=aas ....
|
# e.g. docker build --build-arg TARGETBUILD=aas ....
|
||||||
ARG TARGETBUILD=single
|
ARG TARGETBUILD=single
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "2.13.51",
|
"version": "2.14.7",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*",
|
"packages/*",
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
"@babel/eslint-parser": "^7.22.5",
|
"@babel/eslint-parser": "^7.22.5",
|
||||||
"@babel/preset-env": "^7.22.5",
|
"@babel/preset-env": "^7.22.5",
|
||||||
"@esbuild-plugins/tsconfig-paths": "^0.1.2",
|
"@esbuild-plugins/tsconfig-paths": "^0.1.2",
|
||||||
|
"@types/node": "20.10.0",
|
||||||
"@typescript-eslint/parser": "6.9.0",
|
"@typescript-eslint/parser": "6.9.0",
|
||||||
"esbuild": "^0.18.17",
|
"esbuild": "^0.18.17",
|
||||||
"esbuild-node-externals": "^1.8.0",
|
"esbuild-node-externals": "^1.8.0",
|
||||||
|
@ -99,7 +100,7 @@
|
||||||
"@budibase/types": "0.0.0"
|
"@budibase/types": "0.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <19.0.0"
|
"node": ">=20.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {}
|
"dependencies": {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit c1a53bb2f4cafcb4c55ad7181146617b449907f2
|
Subproject commit 319c8499e7c3d33fbb96cf4d73a922690709686c
|
|
@ -65,7 +65,6 @@
|
||||||
"@types/cookies": "0.7.8",
|
"@types/cookies": "0.7.8",
|
||||||
"@types/jest": "29.5.5",
|
"@types/jest": "29.5.5",
|
||||||
"@types/lodash": "4.14.200",
|
"@types/lodash": "4.14.200",
|
||||||
"@types/node": "18.17.0",
|
|
||||||
"@types/node-fetch": "2.6.4",
|
"@types/node-fetch": "2.6.4",
|
||||||
"@types/pouchdb": "6.4.0",
|
"@types/pouchdb": "6.4.0",
|
||||||
"@types/redlock": "4.0.3",
|
"@types/redlock": "4.0.3",
|
||||||
|
|
|
@ -134,7 +134,7 @@ export async function doInContext(appId: string, task: any): Promise<any> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function doInTenant<T>(
|
export async function doInTenant<T>(
|
||||||
tenantId: string | null,
|
tenantId: string | undefined,
|
||||||
task: () => T
|
task: () => T
|
||||||
): Promise<T> {
|
): Promise<T> {
|
||||||
// make sure default always selected in single tenancy
|
// make sure default always selected in single tenancy
|
||||||
|
|
|
@ -19,6 +19,8 @@ import { WriteStream, ReadStream } from "fs"
|
||||||
import { newid } from "../../docIds/newid"
|
import { newid } from "../../docIds/newid"
|
||||||
import { DDInstrumentedDatabase } from "../instrumentation"
|
import { DDInstrumentedDatabase } from "../instrumentation"
|
||||||
|
|
||||||
|
const DATABASE_NOT_FOUND = "Database does not exist."
|
||||||
|
|
||||||
function buildNano(couchInfo: { url: string; cookie: string }) {
|
function buildNano(couchInfo: { url: string; cookie: string }) {
|
||||||
return Nano({
|
return Nano({
|
||||||
url: couchInfo.url,
|
url: couchInfo.url,
|
||||||
|
@ -31,6 +33,8 @@ function buildNano(couchInfo: { url: string; cookie: string }) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DBCall<T> = () => Promise<T>
|
||||||
|
|
||||||
export function DatabaseWithConnection(
|
export function DatabaseWithConnection(
|
||||||
dbName: string,
|
dbName: string,
|
||||||
connection: string,
|
connection: string,
|
||||||
|
@ -78,7 +82,11 @@ export class DatabaseImpl implements Database {
|
||||||
return this.instanceNano || DatabaseImpl.nano
|
return this.instanceNano || DatabaseImpl.nano
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkSetup() {
|
private getDb() {
|
||||||
|
return this.nano().db.use(this.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
private async checkAndCreateDb() {
|
||||||
let shouldCreate = !this.pouchOpts?.skip_setup
|
let shouldCreate = !this.pouchOpts?.skip_setup
|
||||||
// check exists in a lightweight fashion
|
// check exists in a lightweight fashion
|
||||||
let exists = await this.exists()
|
let exists = await this.exists()
|
||||||
|
@ -95,14 +103,22 @@ export class DatabaseImpl implements Database {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.nano().db.use(this.name)
|
return this.getDb()
|
||||||
}
|
}
|
||||||
|
|
||||||
private async updateOutput(fnc: any) {
|
// this function fetches the DB and handles if DB creation is needed
|
||||||
|
private async performCall<T>(
|
||||||
|
call: (db: Nano.DocumentScope<any>) => Promise<DBCall<T>> | DBCall<T>
|
||||||
|
): Promise<any> {
|
||||||
|
const db = this.getDb()
|
||||||
|
const fnc = await call(db)
|
||||||
try {
|
try {
|
||||||
return await fnc()
|
return await fnc()
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
if (err.statusCode) {
|
if (err.statusCode === 404 && err.reason === DATABASE_NOT_FOUND) {
|
||||||
|
await this.checkAndCreateDb()
|
||||||
|
return await this.performCall(call)
|
||||||
|
} else if (err.statusCode) {
|
||||||
err.status = err.statusCode
|
err.status = err.statusCode
|
||||||
}
|
}
|
||||||
throw err
|
throw err
|
||||||
|
@ -110,11 +126,12 @@ export class DatabaseImpl implements Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
async get<T extends Document>(id?: string): Promise<T> {
|
async get<T extends Document>(id?: string): Promise<T> {
|
||||||
const db = await this.checkSetup()
|
return this.performCall(db => {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
throw new Error("Unable to get doc without a valid _id.")
|
throw new Error("Unable to get doc without a valid _id.")
|
||||||
}
|
}
|
||||||
return this.updateOutput(() => db.get(id))
|
return () => db.get(id)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMultiple<T extends Document>(
|
async getMultiple<T extends Document>(
|
||||||
|
@ -147,22 +164,23 @@ export class DatabaseImpl implements Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
async remove(idOrDoc: string | Document, rev?: string) {
|
async remove(idOrDoc: string | Document, rev?: string) {
|
||||||
const db = await this.checkSetup()
|
return this.performCall(db => {
|
||||||
let _id: string
|
let _id: string
|
||||||
let _rev: string
|
let _rev: string
|
||||||
|
|
||||||
if (isDocument(idOrDoc)) {
|
if (isDocument(idOrDoc)) {
|
||||||
_id = idOrDoc._id!
|
_id = idOrDoc._id!
|
||||||
_rev = idOrDoc._rev!
|
_rev = idOrDoc._rev!
|
||||||
} else {
|
} else {
|
||||||
_id = idOrDoc
|
_id = idOrDoc
|
||||||
_rev = rev!
|
_rev = rev!
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_id || !_rev) {
|
if (!_id || !_rev) {
|
||||||
throw new Error("Unable to remove doc without a valid _id and _rev.")
|
throw new Error("Unable to remove doc without a valid _id and _rev.")
|
||||||
}
|
}
|
||||||
return this.updateOutput(() => db.destroy(_id, _rev))
|
return () => db.destroy(_id, _rev)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async post(document: AnyDocument, opts?: DatabasePutOpts) {
|
async post(document: AnyDocument, opts?: DatabasePutOpts) {
|
||||||
|
@ -176,45 +194,49 @@ export class DatabaseImpl implements Database {
|
||||||
if (!document._id) {
|
if (!document._id) {
|
||||||
throw new Error("Cannot store document without _id field.")
|
throw new Error("Cannot store document without _id field.")
|
||||||
}
|
}
|
||||||
const db = await this.checkSetup()
|
return this.performCall(async db => {
|
||||||
if (!document.createdAt) {
|
if (!document.createdAt) {
|
||||||
document.createdAt = new Date().toISOString()
|
document.createdAt = new Date().toISOString()
|
||||||
}
|
}
|
||||||
document.updatedAt = new Date().toISOString()
|
document.updatedAt = new Date().toISOString()
|
||||||
if (opts?.force && document._id) {
|
if (opts?.force && document._id) {
|
||||||
try {
|
try {
|
||||||
const existing = await this.get(document._id)
|
const existing = await this.get(document._id)
|
||||||
if (existing) {
|
if (existing) {
|
||||||
document._rev = existing._rev
|
document._rev = existing._rev
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
if (err.status !== 404) {
|
if (err.status !== 404) {
|
||||||
throw err
|
throw err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return () => db.insert(document)
|
||||||
return this.updateOutput(() => db.insert(document))
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async bulkDocs(documents: AnyDocument[]) {
|
async bulkDocs(documents: AnyDocument[]) {
|
||||||
const db = await this.checkSetup()
|
return this.performCall(db => {
|
||||||
return this.updateOutput(() => db.bulk({ docs: documents }))
|
return () => db.bulk({ docs: documents })
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async allDocs<T extends Document>(
|
async allDocs<T extends Document>(
|
||||||
params: DatabaseQueryOpts
|
params: DatabaseQueryOpts
|
||||||
): Promise<AllDocsResponse<T>> {
|
): Promise<AllDocsResponse<T>> {
|
||||||
const db = await this.checkSetup()
|
return this.performCall(db => {
|
||||||
return this.updateOutput(() => db.list(params))
|
return () => db.list(params)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async query<T extends Document>(
|
async query<T extends Document>(
|
||||||
viewName: string,
|
viewName: string,
|
||||||
params: DatabaseQueryOpts
|
params: DatabaseQueryOpts
|
||||||
): Promise<AllDocsResponse<T>> {
|
): Promise<AllDocsResponse<T>> {
|
||||||
const db = await this.checkSetup()
|
return this.performCall(db => {
|
||||||
const [database, view] = viewName.split("/")
|
const [database, view] = viewName.split("/")
|
||||||
return this.updateOutput(() => db.view(database, view, params))
|
return () => db.view(database, view, params)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async destroy() {
|
async destroy() {
|
||||||
|
@ -231,8 +253,9 @@ export class DatabaseImpl implements Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
async compact() {
|
async compact() {
|
||||||
const db = await this.checkSetup()
|
return this.performCall(db => {
|
||||||
return this.updateOutput(() => db.compact())
|
return () => db.compact()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// All below functions are in-frequently called, just utilise PouchDB
|
// All below functions are in-frequently called, just utilise PouchDB
|
||||||
|
|
|
@ -31,13 +31,6 @@ export class DDInstrumentedDatabase implements Database {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
checkSetup(): Promise<DocumentScope<any>> {
|
|
||||||
return tracer.trace("db.checkSetup", span => {
|
|
||||||
span?.addTags({ db_name: this.name })
|
|
||||||
return this.db.checkSetup()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
get<T extends Document>(id?: string | undefined): Promise<T> {
|
get<T extends Document>(id?: string | undefined): Promise<T> {
|
||||||
return tracer.trace("db.get", span => {
|
return tracer.trace("db.get", span => {
|
||||||
span?.addTags({ db_name: this.name, doc_id: id })
|
span?.addTags({ db_name: this.name, doc_id: id })
|
||||||
|
|
|
@ -166,6 +166,8 @@ const environment = {
|
||||||
DISABLE_JWT_WARNING: process.env.DISABLE_JWT_WARNING,
|
DISABLE_JWT_WARNING: process.env.DISABLE_JWT_WARNING,
|
||||||
BLACKLIST_IPS: process.env.BLACKLIST_IPS,
|
BLACKLIST_IPS: process.env.BLACKLIST_IPS,
|
||||||
SERVICE_TYPE: "unknown",
|
SERVICE_TYPE: "unknown",
|
||||||
|
PASSWORD_MIN_LENGTH: process.env.PASSWORD_MIN_LENGTH,
|
||||||
|
PASSWORD_MAX_LENGTH: process.env.PASSWORD_MAX_LENGTH,
|
||||||
/**
|
/**
|
||||||
* Enable to allow an admin user to login using a password.
|
* Enable to allow an admin user to login using a password.
|
||||||
* This can be useful to prevent lockout when configuring SSO.
|
* This can be useful to prevent lockout when configuring SSO.
|
||||||
|
|
|
@ -33,6 +33,7 @@ export * as docUpdates from "./docUpdates"
|
||||||
export * from "./utils/Duration"
|
export * from "./utils/Duration"
|
||||||
export { SearchParams } from "./db"
|
export { SearchParams } from "./db"
|
||||||
export * as docIds from "./docIds"
|
export * as docIds from "./docIds"
|
||||||
|
export * as security from "./security"
|
||||||
// Add context to tenancy for backwards compatibility
|
// Add context to tenancy for backwards compatibility
|
||||||
// only do this for external usages to prevent internal
|
// only do this for external usages to prevent internal
|
||||||
// circular dependencies
|
// circular dependencies
|
||||||
|
|
|
@ -15,6 +15,7 @@ import * as identity from "../context/identity"
|
||||||
import env from "../environment"
|
import env from "../environment"
|
||||||
import { Ctx, EndpointMatcher, SessionCookie } from "@budibase/types"
|
import { Ctx, EndpointMatcher, SessionCookie } from "@budibase/types"
|
||||||
import { InvalidAPIKeyError, ErrorCode } from "../errors"
|
import { InvalidAPIKeyError, ErrorCode } from "../errors"
|
||||||
|
import tracer from "dd-trace"
|
||||||
|
|
||||||
const ONE_MINUTE = env.SESSION_UPDATE_PERIOD
|
const ONE_MINUTE = env.SESSION_UPDATE_PERIOD
|
||||||
? parseInt(env.SESSION_UPDATE_PERIOD)
|
? parseInt(env.SESSION_UPDATE_PERIOD)
|
||||||
|
@ -166,6 +167,16 @@ export default function (
|
||||||
if (!authenticated) {
|
if (!authenticated) {
|
||||||
authenticated = false
|
authenticated = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (user) {
|
||||||
|
tracer.setUser({
|
||||||
|
id: user?._id,
|
||||||
|
tenantId: user?.tenantId,
|
||||||
|
budibaseAccess: user?.budibaseAccess,
|
||||||
|
status: user?.status,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// isAuthenticated is a function, so use a variable to be able to check authed state
|
// isAuthenticated is a function, so use a variable to be able to check authed state
|
||||||
finalise(ctx, { authenticated, user, internal, version, publicEndpoint })
|
finalise(ctx, { authenticated, user, internal, version, publicEndpoint })
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ import Redlock from "redlock"
|
||||||
import { getLockClient } from "./init"
|
import { getLockClient } from "./init"
|
||||||
import { LockOptions, LockType } from "@budibase/types"
|
import { LockOptions, LockType } from "@budibase/types"
|
||||||
import * as context from "../context"
|
import * as context from "../context"
|
||||||
import { logWarn } from "../logging"
|
|
||||||
import { utils } from "@budibase/shared-core"
|
import { utils } from "@budibase/shared-core"
|
||||||
import { Duration } from "../utils"
|
import { Duration } from "../utils"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
import env from "../environment"
|
||||||
|
|
||||||
|
export const PASSWORD_MIN_LENGTH = +(env.PASSWORD_MIN_LENGTH || 8)
|
||||||
|
export const PASSWORD_MAX_LENGTH = +(env.PASSWORD_MAX_LENGTH || 512)
|
||||||
|
|
||||||
|
export function validatePassword(
|
||||||
|
password: string
|
||||||
|
): { valid: true } | { valid: false; error: string } {
|
||||||
|
if (!password || password.length < PASSWORD_MIN_LENGTH) {
|
||||||
|
return {
|
||||||
|
valid: false,
|
||||||
|
error: `Password invalid. Minimum ${PASSWORD_MIN_LENGTH} characters.`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (password.length > PASSWORD_MAX_LENGTH) {
|
||||||
|
return {
|
||||||
|
valid: false,
|
||||||
|
error: `Password invalid. Maximum ${PASSWORD_MAX_LENGTH} characters.`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { valid: true }
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
export * from "./auth"
|
|
@ -0,0 +1,45 @@
|
||||||
|
import { generator } from "../../../tests"
|
||||||
|
import { PASSWORD_MAX_LENGTH, validatePassword } from "../auth"
|
||||||
|
|
||||||
|
describe("auth", () => {
|
||||||
|
describe("validatePassword", () => {
|
||||||
|
it("a valid password returns successful", () => {
|
||||||
|
expect(validatePassword("password")).toEqual({ valid: true })
|
||||||
|
})
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
["undefined", undefined],
|
||||||
|
["null", null],
|
||||||
|
["empty", ""],
|
||||||
|
])("%s returns unsuccessful", (_, password) => {
|
||||||
|
expect(validatePassword(password as string)).toEqual({
|
||||||
|
valid: false,
|
||||||
|
error: "Password invalid. Minimum 8 characters.",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
generator.word({ length: PASSWORD_MAX_LENGTH }),
|
||||||
|
generator.paragraph().substring(0, PASSWORD_MAX_LENGTH),
|
||||||
|
])(`can use passwords up to 512 characters in length`, password => {
|
||||||
|
expect(validatePassword(password)).toEqual({
|
||||||
|
valid: true,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
generator.word({ length: PASSWORD_MAX_LENGTH + 1 }),
|
||||||
|
generator
|
||||||
|
.paragraph({ sentences: 50 })
|
||||||
|
.substring(0, PASSWORD_MAX_LENGTH + 1),
|
||||||
|
])(
|
||||||
|
`passwords cannot have more than ${PASSWORD_MAX_LENGTH} characters`,
|
||||||
|
password => {
|
||||||
|
expect(validatePassword(password)).toEqual({
|
||||||
|
valid: false,
|
||||||
|
error: "Password invalid. Maximum 512 characters.",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
|
@ -39,7 +39,7 @@ const ALL_STRATEGIES = Object.values(TenantResolutionStrategy)
|
||||||
export const getTenantIDFromCtx = (
|
export const getTenantIDFromCtx = (
|
||||||
ctx: BBContext,
|
ctx: BBContext,
|
||||||
opts: GetTenantIdOptions
|
opts: GetTenantIdOptions
|
||||||
): string | null => {
|
): string | undefined => {
|
||||||
// exit early if not multi-tenant
|
// exit early if not multi-tenant
|
||||||
if (!isMultiTenant()) {
|
if (!isMultiTenant()) {
|
||||||
return DEFAULT_TENANT_ID
|
return DEFAULT_TENANT_ID
|
||||||
|
@ -144,5 +144,5 @@ export const getTenantIDFromCtx = (
|
||||||
ctx.throw(403, "Tenant id not set")
|
ctx.throw(403, "Tenant id not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,12 +157,12 @@ describe("getTenantIDFromCtx", () => {
|
||||||
TenantResolutionStrategy.PATH,
|
TenantResolutionStrategy.PATH,
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
expect(getTenantIDFromCtx(ctx, mockOpts)).toBeNull()
|
expect(getTenantIDFromCtx(ctx, mockOpts)).toBeUndefined()
|
||||||
expect(ctx.throw).toBeCalledTimes(1)
|
expect(ctx.throw).toBeCalledTimes(1)
|
||||||
expect(ctx.throw).toBeCalledWith(403, "Tenant id not set")
|
expect(ctx.throw).toBeCalledWith(403, "Tenant id not set")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("returns null if allowNoTenant is true", () => {
|
it("returns undefined if allowNoTenant is true", () => {
|
||||||
const ctx = createCtx({})
|
const ctx = createCtx({})
|
||||||
mockOpts = {
|
mockOpts = {
|
||||||
allowNoTenant: true,
|
allowNoTenant: true,
|
||||||
|
@ -172,7 +172,7 @@ describe("getTenantIDFromCtx", () => {
|
||||||
TenantResolutionStrategy.PATH,
|
TenantResolutionStrategy.PATH,
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
expect(getTenantIDFromCtx(ctx, mockOpts)).toBeNull()
|
expect(getTenantIDFromCtx(ctx, mockOpts)).toBeUndefined()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ export class ExecutionTimeTracker {
|
||||||
return this.totalTimeMs
|
return this.totalTimeMs
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkLimit() {
|
checkLimit() {
|
||||||
if (this.totalTimeMs > this.limitMs) {
|
if (this.totalTimeMs > this.limitMs) {
|
||||||
throw new ExecutionTimeoutError(
|
throw new ExecutionTimeoutError(
|
||||||
`Execution time limit of ${this.limitMs}ms exceeded: ${this.totalTimeMs}ms`
|
`Execution time limit of ${this.limitMs}ms exceeded: ${this.totalTimeMs}ms`
|
||||||
|
|
|
@ -27,6 +27,7 @@ import {
|
||||||
} from "./utils"
|
} from "./utils"
|
||||||
import { searchExistingEmails } from "./lookup"
|
import { searchExistingEmails } from "./lookup"
|
||||||
import { hash } from "../utils"
|
import { hash } from "../utils"
|
||||||
|
import { validatePassword } from "../security"
|
||||||
|
|
||||||
type QuotaUpdateFn = (
|
type QuotaUpdateFn = (
|
||||||
change: number,
|
change: number,
|
||||||
|
@ -43,6 +44,12 @@ type GroupFns = {
|
||||||
getBulk: GroupGetFn
|
getBulk: GroupGetFn
|
||||||
getGroupBuilderAppIds: GroupBuildersFn
|
getGroupBuilderAppIds: GroupBuildersFn
|
||||||
}
|
}
|
||||||
|
type CreateAdminUserOpts = {
|
||||||
|
ssoId?: string
|
||||||
|
hashPassword?: boolean
|
||||||
|
requirePassword?: boolean
|
||||||
|
skipPasswordValidation?: boolean
|
||||||
|
}
|
||||||
type FeatureFns = { isSSOEnforced: FeatureFn; isAppBuildersEnabled: FeatureFn }
|
type FeatureFns = { isSSOEnforced: FeatureFn; isAppBuildersEnabled: FeatureFn }
|
||||||
|
|
||||||
const bulkDeleteProcessing = async (dbUser: User) => {
|
const bulkDeleteProcessing = async (dbUser: User) => {
|
||||||
|
@ -110,6 +117,14 @@ export class UserDB {
|
||||||
if (await UserDB.isPreventPasswordActions(user, account)) {
|
if (await UserDB.isPreventPasswordActions(user, account)) {
|
||||||
throw new HTTPError("Password change is disabled for this user", 400)
|
throw new HTTPError("Password change is disabled for this user", 400)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!opts.skipPasswordValidation) {
|
||||||
|
const passwordValidation = validatePassword(password)
|
||||||
|
if (!passwordValidation.valid) {
|
||||||
|
throw new HTTPError(passwordValidation.error, 400)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
hashedPassword = opts.hashPassword ? await hash(password) : password
|
hashedPassword = opts.hashPassword ? await hash(password) : password
|
||||||
} else if (dbUser) {
|
} else if (dbUser) {
|
||||||
hashedPassword = dbUser.password
|
hashedPassword = dbUser.password
|
||||||
|
@ -482,7 +497,7 @@ export class UserDB {
|
||||||
email: string,
|
email: string,
|
||||||
password: string,
|
password: string,
|
||||||
tenantId: string,
|
tenantId: string,
|
||||||
opts?: { ssoId?: string; hashPassword?: boolean; requirePassword?: boolean }
|
opts?: CreateAdminUserOpts
|
||||||
) {
|
) {
|
||||||
const user: User = {
|
const user: User = {
|
||||||
email: email,
|
email: email,
|
||||||
|
@ -506,6 +521,7 @@ export class UserDB {
|
||||||
return await UserDB.save(user, {
|
return await UserDB.save(user, {
|
||||||
hashPassword: opts?.hashPassword,
|
hashPassword: opts?.hashPassword,
|
||||||
requirePassword: opts?.requirePassword,
|
requirePassword: opts?.requirePassword,
|
||||||
|
skipPasswordValidation: opts?.skipPasswordValidation,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@ export async function resolveAppUrl(ctx: Ctx) {
|
||||||
const appUrl = ctx.path.split("/")[2]
|
const appUrl = ctx.path.split("/")[2]
|
||||||
let possibleAppUrl = `/${appUrl.toLowerCase()}`
|
let possibleAppUrl = `/${appUrl.toLowerCase()}`
|
||||||
|
|
||||||
let tenantId: string | null = context.getTenantId()
|
let tenantId: string | undefined = context.getTenantId()
|
||||||
if (env.MULTI_TENANCY) {
|
if (!env.isDev() && env.MULTI_TENANCY) {
|
||||||
// always use the tenant id from the subdomain in multi tenancy
|
// always use the tenant id from the subdomain in multi tenancy
|
||||||
// this ensures the logged-in user tenant id doesn't overwrite
|
// this ensures the logged-in user tenant id doesn't overwrite
|
||||||
// e.g. in the case of viewing a public app while already logged-in to another tenant
|
// e.g. in the case of viewing a public app while already logged-in to another tenant
|
||||||
|
@ -41,7 +41,7 @@ export async function resolveAppUrl(ctx: Ctx) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// search prod apps for a url that matches
|
// search prod apps for an url that matches
|
||||||
const apps: App[] = await context.doInTenant(
|
const apps: App[] = await context.doInTenant(
|
||||||
tenantId,
|
tenantId,
|
||||||
() => getAllApps({ dev: false }) as Promise<App[]>
|
() => getAllApps({ dev: false }) as Promise<App[]>
|
||||||
|
|
|
@ -21,7 +21,7 @@ export const user = (userProps?: Partial<Omit<User, "userId">>): User => {
|
||||||
_id: userId,
|
_id: userId,
|
||||||
userId,
|
userId,
|
||||||
email: newEmail(),
|
email: newEmail(),
|
||||||
password: "test",
|
password: "password",
|
||||||
roles: { app_test: "admin" },
|
roles: { app_test: "admin" },
|
||||||
firstName: generator.first(),
|
firstName: generator.first(),
|
||||||
lastName: generator.last(),
|
lastName: generator.last(),
|
||||||
|
|
|
@ -130,5 +130,6 @@
|
||||||
max-width: 150px;
|
max-width: 150px;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
var(--spacing-xl);
|
var(--spacing-xl);
|
||||||
}
|
}
|
||||||
.property-panel.no-title {
|
.property-panel.no-title {
|
||||||
padding: var(--spacing-xl);
|
padding-top: var(--spacing-xl);
|
||||||
}
|
}
|
||||||
|
|
||||||
.show {
|
.show {
|
||||||
|
|
|
@ -51,15 +51,13 @@
|
||||||
margin-top: var(--spectrum-global-dimension-size-75);
|
margin-top: var(--spectrum-global-dimension-size-75);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.helpText :global(svg) {
|
.helpText :global(svg) {
|
||||||
width: 14px;
|
width: 13px;
|
||||||
color: var(--grey-5);
|
color: var(--spectrum-global-color-gray-600);
|
||||||
margin-right: 6px;
|
margin-right: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.helpText span {
|
.helpText span {
|
||||||
color: var(--grey-7);
|
color: var(--spectrum-global-color-gray-800);
|
||||||
font-size: var(--spectrum-global-dimension-font-size-75);
|
font-size: var(--spectrum-global-dimension-font-size-75);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
// Ensure the value is updated if the value prop changes outside the editor's
|
// Ensure the value is updated if the value prop changes outside the editor's
|
||||||
// control
|
// control
|
||||||
$: checkValue(value)
|
$: checkValue(value)
|
||||||
$: mde?.codemirror.on("change", debouncedUpdate)
|
$: mde?.codemirror.on("blur", update)
|
||||||
$: if (readonly || disabled) {
|
$: if (readonly || disabled) {
|
||||||
mde?.togglePreview()
|
mde?.togglePreview()
|
||||||
}
|
}
|
||||||
|
@ -30,21 +30,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const debounce = (fn, interval) => {
|
|
||||||
let timeout
|
|
||||||
return () => {
|
|
||||||
clearTimeout(timeout)
|
|
||||||
timeout = setTimeout(fn, interval)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const update = () => {
|
const update = () => {
|
||||||
latestValue = mde.value()
|
latestValue = mde.value()
|
||||||
dispatch("change", latestValue)
|
dispatch("change", latestValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debounce the update function to avoid spamming it constantly
|
|
||||||
const debouncedUpdate = debounce(update, 250)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#key height}
|
{#key height}
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
loading = false
|
loading = false
|
||||||
}
|
}
|
||||||
|
|
||||||
async function confirm() {
|
export async function confirm() {
|
||||||
loading = true
|
loading = true
|
||||||
if (!onConfirm || (await onConfirm()) !== keepOpen) {
|
if (!onConfirm || (await onConfirm()) !== keepOpen) {
|
||||||
hide()
|
hide()
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
} from "@budibase/frontend-core"
|
} from "@budibase/frontend-core"
|
||||||
import { store } from "./builderStore"
|
import { store } from "./builderStore"
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { auth } from "./stores/portal"
|
import { auth, navigation } from "./stores/portal"
|
||||||
|
|
||||||
export const API = createAPIClient({
|
export const API = createAPIClient({
|
||||||
attachHeaders: headers => {
|
attachHeaders: headers => {
|
||||||
|
@ -45,4 +45,15 @@ export const API = createAPIClient({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onMigrationDetected: appId => {
|
||||||
|
const updatingUrl = `/builder/app/updating/${appId}`
|
||||||
|
|
||||||
|
if (window.location.pathname === updatingUrl) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
get(navigation).goto(
|
||||||
|
`${updatingUrl}?returnUrl=${encodeURIComponent(window.location.pathname)}`
|
||||||
|
)
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -465,8 +465,8 @@ const filterCategoryByContext = (component, context) => {
|
||||||
const { _component } = component
|
const { _component } = component
|
||||||
if (_component.endsWith("formblock")) {
|
if (_component.endsWith("formblock")) {
|
||||||
if (
|
if (
|
||||||
(component.actionType == "Create" && context.type === "schema") ||
|
(component.actionType === "Create" && context.type === "schema") ||
|
||||||
(component.actionType == "View" && context.type === "form")
|
(component.actionType === "View" && context.type === "form")
|
||||||
) {
|
) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -474,20 +474,21 @@ const filterCategoryByContext = (component, context) => {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enrich binding category information for certain components
|
||||||
const getComponentBindingCategory = (component, context, def) => {
|
const getComponentBindingCategory = (component, context, def) => {
|
||||||
let icon = def.icon
|
let icon = def.icon
|
||||||
let category = component._instanceName
|
let category = component._instanceName
|
||||||
|
|
||||||
if (component._component.endsWith("formblock")) {
|
if (component._component.endsWith("formblock")) {
|
||||||
let contextCategorySuffix = {
|
if (context.type === "form") {
|
||||||
form: "Fields",
|
category = `${component._instanceName} - Fields`
|
||||||
schema: "Row",
|
icon = "Form"
|
||||||
|
} else if (context.type === "schema") {
|
||||||
|
category = `${component._instanceName} - Row`
|
||||||
|
icon = "Data"
|
||||||
}
|
}
|
||||||
category = `${component._instanceName} - ${
|
|
||||||
contextCategorySuffix[context.type]
|
|
||||||
}`
|
|
||||||
icon = context.type === "form" ? "Form" : "Data"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
icon,
|
icon,
|
||||||
category,
|
category,
|
||||||
|
|
|
@ -85,7 +85,6 @@ const INITIAL_FRONTEND_STATE = {
|
||||||
selectedScreenId: null,
|
selectedScreenId: null,
|
||||||
selectedComponentId: null,
|
selectedComponentId: null,
|
||||||
selectedLayoutId: null,
|
selectedLayoutId: null,
|
||||||
hoverComponentId: null,
|
|
||||||
|
|
||||||
// Client state
|
// Client state
|
||||||
selectedComponentInstance: null,
|
selectedComponentInstance: null,
|
||||||
|
@ -93,6 +92,9 @@ const INITIAL_FRONTEND_STATE = {
|
||||||
// Onboarding
|
// Onboarding
|
||||||
onboarding: false,
|
onboarding: false,
|
||||||
tourNodes: null,
|
tourNodes: null,
|
||||||
|
|
||||||
|
// UI state
|
||||||
|
hoveredComponentId: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getFrontendStore = () => {
|
export const getFrontendStore = () => {
|
||||||
|
@ -610,12 +612,12 @@ export const getFrontendStore = () => {
|
||||||
// Use default config if the 'buttons' prop has never been initialised
|
// Use default config if the 'buttons' prop has never been initialised
|
||||||
if (!("buttons" in enrichedComponent)) {
|
if (!("buttons" in enrichedComponent)) {
|
||||||
enrichedComponent["buttons"] =
|
enrichedComponent["buttons"] =
|
||||||
Utils.buildDynamicButtonConfig(enrichedComponent)
|
Utils.buildFormBlockButtonConfig(enrichedComponent)
|
||||||
migrated = true
|
migrated = true
|
||||||
} else if (enrichedComponent["buttons"] == null) {
|
} else if (enrichedComponent["buttons"] == null) {
|
||||||
// Ignore legacy config if 'buttons' has been reset by 'resetOn'
|
// Ignore legacy config if 'buttons' has been reset by 'resetOn'
|
||||||
const { _id, actionType, dataSource } = enrichedComponent
|
const { _id, actionType, dataSource } = enrichedComponent
|
||||||
enrichedComponent["buttons"] = Utils.buildDynamicButtonConfig({
|
enrichedComponent["buttons"] = Utils.buildFormBlockButtonConfig({
|
||||||
_id,
|
_id,
|
||||||
actionType,
|
actionType,
|
||||||
dataSource,
|
dataSource,
|
||||||
|
@ -1289,15 +1291,14 @@ export const getFrontendStore = () => {
|
||||||
const settings = getComponentSettings(component._component)
|
const settings = getComponentSettings(component._component)
|
||||||
const updatedSetting = settings.find(setting => setting.key === name)
|
const updatedSetting = settings.find(setting => setting.key === name)
|
||||||
|
|
||||||
// Can be a single string or array of strings
|
// Reset dependent fields
|
||||||
const resetFields = settings.filter(setting => {
|
settings.forEach(setting => {
|
||||||
return (
|
const needsReset =
|
||||||
name === setting.resetOn ||
|
name === setting.resetOn ||
|
||||||
(Array.isArray(setting.resetOn) && setting.resetOn.includes(name))
|
(Array.isArray(setting.resetOn) && setting.resetOn.includes(name))
|
||||||
)
|
if (needsReset) {
|
||||||
})
|
component[setting.key] = setting.defaultValue || null
|
||||||
resetFields?.forEach(setting => {
|
}
|
||||||
component[setting.key] = null
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -1414,6 +1415,18 @@ export const getFrontendStore = () => {
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
hover: (componentId, notifyClient = true) => {
|
||||||
|
if (componentId === get(store).hoveredComponentId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
store.update(state => {
|
||||||
|
state.hoveredComponentId = componentId
|
||||||
|
return state
|
||||||
|
})
|
||||||
|
if (notifyClient) {
|
||||||
|
store.actions.preview.sendEvent("hover-component", componentId)
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
links: {
|
links: {
|
||||||
save: async (url, title) => {
|
save: async (url, title) => {
|
||||||
|
|
|
@ -152,7 +152,7 @@
|
||||||
{#if isDisabled && !syncAutomationsEnabled && action.stepId === ActionStepID.COLLECT}
|
{#if isDisabled && !syncAutomationsEnabled && action.stepId === ActionStepID.COLLECT}
|
||||||
<div class="tag-color">
|
<div class="tag-color">
|
||||||
<Tags>
|
<Tags>
|
||||||
<Tag icon="LockClosed">Business</Tag>
|
<Tag icon="LockClosed">Premium</Tag>
|
||||||
</Tags>
|
</Tags>
|
||||||
</div>
|
</div>
|
||||||
{:else if isDisabled}
|
{:else if isDisabled}
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
{ label: "False", value: "false" },
|
{ label: "False", value: "false" },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
{:else if schema.type === "array"}
|
{:else if schemaHasOptions(schema) && schema.type === "array"}
|
||||||
<Multiselect
|
<Multiselect
|
||||||
bind:value={value[field]}
|
bind:value={value[field]}
|
||||||
options={schema.constraints.inclusion}
|
options={schema.constraints.inclusion}
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
on:change={e => onChange(e, field)}
|
on:change={e => onChange(e, field)}
|
||||||
useLabel={false}
|
useLabel={false}
|
||||||
/>
|
/>
|
||||||
{:else if ["string", "number", "bigint", "barcodeqr"].includes(schema.type)}
|
{:else if ["string", "number", "bigint", "barcodeqr", "array"].includes(schema.type)}
|
||||||
<svelte:component
|
<svelte:component
|
||||||
this={isTestModal ? ModalBindableInput : DrawerBindableInput}
|
this={isTestModal ? ModalBindableInput : DrawerBindableInput}
|
||||||
panel={AutomationBindingPanel}
|
panel={AutomationBindingPanel}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { string, number } from "yup"
|
import { string, number, object } from "yup"
|
||||||
|
|
||||||
const propertyValidator = type => {
|
const propertyValidator = type => {
|
||||||
if (type === "number") {
|
if (type === "number") {
|
||||||
|
@ -9,6 +9,10 @@ const propertyValidator = type => {
|
||||||
return string().email().nullable()
|
return string().email().nullable()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type === "object") {
|
||||||
|
return object().nullable()
|
||||||
|
}
|
||||||
|
|
||||||
return string().nullable()
|
return string().nullable()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
export let value = ""
|
export let value = ""
|
||||||
export let placeholder = null
|
export let placeholder = null
|
||||||
export let autocompleteEnabled = true
|
export let autocompleteEnabled = true
|
||||||
|
export let autofocus = false
|
||||||
|
|
||||||
// Export a function to expose caret position
|
// Export a function to expose caret position
|
||||||
export const getCaretPosition = () => {
|
export const getCaretPosition = () => {
|
||||||
|
@ -241,6 +242,12 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: {
|
||||||
|
if (autofocus && isEditorInitialised) {
|
||||||
|
editor.focus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$: editorHeight = typeof height === "number" ? `${height}px` : height
|
$: editorHeight = typeof height === "number" ? `${height}px` : height
|
||||||
|
|
||||||
// Init when all elements are ready
|
// Init when all elements are ready
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
export let valid
|
export let valid
|
||||||
export let allowJS = false
|
export let allowJS = false
|
||||||
export let allowHelpers = true
|
export let allowHelpers = true
|
||||||
|
export let autofocusEditor = false
|
||||||
|
|
||||||
const drawerActions = getContext("drawer-actions")
|
const drawerActions = getContext("drawer-actions")
|
||||||
const bindingDrawerActions = getContext("binding-drawer-actions")
|
const bindingDrawerActions = getContext("binding-drawer-actions")
|
||||||
|
@ -199,6 +200,7 @@
|
||||||
]}
|
]}
|
||||||
placeholder=""
|
placeholder=""
|
||||||
height="100%"
|
height="100%"
|
||||||
|
autofocus={autofocusEditor}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="binding-footer">
|
<div class="binding-footer">
|
||||||
|
@ -301,6 +303,7 @@
|
||||||
bind:getCaretPosition
|
bind:getCaretPosition
|
||||||
bind:insertAtPos
|
bind:insertAtPos
|
||||||
height="100%"
|
height="100%"
|
||||||
|
autofocus={autofocusEditor}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="binding-footer">
|
<div class="binding-footer">
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
export let value = ""
|
export let value = ""
|
||||||
export let allowJS = false
|
export let allowJS = false
|
||||||
export let allowHelpers = true
|
export let allowHelpers = true
|
||||||
|
export let autofocusEditor = false
|
||||||
|
|
||||||
$: enrichedBindings = enrichBindings(bindings)
|
$: enrichedBindings = enrichBindings(bindings)
|
||||||
|
|
||||||
|
@ -27,5 +28,6 @@
|
||||||
{value}
|
{value}
|
||||||
{allowJS}
|
{allowJS}
|
||||||
{allowHelpers}
|
{allowHelpers}
|
||||||
|
{autofocusEditor}
|
||||||
on:change
|
on:change
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -44,7 +44,11 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
const onChange = value => {
|
const onChange = value => {
|
||||||
if (type === "link" && value && hasValidLinks(value)) {
|
if (
|
||||||
|
(type === "link" || type === "bb_reference") &&
|
||||||
|
value &&
|
||||||
|
hasValidLinks(value)
|
||||||
|
) {
|
||||||
currentVal = value.split(",")
|
currentVal = value.split(",")
|
||||||
} else if (type === "array" && value && hasValidOptions(value)) {
|
} else if (type === "array" && value && hasValidOptions(value)) {
|
||||||
currentVal = value.split(",")
|
currentVal = value.split(",")
|
||||||
|
@ -95,6 +99,7 @@
|
||||||
date: isValidDate,
|
date: isValidDate,
|
||||||
datetime: isValidDate,
|
datetime: isValidDate,
|
||||||
link: hasValidLinks,
|
link: hasValidLinks,
|
||||||
|
bb_reference: hasValidLinks,
|
||||||
array: hasValidOptions,
|
array: hasValidOptions,
|
||||||
longform: value => !isJSBinding(value),
|
longform: value => !isJSBinding(value),
|
||||||
json: value => !isJSBinding(value),
|
json: value => !isJSBinding(value),
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
const appPrefix = "/app"
|
const appPrefix = "/app"
|
||||||
let touched = false
|
let touched = false
|
||||||
let error
|
let error
|
||||||
|
let modal
|
||||||
|
|
||||||
$: appUrl = screenUrl
|
$: appUrl = screenUrl
|
||||||
? `${window.location.origin}${appPrefix}${screenUrl}`
|
? `${window.location.origin}${appPrefix}${screenUrl}`
|
||||||
|
@ -50,6 +51,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ModalContent
|
<ModalContent
|
||||||
|
bind:this={modal}
|
||||||
size="M"
|
size="M"
|
||||||
title={"Screen details"}
|
title={"Screen details"}
|
||||||
{confirmText}
|
{confirmText}
|
||||||
|
@ -58,15 +60,17 @@
|
||||||
cancelText={"Back"}
|
cancelText={"Back"}
|
||||||
disabled={!screenUrl || error || !touched}
|
disabled={!screenUrl || error || !touched}
|
||||||
>
|
>
|
||||||
<Input
|
<form on:submit|preventDefault={() => modal.confirm()}>
|
||||||
label="Enter a URL for the new screen"
|
<Input
|
||||||
{error}
|
label="Enter a URL for the new screen"
|
||||||
bind:value={screenUrl}
|
{error}
|
||||||
on:change={routeChanged}
|
bind:value={screenUrl}
|
||||||
/>
|
on:change={routeChanged}
|
||||||
<div class="app-server" title={appUrl}>
|
/>
|
||||||
{appUrl}
|
<div class="app-server" title={appUrl}>
|
||||||
</div>
|
{appUrl}
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -25,6 +25,8 @@ import BarButtonList from "./controls/BarButtonList.svelte"
|
||||||
import FieldConfiguration from "./controls/FieldConfiguration/FieldConfiguration.svelte"
|
import FieldConfiguration from "./controls/FieldConfiguration/FieldConfiguration.svelte"
|
||||||
import ButtonConfiguration from "./controls/ButtonConfiguration/ButtonConfiguration.svelte"
|
import ButtonConfiguration from "./controls/ButtonConfiguration/ButtonConfiguration.svelte"
|
||||||
import RelationshipFilterEditor from "./controls/RelationshipFilterEditor.svelte"
|
import RelationshipFilterEditor from "./controls/RelationshipFilterEditor.svelte"
|
||||||
|
import FormStepConfiguration from "./controls/FormStepConfiguration.svelte"
|
||||||
|
import FormStepControls from "components/design/settings/controls/FormStepControls.svelte"
|
||||||
|
|
||||||
const componentMap = {
|
const componentMap = {
|
||||||
text: DrawerBindableInput,
|
text: DrawerBindableInput,
|
||||||
|
@ -51,6 +53,8 @@ const componentMap = {
|
||||||
url: URLSelect,
|
url: URLSelect,
|
||||||
fieldConfiguration: FieldConfiguration,
|
fieldConfiguration: FieldConfiguration,
|
||||||
buttonConfiguration: ButtonConfiguration,
|
buttonConfiguration: ButtonConfiguration,
|
||||||
|
stepConfiguration: FormStepConfiguration,
|
||||||
|
formStepControls: FormStepControls,
|
||||||
columns: ColumnEditor,
|
columns: ColumnEditor,
|
||||||
"columns/basic": BasicColumnEditor,
|
"columns/basic": BasicColumnEditor,
|
||||||
"columns/grid": GridColumnEditor,
|
"columns/grid": GridColumnEditor,
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
$: canAddButtons = max == null || buttonList.length < max
|
$: canAddButtons = max == null || buttonList.length < max
|
||||||
|
|
||||||
const sanitizeValue = val => {
|
const sanitizeValue = val => {
|
||||||
|
if (!Array.isArray(val)) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
return val?.map(button => {
|
return val?.map(button => {
|
||||||
return button._component ? button : buildPseudoInstance(button)
|
return button._component ? button : buildPseudoInstance(button)
|
||||||
})
|
})
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
export let draggable = true
|
export let draggable = true
|
||||||
export let focus
|
export let focus
|
||||||
|
|
||||||
|
let zoneType = generate()
|
||||||
|
|
||||||
let store = writable({
|
let store = writable({
|
||||||
selected: null,
|
selected: null,
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -46,6 +48,7 @@
|
||||||
return {
|
return {
|
||||||
id: listItemKey ? item[listItemKey] : generate(),
|
id: listItemKey ? item[listItemKey] : generate(),
|
||||||
item,
|
item,
|
||||||
|
type: zoneType,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter(item => item.id)
|
.filter(item => item.id)
|
||||||
|
@ -83,6 +86,8 @@
|
||||||
items: draggableItems,
|
items: draggableItems,
|
||||||
dropTargetStyle: { outline: "none" },
|
dropTargetStyle: { outline: "none" },
|
||||||
dragDisabled: !draggable || inactive,
|
dragDisabled: !draggable || inactive,
|
||||||
|
type: zoneType,
|
||||||
|
dropFromOthersDisabled: true,
|
||||||
}}
|
}}
|
||||||
on:finalize={handleFinalize}
|
on:finalize={handleFinalize}
|
||||||
on:consider={updateRowOrder}
|
on:consider={updateRowOrder}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
import { convertOldFieldFormat, getComponentForField } from "./utils"
|
import { convertOldFieldFormat, getComponentForField } from "./utils"
|
||||||
|
|
||||||
export let componentInstance
|
export let componentInstance
|
||||||
|
export let bindings
|
||||||
export let value
|
export let value
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
@ -28,7 +29,9 @@
|
||||||
|
|
||||||
let selectAll = true
|
let selectAll = true
|
||||||
|
|
||||||
$: bindings = getBindableProperties($selectedScreen, componentInstance._id)
|
$: resolvedBindings =
|
||||||
|
bindings || getBindableProperties($selectedScreen, componentInstance._id)
|
||||||
|
|
||||||
$: actionType = componentInstance.actionType
|
$: actionType = componentInstance.actionType
|
||||||
let componentBindings = []
|
let componentBindings = []
|
||||||
|
|
||||||
|
@ -39,7 +42,10 @@
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
$: datasource = getDatasourceForProvider($currentAsset, componentInstance)
|
$: datasource =
|
||||||
|
componentInstance.dataSource ||
|
||||||
|
getDatasourceForProvider($currentAsset, componentInstance)
|
||||||
|
|
||||||
$: resourceId = datasource?.resourceId || datasource?.tableId
|
$: resourceId = datasource?.resourceId || datasource?.tableId
|
||||||
|
|
||||||
$: if (!isEqual(value, cachedValue)) {
|
$: if (!isEqual(value, cachedValue)) {
|
||||||
|
@ -179,7 +185,7 @@
|
||||||
listType={FieldSetting}
|
listType={FieldSetting}
|
||||||
listTypeProps={{
|
listTypeProps={{
|
||||||
componentBindings,
|
componentBindings,
|
||||||
bindings,
|
bindings: resolvedBindings,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
<div class="filter-editor">
|
<div class="filter-editor">
|
||||||
<ActionButton on:click={drawer.show}>{text}</ActionButton>
|
<ActionButton on:click={drawer.show}>{text}</ActionButton>
|
||||||
</div>
|
</div>
|
||||||
<Drawer bind:this={drawer} title="Filtering">
|
<Drawer bind:this={drawer} title="Filtering" on:drawerHide on:drawerShow>
|
||||||
<Button cta slot="buttons" on:click={saveFilter}>Save</Button>
|
<Button cta slot="buttons" on:click={saveFilter}>Save</Button>
|
||||||
<FilterDrawer
|
<FilterDrawer
|
||||||
slot="body"
|
slot="body"
|
||||||
|
|
|
@ -0,0 +1,182 @@
|
||||||
|
<script>
|
||||||
|
import { createEventDispatcher, setContext } from "svelte"
|
||||||
|
import ComponentSettingsSection from "../../../../pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ComponentSettingsSection.svelte"
|
||||||
|
import { getDatasourceForProvider } from "builderStore/dataBinding"
|
||||||
|
import { currentAsset, store } from "builderStore"
|
||||||
|
import { Helpers } from "@budibase/bbui"
|
||||||
|
import { derived, writable } from "svelte/store"
|
||||||
|
import { Utils } from "@budibase/frontend-core"
|
||||||
|
import { cloneDeep, isEqual } from "lodash"
|
||||||
|
|
||||||
|
export let componentInstance
|
||||||
|
export let componentBindings
|
||||||
|
export let value
|
||||||
|
export let bindings
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
const multiStepStore = writable({
|
||||||
|
stepCount: value?.length ?? 0,
|
||||||
|
currentStep: 0,
|
||||||
|
})
|
||||||
|
const currentStep = derived(multiStepStore, state => state.currentStep)
|
||||||
|
const componentType = "@budibase/standard-components/multistepformblockstep"
|
||||||
|
|
||||||
|
let cachedValue
|
||||||
|
let cachedInstance = {}
|
||||||
|
|
||||||
|
$: if (!isEqual(cachedValue, value)) {
|
||||||
|
cachedValue = value
|
||||||
|
}
|
||||||
|
|
||||||
|
$: if (!isEqual(componentInstance, cachedInstance)) {
|
||||||
|
cachedInstance = componentInstance
|
||||||
|
}
|
||||||
|
|
||||||
|
setContext("multi-step-form-block", multiStepStore)
|
||||||
|
|
||||||
|
$: stepCount = cachedValue?.length || 0
|
||||||
|
$: updateStore(stepCount)
|
||||||
|
$: dataSource = getDatasourceForProvider($currentAsset, cachedInstance)
|
||||||
|
$: emitCurrentStep($currentStep)
|
||||||
|
$: stepLabel = getStepLabel($multiStepStore)
|
||||||
|
$: stepDef = getDefinition(stepLabel)
|
||||||
|
$: stepSettings = cachedValue?.[$currentStep] || {}
|
||||||
|
$: defaults = Utils.buildMultiStepFormBlockDefaultProps({
|
||||||
|
_id: cachedInstance._id,
|
||||||
|
stepCount: $multiStepStore.stepCount,
|
||||||
|
currentStep: $multiStepStore.currentStep,
|
||||||
|
actionType: cachedInstance.actionType,
|
||||||
|
dataSource: cachedInstance.dataSource,
|
||||||
|
})
|
||||||
|
$: stepInstance = {
|
||||||
|
_id: Helpers.uuid(),
|
||||||
|
_component: componentType,
|
||||||
|
_instanceName: `Step ${currentStep + 1}`,
|
||||||
|
title: stepSettings.title ?? defaults.title,
|
||||||
|
buttons: stepSettings.buttons || defaults.buttons,
|
||||||
|
fields: stepSettings.fields,
|
||||||
|
desc: stepSettings.desc,
|
||||||
|
|
||||||
|
// Needed for field configuration
|
||||||
|
dataSource,
|
||||||
|
}
|
||||||
|
|
||||||
|
const getDefinition = stepLabel => {
|
||||||
|
let def = cloneDeep(store.actions.components.getDefinition(componentType))
|
||||||
|
def.settings.find(x => x.key === "steps").label = stepLabel
|
||||||
|
return def
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateStore = stepCount => {
|
||||||
|
multiStepStore.update(state => {
|
||||||
|
state.stepCount = stepCount
|
||||||
|
if (state.currentStep >= stepCount) {
|
||||||
|
state.currentStep = 0
|
||||||
|
}
|
||||||
|
return { ...state }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const getStepLabel = ({ stepCount, currentStep }) => {
|
||||||
|
if (stepCount <= 1) {
|
||||||
|
return "Steps"
|
||||||
|
}
|
||||||
|
return `Steps (${currentStep + 1}/${stepCount})`
|
||||||
|
}
|
||||||
|
|
||||||
|
const emitCurrentStep = step => {
|
||||||
|
store.actions.preview.sendEvent("builder-meta", {
|
||||||
|
componentId: componentInstance._id,
|
||||||
|
step: step,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const addStep = () => {
|
||||||
|
value = value.toSpliced($currentStep + 1, 0, {})
|
||||||
|
dispatch("change", value)
|
||||||
|
multiStepStore.update(state => ({
|
||||||
|
...state,
|
||||||
|
currentStep: $currentStep + 1,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
const removeStep = () => {
|
||||||
|
value = value.toSpliced($currentStep, 1)
|
||||||
|
dispatch("change", value)
|
||||||
|
multiStepStore.update(state => ({
|
||||||
|
...state,
|
||||||
|
currentStep: Math.min($currentStep, stepCount - 2),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
const previousStep = () => {
|
||||||
|
multiStepStore.update(state => ({
|
||||||
|
...state,
|
||||||
|
currentStep: Math.max($currentStep - 1, 0),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
const nextStep = () => {
|
||||||
|
multiStepStore.update(state => ({
|
||||||
|
...state,
|
||||||
|
currentStep: Math.min($currentStep + 1, value.length - 1),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateStep = (field, val) => {
|
||||||
|
const newStep = {
|
||||||
|
...value[$currentStep],
|
||||||
|
[field.key]: val,
|
||||||
|
}
|
||||||
|
value = value.toSpliced($currentStep, 1, newStep)
|
||||||
|
dispatch("change", value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleStepAction = action => {
|
||||||
|
switch (action) {
|
||||||
|
case "addStep":
|
||||||
|
addStep()
|
||||||
|
break
|
||||||
|
case "removeStep":
|
||||||
|
removeStep()
|
||||||
|
break
|
||||||
|
case "nextStep":
|
||||||
|
nextStep()
|
||||||
|
break
|
||||||
|
case "previousStep":
|
||||||
|
previousStep()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const processUpdate = (field, val) => {
|
||||||
|
if (field.key === "steps") {
|
||||||
|
handleStepAction(val.action)
|
||||||
|
} else {
|
||||||
|
updateStep(field, val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="nested-section">
|
||||||
|
<ComponentSettingsSection
|
||||||
|
includeHidden
|
||||||
|
componentInstance={stepInstance}
|
||||||
|
componentDefinition={stepDef}
|
||||||
|
onUpdateSetting={processUpdate}
|
||||||
|
showSectionTitle={false}
|
||||||
|
isScreen={false}
|
||||||
|
nested={true}
|
||||||
|
{bindings}
|
||||||
|
{componentBindings}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.nested-section {
|
||||||
|
margin: 0 calc(-1 * var(--spacing-xl)) calc(-1 * var(--spacing-xl))
|
||||||
|
calc(-1 * var(--spacing-xl));
|
||||||
|
}
|
||||||
|
.nested-section :global(.property-panel) {
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -0,0 +1,84 @@
|
||||||
|
<script>
|
||||||
|
import { createEventDispatcher, getContext } from "svelte"
|
||||||
|
import { ActionButton } from "@budibase/bbui"
|
||||||
|
|
||||||
|
const multiStepStore = getContext("multi-step-form-block")
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
$: ({ stepCount, currentStep } = $multiStepStore)
|
||||||
|
|
||||||
|
const stepAction = action => {
|
||||||
|
dispatch("change", {
|
||||||
|
action,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if stepCount === 1}
|
||||||
|
<div class="stretch">
|
||||||
|
<ActionButton
|
||||||
|
icon="MultipleAdd"
|
||||||
|
secondary
|
||||||
|
on:click={() => {
|
||||||
|
stepAction("addStep")
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Add step
|
||||||
|
</ActionButton>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<div class="step-actions">
|
||||||
|
<ActionButton
|
||||||
|
size="S"
|
||||||
|
secondary
|
||||||
|
icon="ChevronLeft"
|
||||||
|
disabled={currentStep === 0}
|
||||||
|
on:click={() => {
|
||||||
|
stepAction("previousStep")
|
||||||
|
}}
|
||||||
|
tooltip={"Previous step"}
|
||||||
|
/>
|
||||||
|
<ActionButton
|
||||||
|
size="S"
|
||||||
|
secondary
|
||||||
|
disabled={currentStep === stepCount - 1}
|
||||||
|
icon="ChevronRight"
|
||||||
|
on:click={() => {
|
||||||
|
stepAction("nextStep")
|
||||||
|
}}
|
||||||
|
tooltip={"Next step"}
|
||||||
|
/>
|
||||||
|
<ActionButton
|
||||||
|
size="S"
|
||||||
|
secondary
|
||||||
|
icon="Close"
|
||||||
|
disabled={stepCount === 1}
|
||||||
|
on:click={() => {
|
||||||
|
stepAction("removeStep")
|
||||||
|
}}
|
||||||
|
tooltip={"Remove step"}
|
||||||
|
/>
|
||||||
|
<ActionButton
|
||||||
|
size="S"
|
||||||
|
secondary
|
||||||
|
icon="MultipleAdd"
|
||||||
|
on:click={() => {
|
||||||
|
stepAction("addStep")
|
||||||
|
}}
|
||||||
|
tooltip={"Add step"}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.stretch :global(.spectrum-ActionButton) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.step-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--spacing-s);
|
||||||
|
}
|
||||||
|
.step-actions :global(.spectrum-ActionButton) {
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -114,7 +114,7 @@ const getColumns = ({
|
||||||
primary,
|
primary,
|
||||||
sortable,
|
sortable,
|
||||||
updateSortable: newDraggableList => {
|
updateSortable: newDraggableList => {
|
||||||
onChange(toGridFormat(newDraggableList.concat(primary)))
|
onChange(toGridFormat(newDraggableList.concat(primary || [])))
|
||||||
},
|
},
|
||||||
update: newEntry => {
|
update: newEntry => {
|
||||||
const newDraggableList = draggableList.map(entry => {
|
const newDraggableList = draggableList.map(entry => {
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="options-wrap">
|
<div class="options-wrap">
|
||||||
<div />
|
|
||||||
<div><ActionButton on:click={drawer.show}>Define Options</ActionButton></div>
|
<div><ActionButton on:click={drawer.show}>Define Options</ActionButton></div>
|
||||||
</div>
|
</div>
|
||||||
<Drawer bind:this={drawer} title="Options" on:drawerHide on:drawerShow>
|
<Drawer bind:this={drawer} title="Options" on:drawerHide on:drawerShow>
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
export let propertyFocus = false
|
export let propertyFocus = false
|
||||||
export let info = null
|
export let info = null
|
||||||
export let disableBindings = false
|
export let disableBindings = false
|
||||||
|
export let wide
|
||||||
|
|
||||||
$: nullishValue = value == null || value === ""
|
$: nullishValue = value == null || value === ""
|
||||||
$: allBindings = getAllBindings(bindings, componentBindings, nested)
|
$: allBindings = getAllBindings(bindings, componentBindings, nested)
|
||||||
|
@ -78,7 +79,7 @@
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="property-control"
|
class="property-control"
|
||||||
class:wide={!label || labelHidden}
|
class:wide={!label || labelHidden || wide === true}
|
||||||
class:highlighted={highlighted && nullishValue}
|
class:highlighted={highlighted && nullishValue}
|
||||||
class:property-focus={propertyFocus}
|
class:property-focus={propertyFocus}
|
||||||
>
|
>
|
||||||
|
@ -104,6 +105,7 @@
|
||||||
{...props}
|
{...props}
|
||||||
on:drawerHide
|
on:drawerHide
|
||||||
on:drawerShow
|
on:drawerShow
|
||||||
|
on:meta
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{#if info}
|
{#if info}
|
||||||
|
@ -146,15 +148,28 @@
|
||||||
.control {
|
.control {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
.property-control.wide .control {
|
|
||||||
grid-column: 1 / -1;
|
|
||||||
}
|
|
||||||
.text {
|
.text {
|
||||||
font-size: var(--spectrum-global-dimension-font-size-75);
|
font-size: var(--spectrum-global-dimension-font-size-75);
|
||||||
color: var(--grey-6);
|
color: var(--grey-6);
|
||||||
grid-column: 2 / 2;
|
grid-column: 2 / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.property-control.wide .control {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.property-control.wide {
|
||||||
|
grid-template-columns: unset;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.property-control.wide > * {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
.property-control.wide .text {
|
.property-control.wide .text {
|
||||||
grid-column: 1 / -1;
|
grid-column: 1 / -1;
|
||||||
}
|
}
|
||||||
|
.property-control.wide .label {
|
||||||
|
margin-bottom: -8px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
<script>
|
<script>
|
||||||
import { currentAsset } from "builderStore"
|
import { currentAsset, store } from "builderStore"
|
||||||
import { findClosestMatchingComponent } from "builderStore/componentUtils"
|
import {
|
||||||
|
findClosestMatchingComponent,
|
||||||
|
findComponent,
|
||||||
|
} from "builderStore/componentUtils"
|
||||||
import {
|
import {
|
||||||
getDatasourceForProvider,
|
getDatasourceForProvider,
|
||||||
getSchemaForDatasource,
|
getSchemaForDatasource,
|
||||||
|
@ -20,8 +23,23 @@
|
||||||
component => component._component.endsWith("/form")
|
component => component._component.endsWith("/form")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const resolveDatasource = (currentAsset, componentInstance, form) => {
|
||||||
|
if (!form && componentInstance._id != $store.selectedComponentId) {
|
||||||
|
const block = findComponent(
|
||||||
|
currentAsset.props,
|
||||||
|
$store.selectedComponentId
|
||||||
|
)
|
||||||
|
const def = store.actions.components.getDefinition(block._component)
|
||||||
|
return def?.block === true
|
||||||
|
? getDatasourceForProvider(currentAsset, block)
|
||||||
|
: {}
|
||||||
|
} else {
|
||||||
|
return getDatasourceForProvider(currentAsset, form)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get that form's schema
|
// Get that form's schema
|
||||||
$: datasource = getDatasourceForProvider($currentAsset, form)
|
$: datasource = resolveDatasource($currentAsset, componentInstance, form)
|
||||||
$: formSchema = getSchemaForDatasource($currentAsset, datasource)?.schema
|
$: formSchema = getSchemaForDatasource($currentAsset, datasource)?.schema
|
||||||
|
|
||||||
// Get the schema for the relationship field that this picker is using
|
// Get the schema for the relationship field that this picker is using
|
||||||
|
@ -32,4 +50,4 @@
|
||||||
$: schema = linkedTable?.schema
|
$: schema = linkedTable?.schema
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<FilterEditor on:change {...$$props} {schema} />
|
<FilterEditor on:change {...$$props} {schema} on:drawerHide on:drawerShow />
|
||||||
|
|
|
@ -12,7 +12,10 @@
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import { currentAsset, selectedComponent } from "builderStore"
|
import { currentAsset, selectedComponent } from "builderStore"
|
||||||
import { findClosestMatchingComponent } from "builderStore/componentUtils"
|
import { findClosestMatchingComponent } from "builderStore/componentUtils"
|
||||||
import { getSchemaForDatasource } from "builderStore/dataBinding"
|
import {
|
||||||
|
getSchemaForDatasource,
|
||||||
|
getDatasourceForProvider,
|
||||||
|
} from "builderStore/dataBinding"
|
||||||
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
|
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
|
||||||
import { generate } from "shortid"
|
import { generate } from "shortid"
|
||||||
|
|
||||||
|
@ -124,6 +127,12 @@
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const resolveDatasource = (currentAsset, componentInstance, parent) => {
|
||||||
|
return (
|
||||||
|
getDatasourceForProvider(currentAsset, parent || componentInstance) || {}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
$: dataSourceSchema = getDataSourceSchema($currentAsset, $selectedComponent)
|
$: dataSourceSchema = getDataSourceSchema($currentAsset, $selectedComponent)
|
||||||
$: field = fieldName || $selectedComponent?.field
|
$: field = fieldName || $selectedComponent?.field
|
||||||
$: schemaRules = parseRulesFromSchema(field, dataSourceSchema || {})
|
$: schemaRules = parseRulesFromSchema(field, dataSourceSchema || {})
|
||||||
|
@ -146,8 +155,8 @@
|
||||||
component._component.endsWith("/formblock") ||
|
component._component.endsWith("/formblock") ||
|
||||||
component._component.endsWith("/tableblock")
|
component._component.endsWith("/tableblock")
|
||||||
)
|
)
|
||||||
|
const dataSource = resolveDatasource(asset, component, formParent)
|
||||||
return getSchemaForDatasource(asset, formParent?.dataSource)
|
return getSchemaForDatasource(asset, dataSource)
|
||||||
}
|
}
|
||||||
|
|
||||||
const parseRulesFromSchema = (field, dataSourceSchema) => {
|
const parseRulesFromSchema = (field, dataSourceSchema) => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { isActive, redirect, params } from "@roxi/routify"
|
import { isActive, redirect, params } from "@roxi/routify"
|
||||||
import { admin, auth, licensing } from "stores/portal"
|
import { admin, auth, licensing, navigation } from "stores/portal"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
import { CookieUtils, Constants } from "@budibase/frontend-core"
|
import { CookieUtils, Constants } from "@budibase/frontend-core"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
$: useAccountPortal = cloud && !$admin.disableAccountPortal
|
$: useAccountPortal = cloud && !$admin.disableAccountPortal
|
||||||
|
|
||||||
|
navigation.actions.init($redirect)
|
||||||
|
|
||||||
const validateTenantId = async () => {
|
const validateTenantId = async () => {
|
||||||
const host = window.location.host
|
const host = window.location.host
|
||||||
if (host.includes("localhost:") || !baseUrl) {
|
if (host.includes("localhost:") || !baseUrl) {
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
$goto("../portal")
|
$goto("../portal")
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
submitted = false
|
submitted = false
|
||||||
notifications.error("Failed to create admin user")
|
notifications.error(error.message || "Failed to create admin user")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -108,6 +108,8 @@
|
||||||
{componentInstance}
|
{componentInstance}
|
||||||
{componentDefinition}
|
{componentDefinition}
|
||||||
{bindings}
|
{bindings}
|
||||||
|
iconTooltip={componentName}
|
||||||
|
componentTitle={title}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{#if section == "conditions"}
|
{#if section == "conditions"}
|
||||||
|
|
|
@ -32,21 +32,19 @@
|
||||||
const generalSettings = settings.filter(
|
const generalSettings = settings.filter(
|
||||||
setting => !setting.section && setting.tag === tag
|
setting => !setting.section && setting.tag === tag
|
||||||
)
|
)
|
||||||
|
|
||||||
const customSections = settings.filter(
|
const customSections = settings.filter(
|
||||||
setting => setting.section && setting.tag === tag
|
setting => setting.section && setting.tag === tag
|
||||||
)
|
)
|
||||||
let sections = [
|
let sections = []
|
||||||
...(generalSettings?.length
|
if (generalSettings.length) {
|
||||||
? [
|
sections.push({
|
||||||
{
|
name: "General",
|
||||||
name: "General",
|
settings: generalSettings,
|
||||||
settings: generalSettings,
|
})
|
||||||
},
|
}
|
||||||
]
|
if (customSections.length) {
|
||||||
: []),
|
sections = sections.concat(customSections)
|
||||||
...(customSections || []),
|
}
|
||||||
]
|
|
||||||
|
|
||||||
// Filter out settings which shouldn't be rendered
|
// Filter out settings which shouldn't be rendered
|
||||||
sections.forEach(section => {
|
sections.forEach(section => {
|
||||||
|
@ -153,6 +151,7 @@
|
||||||
<DetailSummary
|
<DetailSummary
|
||||||
name={showSectionTitle ? section.name : ""}
|
name={showSectionTitle ? section.name : ""}
|
||||||
initiallyShow={section.collapsed !== true}
|
initiallyShow={section.collapsed !== true}
|
||||||
|
collapsible={section.name !== "General"}
|
||||||
>
|
>
|
||||||
{#if section.info}
|
{#if section.info}
|
||||||
<div class="section-info">
|
<div class="section-info">
|
||||||
|
@ -172,6 +171,7 @@
|
||||||
control={getComponentForSetting(setting)}
|
control={getComponentForSetting(setting)}
|
||||||
label={setting.label}
|
label={setting.label}
|
||||||
labelHidden={setting.labelHidden}
|
labelHidden={setting.labelHidden}
|
||||||
|
wide={setting.wide}
|
||||||
key={setting.key}
|
key={setting.key}
|
||||||
value={componentInstance[setting.key]}
|
value={componentInstance[setting.key]}
|
||||||
defaultValue={setting.defaultValue}
|
defaultValue={setting.defaultValue}
|
||||||
|
@ -208,7 +208,7 @@
|
||||||
</DetailSummary>
|
</DetailSummary>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
{#if componentDefinition?.block && !tag}
|
{#if componentDefinition?.block && !tag && componentDefinition.ejectable !== false}
|
||||||
<DetailSummary name="Eject" collapsible={false}>
|
<DetailSummary name="Eject" collapsible={false}>
|
||||||
<EjectBlockButton />
|
<EjectBlockButton />
|
||||||
</DetailSummary>
|
</DetailSummary>
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
Drawer,
|
Drawer,
|
||||||
Button,
|
Button,
|
||||||
notifications,
|
notifications,
|
||||||
|
AbsTooltip,
|
||||||
|
Icon,
|
||||||
|
Body,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import { selectedScreen, store } from "builderStore"
|
import { selectedScreen, store } from "builderStore"
|
||||||
import ClientBindingPanel from "components/common/bindings/ClientBindingPanel.svelte"
|
import ClientBindingPanel from "components/common/bindings/ClientBindingPanel.svelte"
|
||||||
|
@ -15,6 +18,9 @@
|
||||||
} from "builderStore/dataBinding"
|
} from "builderStore/dataBinding"
|
||||||
|
|
||||||
export let componentInstance
|
export let componentInstance
|
||||||
|
export let componentDefinition
|
||||||
|
export let iconTooltip
|
||||||
|
export let componentTitle
|
||||||
|
|
||||||
let tempValue
|
let tempValue
|
||||||
let drawer
|
let drawer
|
||||||
|
@ -24,6 +30,8 @@
|
||||||
$store.selectedComponentId
|
$store.selectedComponentId
|
||||||
)
|
)
|
||||||
|
|
||||||
|
$: icon = componentDefinition?.icon
|
||||||
|
|
||||||
const openDrawer = () => {
|
const openDrawer = () => {
|
||||||
tempValue = runtimeToReadableBinding(
|
tempValue = runtimeToReadableBinding(
|
||||||
bindings,
|
bindings,
|
||||||
|
@ -54,7 +62,19 @@
|
||||||
{#key componentInstance?._id}
|
{#key componentInstance?._id}
|
||||||
<Drawer bind:this={drawer} title="Custom CSS">
|
<Drawer bind:this={drawer} title="Custom CSS">
|
||||||
<svelte:fragment slot="description">
|
<svelte:fragment slot="description">
|
||||||
Custom CSS overrides all other component styles.
|
<div class="header">
|
||||||
|
Your CSS will overwrite styles for:
|
||||||
|
{#if icon}
|
||||||
|
<AbsTooltip type="info" text={iconTooltip}>
|
||||||
|
<Icon
|
||||||
|
color={`var(--spectrum-global-color-gray-600)`}
|
||||||
|
size="S"
|
||||||
|
name={icon}
|
||||||
|
/>
|
||||||
|
</AbsTooltip>
|
||||||
|
<Body size="S"><b>{componentTitle || ""}</b></Body>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
<Button cta slot="buttons" on:click={save}>Save</Button>
|
<Button cta slot="buttons" on:click={save}>Save</Button>
|
||||||
<svelte:component
|
<svelte:component
|
||||||
|
@ -64,6 +84,17 @@
|
||||||
on:change={event => (tempValue = event.detail)}
|
on:change={event => (tempValue = event.detail)}
|
||||||
allowJS
|
allowJS
|
||||||
{bindings}
|
{bindings}
|
||||||
|
autofocusEditor={true}
|
||||||
/>
|
/>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
{/key}
|
{/key}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-m);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
"cardsblock",
|
"cardsblock",
|
||||||
"repeaterblock",
|
"repeaterblock",
|
||||||
"formblock",
|
"formblock",
|
||||||
|
"multistepformblock",
|
||||||
"chartblock",
|
"chartblock",
|
||||||
"rowexplorer"
|
"rowexplorer"
|
||||||
]
|
]
|
||||||
|
|
|
@ -36,14 +36,12 @@
|
||||||
|
|
||||||
// Determine selected component ID
|
// Determine selected component ID
|
||||||
$: selectedComponentId = $store.selectedComponentId
|
$: selectedComponentId = $store.selectedComponentId
|
||||||
$: hoverComponentId = $store.hoverComponentId
|
|
||||||
|
|
||||||
$: previewData = {
|
$: previewData = {
|
||||||
appId: $store.appId,
|
appId: $store.appId,
|
||||||
layout,
|
layout,
|
||||||
screen,
|
screen,
|
||||||
selectedComponentId,
|
selectedComponentId,
|
||||||
hoverComponentId,
|
|
||||||
theme: $store.theme,
|
theme: $store.theme,
|
||||||
customTheme: $store.customTheme,
|
customTheme: $store.customTheme,
|
||||||
previewDevice: $store.previewDevice,
|
previewDevice: $store.previewDevice,
|
||||||
|
@ -119,8 +117,8 @@
|
||||||
error = event.error || "An unknown error occurred"
|
error = event.error || "An unknown error occurred"
|
||||||
} else if (type === "select-component" && data.id) {
|
} else if (type === "select-component" && data.id) {
|
||||||
$store.selectedComponentId = data.id
|
$store.selectedComponentId = data.id
|
||||||
} else if (type === "hover-component" && data.id) {
|
} else if (type === "hover-component") {
|
||||||
$store.hoverComponentId = data.id
|
store.actions.components.hover(data.id, false)
|
||||||
} else if (type === "update-prop") {
|
} else if (type === "update-prop") {
|
||||||
await store.actions.components.updateSetting(data.prop, data.value)
|
await store.actions.components.updateSetting(data.prop, data.value)
|
||||||
} else if (type === "update-styles") {
|
} else if (type === "update-styles") {
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
$: definition = store.actions.components.getDefinition(component?._component)
|
$: definition = store.actions.components.getDefinition(component?._component)
|
||||||
$: noPaste = !$store.componentToPaste
|
$: noPaste = !$store.componentToPaste
|
||||||
$: isBlock = definition?.block === true
|
$: isBlock = definition?.block === true
|
||||||
|
$: canEject = !(definition?.ejectable === false)
|
||||||
|
|
||||||
const keyboardEvent = (key, ctrlKey = false) => {
|
const keyboardEvent = (key, ctrlKey = false) => {
|
||||||
document.dispatchEvent(
|
document.dispatchEvent(
|
||||||
|
@ -32,7 +33,7 @@
|
||||||
>
|
>
|
||||||
Delete
|
Delete
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{#if isBlock}
|
{#if isBlock && canEject}
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon="Export"
|
icon="Export"
|
||||||
keyBind="Ctrl+E"
|
keyBind="Ctrl+E"
|
||||||
|
|
|
@ -32,8 +32,15 @@
|
||||||
await store.actions.components.paste(component, "below")
|
await store.actions.components.paste(component, "below")
|
||||||
},
|
},
|
||||||
["Ctrl+e"]: component => {
|
["Ctrl+e"]: component => {
|
||||||
componentToEject = component
|
const definition = store.actions.components.getDefinition(
|
||||||
confirmEjectDialog.show()
|
component._component
|
||||||
|
)
|
||||||
|
const isBlock = definition?.block === true
|
||||||
|
const canEject = !(definition?.ejectable === false)
|
||||||
|
if (isBlock && canEject) {
|
||||||
|
componentToEject = component
|
||||||
|
confirmEjectDialog.show()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
["Ctrl+Enter"]: () => {
|
["Ctrl+Enter"]: () => {
|
||||||
$goto(`./:componentId/new`)
|
$goto(`./:componentId/new`)
|
||||||
|
|
|
@ -90,16 +90,7 @@
|
||||||
return findComponentPath($selectedComponent, component._id)?.length > 0
|
return findComponentPath($selectedComponent, component._id)?.length > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleMouseover = componentId => {
|
const hover = store.actions.components.hover
|
||||||
if ($store.hoverComponentId !== componentId) {
|
|
||||||
$store.hoverComponentId = componentId
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const handleMouseout = componentId => {
|
|
||||||
if ($store.hoverComponentId === componentId) {
|
|
||||||
$store.hoverComponentId = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -120,9 +111,9 @@
|
||||||
on:dragover={dragover(component, index)}
|
on:dragover={dragover(component, index)}
|
||||||
on:iconClick={() => toggleNodeOpen(component._id)}
|
on:iconClick={() => toggleNodeOpen(component._id)}
|
||||||
on:drop={onDrop}
|
on:drop={onDrop}
|
||||||
hovering={$store.hoverComponentId === component._id}
|
hovering={$store.hoveredComponentId === component._id}
|
||||||
on:mouseenter={() => handleMouseover(component._id)}
|
on:mouseenter={() => hover(component._id)}
|
||||||
on:mouseleave={() => handleMouseout(component._id)}
|
on:mouseleave={() => hover(null)}
|
||||||
text={getComponentText(component)}
|
text={getComponentText(component)}
|
||||||
icon={getComponentIcon(component)}
|
icon={getComponentIcon(component)}
|
||||||
iconTooltip={getComponentName(component)}
|
iconTooltip={getComponentName(component)}
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
|
|
||||||
let scrolling = false
|
let scrolling = false
|
||||||
|
|
||||||
|
$: screenComponentId = `${$store.selectedScreenId}-screen`
|
||||||
|
$: navComponentId = `${$store.selectedScreenId}-navigation`
|
||||||
|
|
||||||
const toNewComponentRoute = () => {
|
const toNewComponentRoute = () => {
|
||||||
if ($isActive(`./:componentId/new`)) {
|
if ($isActive(`./:componentId/new`)) {
|
||||||
$goto(`./:componentId`)
|
$goto(`./:componentId`)
|
||||||
|
@ -33,16 +36,7 @@
|
||||||
scrolling = e.target.scrollTop !== 0
|
scrolling = e.target.scrollTop !== 0
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleMouseover = componentId => {
|
const hover = store.actions.components.hover
|
||||||
if ($store.hoverComponentId !== componentId) {
|
|
||||||
$store.hoverComponentId = componentId
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const handleMouseout = componentId => {
|
|
||||||
if ($store.hoverComponentId === componentId) {
|
|
||||||
$store.hoverComponentId = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="components">
|
<div class="components">
|
||||||
|
@ -65,46 +59,31 @@
|
||||||
scrollable
|
scrollable
|
||||||
icon="WebPage"
|
icon="WebPage"
|
||||||
on:drop={onDrop}
|
on:drop={onDrop}
|
||||||
on:click={() => {
|
on:click={() => ($store.selectedComponentId = screenComponentId)}
|
||||||
$store.selectedComponentId = `${$store.selectedScreenId}-screen`
|
hovering={$store.hoveredComponentId === screenComponentId}
|
||||||
}}
|
on:mouseenter={() => hover(screenComponentId)}
|
||||||
hovering={$store.hoverComponentId ===
|
on:mouseleave={() => hover(null)}
|
||||||
`${$store.selectedScreenId}-screen`}
|
id="component-screen"
|
||||||
on:mouseenter={() =>
|
selectedBy={$userSelectedResourceMap[screenComponentId]}
|
||||||
handleMouseover(`${$store.selectedScreenId}-screen`)}
|
|
||||||
on:mouseleave={() =>
|
|
||||||
handleMouseout(`${$store.selectedScreenId}-screen`)}
|
|
||||||
id={`component-screen`}
|
|
||||||
selectedBy={$userSelectedResourceMap[
|
|
||||||
`${$store.selectedScreenId}-screen`
|
|
||||||
]}
|
|
||||||
>
|
>
|
||||||
<ScreenslotDropdownMenu component={$selectedScreen?.props} />
|
<ScreenslotDropdownMenu component={$selectedScreen?.props} />
|
||||||
</NavItem>
|
</NavItem>
|
||||||
<NavItem
|
<NavItem
|
||||||
text="Navigation"
|
text="Navigation"
|
||||||
indentLevel={0}
|
indentLevel={0}
|
||||||
selected={$store.selectedComponentId ===
|
selected={$store.selectedComponentId === navComponentId}
|
||||||
`${$store.selectedScreenId}-navigation`}
|
|
||||||
opened
|
opened
|
||||||
scrollable
|
scrollable
|
||||||
icon={$selectedScreen.showNavigation
|
icon={$selectedScreen.showNavigation
|
||||||
? "Visibility"
|
? "Visibility"
|
||||||
: "VisibilityOff"}
|
: "VisibilityOff"}
|
||||||
on:drop={onDrop}
|
on:drop={onDrop}
|
||||||
on:click={() => {
|
on:click={() => ($store.selectedComponentId = navComponentId)}
|
||||||
$store.selectedComponentId = `${$store.selectedScreenId}-navigation`
|
hovering={$store.hoveredComponentId === navComponentId}
|
||||||
}}
|
on:mouseenter={() => hover(navComponentId)}
|
||||||
hovering={$store.hoverComponentId ===
|
on:mouseleave={() => hover(null)}
|
||||||
`${$store.selectedScreenId}-navigation`}
|
id="component-nav"
|
||||||
on:mouseenter={() =>
|
selectedBy={$userSelectedResourceMap[navComponentId]}
|
||||||
handleMouseover(`${$store.selectedScreenId}-navigation`)}
|
|
||||||
on:mouseleave={() =>
|
|
||||||
handleMouseout(`${$store.selectedScreenId}-navigation`)}
|
|
||||||
id={`component-nav`}
|
|
||||||
selectedBy={$userSelectedResourceMap[
|
|
||||||
`${$store.selectedScreenId}-navigation`
|
|
||||||
]}
|
|
||||||
/>
|
/>
|
||||||
<ComponentTree
|
<ComponentTree
|
||||||
level={0}
|
level={0}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<script>
|
||||||
|
import { Updating } from "@budibase/frontend-core"
|
||||||
|
import { redirect, params } from "@roxi/routify"
|
||||||
|
|
||||||
|
import { API } from "api"
|
||||||
|
|
||||||
|
async function isMigrationDone() {
|
||||||
|
const response = await API.getMigrationStatus()
|
||||||
|
return response.migrated
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onMigrationDone() {
|
||||||
|
// For some reason routify params is not stripping the ? properly, so we need to check both with and without ?
|
||||||
|
const returnUrl = $params.returnUrl || $params["?returnUrl"]
|
||||||
|
$redirect(returnUrl)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Updating {isMigrationDone} {onMigrationDone} />
|
|
@ -45,7 +45,7 @@
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
submitted = false
|
submitted = false
|
||||||
notifications.error("Unable to reset password")
|
notifications.error(err.message || "Unable to reset password")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,7 @@
|
||||||
<Heading size="M">Branding</Heading>
|
<Heading size="M">Branding</Heading>
|
||||||
{#if !isCloud && !brandingEnabled}
|
{#if !isCloud && !brandingEnabled}
|
||||||
<Tags>
|
<Tags>
|
||||||
<Tag icon="LockClosed">Business</Tag>
|
<Tag icon="LockClosed">Premium</Tag>
|
||||||
</Tags>
|
</Tags>
|
||||||
{/if}
|
{/if}
|
||||||
{#if isCloud && !brandingEnabled}
|
{#if isCloud && !brandingEnabled}
|
||||||
|
|
|
@ -97,7 +97,7 @@
|
||||||
<Heading size="M">Groups</Heading>
|
<Heading size="M">Groups</Heading>
|
||||||
{#if !$licensing.groupsEnabled}
|
{#if !$licensing.groupsEnabled}
|
||||||
<Tags>
|
<Tags>
|
||||||
<Tag icon="LockClosed">Business</Tag>
|
<Tag icon="LockClosed">Enterpise</Tag>
|
||||||
</Tags>
|
</Tags>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -16,5 +16,6 @@ export { environment } from "./environment"
|
||||||
export { menu } from "./menu"
|
export { menu } from "./menu"
|
||||||
export { auditLogs } from "./auditLogs"
|
export { auditLogs } from "./auditLogs"
|
||||||
export { features } from "./features"
|
export { features } from "./features"
|
||||||
|
export { navigation } from "./navigation"
|
||||||
|
|
||||||
export const sideBarCollapsed = writable(false)
|
export const sideBarCollapsed = writable(false)
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
import { writable } from "svelte/store"
|
||||||
|
|
||||||
|
export function createNavigationStore() {
|
||||||
|
const store = writable({
|
||||||
|
initialisated: false,
|
||||||
|
goto: undefined,
|
||||||
|
})
|
||||||
|
const { set, subscribe } = store
|
||||||
|
|
||||||
|
const init = gotoFunc => {
|
||||||
|
if (typeof gotoFunc !== "function") {
|
||||||
|
throw new Error(
|
||||||
|
`gotoFunc must be a function, found a "${typeof gotoFunc}" instead`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
set({
|
||||||
|
initialisated: true,
|
||||||
|
goto: gotoFunc,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
subscribe,
|
||||||
|
actions: {
|
||||||
|
init,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const navigation = createNavigationStore()
|
|
@ -5,7 +5,6 @@ build/
|
||||||
docker-error.log
|
docker-error.log
|
||||||
envoy.yaml
|
envoy.yaml
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
prebuilds/
|
|
||||||
dist/
|
dist/
|
||||||
budibase-automation/
|
budibase-automation/
|
||||||
budibase-component/
|
budibase-component/
|
||||||
|
|
|
@ -9,26 +9,11 @@
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "rm -rf prebuilds 2> /dev/null && cp -r ../../node_modules/leveldown/prebuilds prebuilds",
|
|
||||||
"rename": "renamer --find .node --replace .fake 'prebuilds/**'",
|
|
||||||
"tsc": "node ../../scripts/build.js",
|
"tsc": "node ../../scripts/build.js",
|
||||||
"pkg": "pkg . --out-path build --no-bytecode --public --public-packages \"*\" -C GZip",
|
"build": "yarn tsc",
|
||||||
"build": "yarn prebuild && yarn rename && yarn tsc && yarn pkg && yarn postbuild",
|
|
||||||
"check:types": "tsc -p tsconfig.json --noEmit --paths null",
|
"check:types": "tsc -p tsconfig.json --noEmit --paths null",
|
||||||
"postbuild": "rm -rf prebuilds 2> /dev/null",
|
|
||||||
"start": "ts-node ./src/index.ts"
|
"start": "ts-node ./src/index.ts"
|
||||||
},
|
},
|
||||||
"pkg": {
|
|
||||||
"targets": [
|
|
||||||
"node18-linux",
|
|
||||||
"node18-win",
|
|
||||||
"node18-macos"
|
|
||||||
],
|
|
||||||
"assets": [
|
|
||||||
"prebuilds/**/*"
|
|
||||||
],
|
|
||||||
"outputPath": "build"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/backend-core": "0.0.0",
|
"@budibase/backend-core": "0.0.0",
|
||||||
"@budibase/string-templates": "0.0.0",
|
"@budibase/string-templates": "0.0.0",
|
||||||
|
@ -43,7 +28,6 @@
|
||||||
"inquirer": "8.0.0",
|
"inquirer": "8.0.0",
|
||||||
"lookpath": "1.1.0",
|
"lookpath": "1.1.0",
|
||||||
"node-fetch": "2.6.7",
|
"node-fetch": "2.6.7",
|
||||||
"pkg": "5.8.0",
|
|
||||||
"posthog-node": "1.3.0",
|
"posthog-node": "1.3.0",
|
||||||
"pouchdb": "7.3.0",
|
"pouchdb": "7.3.0",
|
||||||
"pouchdb-replication-stream": "1.2.9",
|
"pouchdb-replication-stream": "1.2.9",
|
||||||
|
@ -55,7 +39,6 @@
|
||||||
"@types/jest": "29.5.5",
|
"@types/jest": "29.5.5",
|
||||||
"@types/node-fetch": "2.6.4",
|
"@types/node-fetch": "2.6.4",
|
||||||
"@types/pouchdb": "^6.4.0",
|
"@types/pouchdb": "^6.4.0",
|
||||||
"renamer": "^4.0.0",
|
|
||||||
"ts-node": "10.8.1",
|
"ts-node": "10.8.1",
|
||||||
"typescript": "5.2.2"
|
"typescript": "5.2.2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
process.env.DISABLE_PINO_LOGGER = "1"
|
process.env.DISABLE_PINO_LOGGER = "1"
|
||||||
import "./prebuilds"
|
|
||||||
import "./environment"
|
import "./environment"
|
||||||
import { getCommands } from "./options"
|
import { getCommands } from "./options"
|
||||||
import { Command } from "commander"
|
import { Command } from "commander"
|
||||||
import { getHelpDescription } from "./utils"
|
import { getHelpDescription, error } from "./utils"
|
||||||
import { version } from "../package.json"
|
import { version } from "../package.json"
|
||||||
|
|
||||||
// add hosting config
|
// add hosting config
|
||||||
|
@ -21,6 +20,23 @@ async function init() {
|
||||||
await program.parseAsync(process.argv)
|
await program.parseAsync(process.argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const events = ["exit", "SIGINT", "SIGUSR1", "SIGUSR2", "uncaughtException"]
|
||||||
|
events.forEach(event => {
|
||||||
|
process.on(event, (evt?: number) => {
|
||||||
|
if (evt && !isNaN(evt)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (evt) {
|
||||||
|
console.error(
|
||||||
|
error(
|
||||||
|
"Failed to run CLI command - please report with the following message:"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
console.error(error(evt))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
init().catch(err => {
|
init().catch(err => {
|
||||||
console.error(`Unexpected error - `, err)
|
console.error(`Unexpected error - `, err)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
import os from "os"
|
|
||||||
import { join } from "path"
|
|
||||||
import fs from "fs"
|
|
||||||
import { error } from "./utils"
|
|
||||||
|
|
||||||
const PREBUILDS = "prebuilds"
|
|
||||||
const ARCH = `${os.platform()}-${os.arch()}`
|
|
||||||
const PREBUILD_DIR = join(process.execPath, "..", "cli", PREBUILDS, ARCH)
|
|
||||||
|
|
||||||
// running as built CLI pkg bundle
|
|
||||||
if (!process.argv[0].includes("node")) {
|
|
||||||
checkForBinaries()
|
|
||||||
}
|
|
||||||
|
|
||||||
function localPrebuildPath() {
|
|
||||||
return join(process.execPath, "..", PREBUILDS)
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkForBinaries() {
|
|
||||||
const readDir = join(__filename, "..", "..", "..", "cli", PREBUILDS, ARCH)
|
|
||||||
if (fs.existsSync(PREBUILD_DIR) || !fs.existsSync(readDir)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const natives = fs.readdirSync(readDir)
|
|
||||||
if (fs.existsSync(readDir)) {
|
|
||||||
const writePath = join(localPrebuildPath(), ARCH)
|
|
||||||
fs.mkdirSync(writePath, { recursive: true })
|
|
||||||
for (let native of natives) {
|
|
||||||
const filename = `${native.split(".fake")[0]}.node`
|
|
||||||
fs.cpSync(join(readDir, native), join(writePath, filename))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function cleanup(evt?: number) {
|
|
||||||
// cleanup prebuilds first
|
|
||||||
const path = localPrebuildPath()
|
|
||||||
if (fs.existsSync(path)) {
|
|
||||||
fs.rmSync(path, { recursive: true })
|
|
||||||
}
|
|
||||||
if (evt && !isNaN(evt)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (evt) {
|
|
||||||
console.error(
|
|
||||||
error(
|
|
||||||
"Failed to run CLI command - please report with the following message:"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
console.error(error(evt))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const events = ["exit", "SIGINT", "SIGUSR1", "SIGUSR2", "uncaughtException"]
|
|
||||||
events.forEach(event => {
|
|
||||||
process.on(event, cleanup)
|
|
||||||
})
|
|
|
@ -3295,6 +3295,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "options",
|
"type": "options",
|
||||||
|
"label": "Custom options",
|
||||||
"key": "customOptions",
|
"key": "customOptions",
|
||||||
"dependsOn": {
|
"dependsOn": {
|
||||||
"setting": "optionsSource",
|
"setting": "optionsSource",
|
||||||
|
@ -3502,6 +3503,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "options",
|
"type": "options",
|
||||||
|
"label": "Custom options",
|
||||||
"key": "customOptions",
|
"key": "customOptions",
|
||||||
"dependsOn": {
|
"dependsOn": {
|
||||||
"setting": "optionsSource",
|
"setting": "optionsSource",
|
||||||
|
@ -4877,7 +4879,7 @@
|
||||||
},
|
},
|
||||||
"chartblock": {
|
"chartblock": {
|
||||||
"block": true,
|
"block": true,
|
||||||
"name": "Chart block",
|
"name": "Chart Block",
|
||||||
"icon": "GraphPie",
|
"icon": "GraphPie",
|
||||||
"hasChildren": false,
|
"hasChildren": false,
|
||||||
"settings": [
|
"settings": [
|
||||||
|
@ -5367,7 +5369,7 @@
|
||||||
},
|
},
|
||||||
"tableblock": {
|
"tableblock": {
|
||||||
"block": true,
|
"block": true,
|
||||||
"name": "Table block",
|
"name": "Table Block",
|
||||||
"icon": "Table",
|
"icon": "Table",
|
||||||
"styles": ["size"],
|
"styles": ["size"],
|
||||||
"size": {
|
"size": {
|
||||||
|
@ -5613,7 +5615,7 @@
|
||||||
},
|
},
|
||||||
"cardsblock": {
|
"cardsblock": {
|
||||||
"block": true,
|
"block": true,
|
||||||
"name": "Cards block",
|
"name": "Cards Block",
|
||||||
"icon": "PersonalizationField",
|
"icon": "PersonalizationField",
|
||||||
"styles": ["size"],
|
"styles": ["size"],
|
||||||
"size": {
|
"size": {
|
||||||
|
@ -5793,7 +5795,7 @@
|
||||||
},
|
},
|
||||||
"repeaterblock": {
|
"repeaterblock": {
|
||||||
"block": true,
|
"block": true,
|
||||||
"name": "Repeater block",
|
"name": "Repeater Block",
|
||||||
"icon": "ViewList",
|
"icon": "ViewList",
|
||||||
"illegalChildren": ["section"],
|
"illegalChildren": ["section"],
|
||||||
"hasChildren": true,
|
"hasChildren": true,
|
||||||
|
@ -6033,6 +6035,193 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"multistepformblock": {
|
||||||
|
"name": "Multi-step Form Block",
|
||||||
|
"icon": "AssetsAdded",
|
||||||
|
"block": true,
|
||||||
|
"hasChildren": false,
|
||||||
|
"ejectable": false,
|
||||||
|
"size": {
|
||||||
|
"width": 400,
|
||||||
|
"height": 400
|
||||||
|
},
|
||||||
|
"styles": ["size"],
|
||||||
|
"settings": [
|
||||||
|
{
|
||||||
|
"type": "table",
|
||||||
|
"label": "Data",
|
||||||
|
"key": "dataSource"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "radio",
|
||||||
|
"label": "Type",
|
||||||
|
"key": "actionType",
|
||||||
|
"options": ["Create", "Update", "View"],
|
||||||
|
"defaultValue": "Create"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"section": true,
|
||||||
|
"dependsOn": {
|
||||||
|
"setting": "actionType",
|
||||||
|
"value": "Create",
|
||||||
|
"invert": true
|
||||||
|
},
|
||||||
|
"name": "Row ID",
|
||||||
|
"info": "<a href='https://docs.budibase.com/docs/form-block' target='_blank'>How to pass a row ID using bindings</a>",
|
||||||
|
"settings": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"label": "Row ID",
|
||||||
|
"key": "rowId",
|
||||||
|
"nested": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"label": "No rows found",
|
||||||
|
"key": "noRowsMessage",
|
||||||
|
"defaultValue": "We couldn't find a row to display",
|
||||||
|
"nested": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"section": true,
|
||||||
|
"name": "Details",
|
||||||
|
"settings": [
|
||||||
|
{
|
||||||
|
"type": "stepConfiguration",
|
||||||
|
"key": "steps",
|
||||||
|
"nested": true,
|
||||||
|
"labelHidden": true,
|
||||||
|
"resetOn": ["dataSource", "actionType"],
|
||||||
|
"defaultValue": [{}]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "style",
|
||||||
|
"type": "select",
|
||||||
|
"label": "Size",
|
||||||
|
"key": "size",
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "Medium",
|
||||||
|
"value": "spectrum--medium"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Large",
|
||||||
|
"value": "spectrum--large"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"defaultValue": "spectrum--medium"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "style",
|
||||||
|
"type": "select",
|
||||||
|
"label": "Button position",
|
||||||
|
"key": "buttonPosition",
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"label": "Bottom",
|
||||||
|
"value": "bottom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Top",
|
||||||
|
"value": "top"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"defaultValue": "bottom"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"type": "ValidateForm",
|
||||||
|
"suffix": "form"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ClearForm",
|
||||||
|
"suffix": "form"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "UpdateFieldValue",
|
||||||
|
"suffix": "form"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ScrollTo",
|
||||||
|
"suffix": "form"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ChangeFormStep",
|
||||||
|
"suffix": "form"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"context": [
|
||||||
|
{
|
||||||
|
"type": "form",
|
||||||
|
"suffix": "form"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "static",
|
||||||
|
"suffix": "form",
|
||||||
|
"values": [
|
||||||
|
{
|
||||||
|
"label": "Value",
|
||||||
|
"key": "__value",
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Valid",
|
||||||
|
"key": "__valid",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Current Step",
|
||||||
|
"key": "__currentStep",
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Current Step Valid",
|
||||||
|
"key": "__currentStepValid",
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"multistepformblockstep": {
|
||||||
|
"name": "Multi-step Form Block Step",
|
||||||
|
"settings": [
|
||||||
|
{
|
||||||
|
"type": "formStepControls",
|
||||||
|
"label": "Steps",
|
||||||
|
"key": "steps"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"label": "Title",
|
||||||
|
"key": "title",
|
||||||
|
"nested": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"label": "Description",
|
||||||
|
"key": "desc",
|
||||||
|
"nested": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "fieldConfiguration",
|
||||||
|
"key": "fields",
|
||||||
|
"nested": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "buttonConfiguration",
|
||||||
|
"label": "Buttons",
|
||||||
|
"key": "buttons",
|
||||||
|
"wide": true,
|
||||||
|
"nested": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"formblock": {
|
"formblock": {
|
||||||
"name": "Form Block",
|
"name": "Form Block",
|
||||||
"icon": "Form",
|
"icon": "Form",
|
||||||
|
@ -6288,7 +6477,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"gridblock": {
|
"gridblock": {
|
||||||
"name": "Grid block",
|
"name": "Grid Block",
|
||||||
"icon": "Table",
|
"icon": "Table",
|
||||||
"styles": ["size"],
|
"styles": ["size"],
|
||||||
"size": {
|
"size": {
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
"downloadjs": "1.4.7",
|
"downloadjs": "1.4.7",
|
||||||
"html5-qrcode": "^2.2.1",
|
"html5-qrcode": "^2.2.1",
|
||||||
"leaflet": "^1.7.1",
|
"leaflet": "^1.7.1",
|
||||||
"regexparam": "^1.3.0",
|
|
||||||
"sanitize-html": "^2.7.0",
|
"sanitize-html": "^2.7.0",
|
||||||
"screenfull": "^6.0.1",
|
"screenfull": "^6.0.1",
|
||||||
"shortid": "^2.2.15",
|
"shortid": "^2.2.15",
|
||||||
|
|
|
@ -77,4 +77,10 @@ export const API = createAPIClient({
|
||||||
// Log all errors to console
|
// Log all errors to console
|
||||||
console.warn(`[Client] HTTP ${status} on ${method}:${url}\n\t${message}`)
|
console.warn(`[Client] HTTP ${status} on ${method}:${url}\n\t${message}`)
|
||||||
},
|
},
|
||||||
|
onMigrationDetected: _appId => {
|
||||||
|
if (!window.MIGRATING_APP) {
|
||||||
|
// We will force a reload, that will display the updating screen until the migration is running
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<script>
|
||||||
|
import { Updating } from "@budibase/frontend-core"
|
||||||
|
import { API } from "../api"
|
||||||
|
|
||||||
|
async function isMigrationDone() {
|
||||||
|
const response = await API.getMigrationStatus()
|
||||||
|
return response.migrated
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onMigrationDone() {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="updating">
|
||||||
|
<Updating {isMigrationDone} {onMigrationDone} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.updating {
|
||||||
|
font-family: var(--font-sans);
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -0,0 +1,229 @@
|
||||||
|
<script>
|
||||||
|
import BlockComponent from "components/BlockComponent.svelte"
|
||||||
|
import { getContext, setContext } from "svelte"
|
||||||
|
import { builderStore } from "stores"
|
||||||
|
import { Utils } from "@budibase/frontend-core"
|
||||||
|
import FormBlockWrapper from "./form/FormBlockWrapper.svelte"
|
||||||
|
import { writable } from "svelte/store"
|
||||||
|
|
||||||
|
export let actionType
|
||||||
|
export let rowId
|
||||||
|
export let noRowsMessage
|
||||||
|
export let steps
|
||||||
|
export let dataSource
|
||||||
|
export let buttonPosition = "bottom"
|
||||||
|
export let size
|
||||||
|
|
||||||
|
const { fetchDatasourceSchema } = getContext("sdk")
|
||||||
|
const component = getContext("component")
|
||||||
|
const context = getContext("context")
|
||||||
|
|
||||||
|
// Set current step context to force child form to use it
|
||||||
|
const currentStep = writable(1)
|
||||||
|
setContext("current-step", currentStep)
|
||||||
|
|
||||||
|
const FieldTypeToComponentMap = {
|
||||||
|
string: "stringfield",
|
||||||
|
number: "numberfield",
|
||||||
|
bigint: "bigintfield",
|
||||||
|
options: "optionsfield",
|
||||||
|
array: "multifieldselect",
|
||||||
|
boolean: "booleanfield",
|
||||||
|
longform: "longformfield",
|
||||||
|
datetime: "datetimefield",
|
||||||
|
attachment: "attachmentfield",
|
||||||
|
link: "relationshipfield",
|
||||||
|
json: "jsonfield",
|
||||||
|
barcodeqr: "codescanner",
|
||||||
|
bb_reference: "bbreferencefield",
|
||||||
|
}
|
||||||
|
|
||||||
|
let schema
|
||||||
|
|
||||||
|
$: fetchSchema(dataSource)
|
||||||
|
$: enrichedSteps = enrichSteps(steps, schema, $component.id)
|
||||||
|
$: updateCurrentStep(enrichedSteps, $builderStore, $component)
|
||||||
|
|
||||||
|
const updateCurrentStep = (steps, builderStore, component) => {
|
||||||
|
const { componentId, step } = builderStore.metadata || {}
|
||||||
|
|
||||||
|
// If we aren't in the builder or aren't selected then don't update the step
|
||||||
|
// context at all, allowing the normal form to take control.
|
||||||
|
if (
|
||||||
|
!component.selected ||
|
||||||
|
!builderStore.inBuilder ||
|
||||||
|
componentId !== component.id
|
||||||
|
) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure we have a valid step selected
|
||||||
|
let newStep = Math.min(step || 0, steps.length - 1)
|
||||||
|
|
||||||
|
// Sanity check
|
||||||
|
newStep = Math.max(newStep, 0)
|
||||||
|
|
||||||
|
// Add 1 because the form component expects 1 indexed rather than 0 indexed
|
||||||
|
currentStep.set(newStep + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const getPropsForField = field => {
|
||||||
|
if (field._component) {
|
||||||
|
return field
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
field: field.name,
|
||||||
|
label: field.name,
|
||||||
|
placeholder: field.name,
|
||||||
|
_instanceName: field.name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getComponentForField = field => {
|
||||||
|
const fieldSchemaName = field.field || field.name
|
||||||
|
if (!fieldSchemaName || !schema?.[fieldSchemaName]) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const type = schema[fieldSchemaName].type
|
||||||
|
return FieldTypeToComponentMap[type]
|
||||||
|
}
|
||||||
|
|
||||||
|
const fetchSchema = async () => {
|
||||||
|
schema = (await fetchDatasourceSchema(dataSource)) || {}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getDefaultFields = (fields, schema) => {
|
||||||
|
if (fields?.length) {
|
||||||
|
return fields.filter(field => field.active)
|
||||||
|
}
|
||||||
|
return Object.values(schema || {})
|
||||||
|
.filter(field => !field.autocolumn)
|
||||||
|
.map(field => ({
|
||||||
|
name: field.name,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
const enrichSteps = (steps, schema, id) => {
|
||||||
|
const safeSteps = steps?.length ? steps : [{}]
|
||||||
|
return safeSteps.map((step, idx) => {
|
||||||
|
const { title, desc, fields, buttons } = step
|
||||||
|
const defaultProps = Utils.buildMultiStepFormBlockDefaultProps({
|
||||||
|
_id: id,
|
||||||
|
stepCount: safeSteps.length,
|
||||||
|
currentStep: idx,
|
||||||
|
actionType,
|
||||||
|
dataSource,
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
fields: getDefaultFields(fields || [], schema),
|
||||||
|
title: title ?? defaultProps.title,
|
||||||
|
desc,
|
||||||
|
buttons: buttons || defaultProps.buttons,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<FormBlockWrapper {actionType} {dataSource} {rowId} {noRowsMessage}>
|
||||||
|
<BlockComponent
|
||||||
|
type="form"
|
||||||
|
context="form"
|
||||||
|
props={{
|
||||||
|
size,
|
||||||
|
dataSource,
|
||||||
|
actionType: actionType === "Create" ? "Create" : "Update",
|
||||||
|
readonly: actionType === "View",
|
||||||
|
}}
|
||||||
|
styles={{
|
||||||
|
normal: {
|
||||||
|
width: "600px",
|
||||||
|
"margin-left": "auto",
|
||||||
|
"margin-right": "auto",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{#each enrichedSteps as step, stepIdx}
|
||||||
|
<BlockComponent
|
||||||
|
type="formstep"
|
||||||
|
props={{ step: stepIdx + 1, _instanceName: `Step ${stepIdx + 1}` }}
|
||||||
|
>
|
||||||
|
<BlockComponent
|
||||||
|
type="container"
|
||||||
|
props={{
|
||||||
|
gap: "M",
|
||||||
|
direction: "column",
|
||||||
|
hAlign: "stretch",
|
||||||
|
vAlign: "top",
|
||||||
|
size: "shrink",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<BlockComponent
|
||||||
|
type="container"
|
||||||
|
props={{
|
||||||
|
direction: "column",
|
||||||
|
gap: "S",
|
||||||
|
}}
|
||||||
|
order={0}
|
||||||
|
>
|
||||||
|
<BlockComponent
|
||||||
|
type="container"
|
||||||
|
props={{
|
||||||
|
direction: "row",
|
||||||
|
hAlign: "stretch",
|
||||||
|
vAlign: "center",
|
||||||
|
gap: "M",
|
||||||
|
wrap: true,
|
||||||
|
}}
|
||||||
|
order={0}
|
||||||
|
>
|
||||||
|
<BlockComponent type="heading" props={{ text: step.title }} />
|
||||||
|
{#if buttonPosition === "top"}
|
||||||
|
<BlockComponent
|
||||||
|
type="buttongroup"
|
||||||
|
props={{ buttons: step.buttons }}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
</BlockComponent>
|
||||||
|
</BlockComponent>
|
||||||
|
<BlockComponent type="text" props={{ text: step.desc }} order={1} />
|
||||||
|
<BlockComponent type="container" order={2}>
|
||||||
|
<div
|
||||||
|
class="form-block fields"
|
||||||
|
class:mobile={$context.device.mobile}
|
||||||
|
>
|
||||||
|
{#each step.fields as field, fieldIdx (`${field.field || field.name}_${stepIdx}_${fieldIdx}`)}
|
||||||
|
{#if getComponentForField(field)}
|
||||||
|
<BlockComponent
|
||||||
|
type={getComponentForField(field)}
|
||||||
|
props={getPropsForField(field)}
|
||||||
|
order={fieldIdx}
|
||||||
|
interactive
|
||||||
|
name={field.field}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
</BlockComponent>
|
||||||
|
{#if buttonPosition === "bottom"}
|
||||||
|
<BlockComponent
|
||||||
|
type="buttongroup"
|
||||||
|
props={{ buttons: step.buttons }}
|
||||||
|
order={3}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
</BlockComponent>
|
||||||
|
</BlockComponent>
|
||||||
|
{/each}
|
||||||
|
</BlockComponent>
|
||||||
|
</FormBlockWrapper>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.fields {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(6, 1fr);
|
||||||
|
gap: 8px 16px;
|
||||||
|
}
|
||||||
|
.fields.mobile :global(.spectrum-Form-item) {
|
||||||
|
grid-column: span 6 !important;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -265,7 +265,7 @@
|
||||||
props={{
|
props={{
|
||||||
dataSource,
|
dataSource,
|
||||||
buttonPosition: "top",
|
buttonPosition: "top",
|
||||||
buttons: Utils.buildDynamicButtonConfig({
|
buttons: Utils.buildFormBlockButtonConfig({
|
||||||
_id: $component.id + "-form-edit",
|
_id: $component.id + "-form-edit",
|
||||||
showDeleteButton: deleteLabel !== "",
|
showDeleteButton: deleteLabel !== "",
|
||||||
showSaveButton: true,
|
showSaveButton: true,
|
||||||
|
@ -299,7 +299,7 @@
|
||||||
props={{
|
props={{
|
||||||
dataSource,
|
dataSource,
|
||||||
buttonPosition: "top",
|
buttonPosition: "top",
|
||||||
buttons: Utils.buildDynamicButtonConfig({
|
buttons: Utils.buildFormBlockButtonConfig({
|
||||||
_id: $component.id + "-form-new",
|
_id: $component.id + "-form-new",
|
||||||
showDeleteButton: false,
|
showDeleteButton: false,
|
||||||
showSaveButton: true,
|
showSaveButton: true,
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
<script>
|
<script>
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
import BlockComponent from "components/BlockComponent.svelte"
|
|
||||||
import Block from "components/Block.svelte"
|
|
||||||
import { makePropSafe as safe } from "@budibase/string-templates"
|
|
||||||
import InnerFormBlock from "./InnerFormBlock.svelte"
|
import InnerFormBlock from "./InnerFormBlock.svelte"
|
||||||
import { Utils } from "@budibase/frontend-core"
|
import { Utils } from "@budibase/frontend-core"
|
||||||
|
import FormBlockWrapper from "./FormBlockWrapper.svelte"
|
||||||
|
|
||||||
export let actionType
|
export let actionType
|
||||||
export let dataSource
|
export let dataSource
|
||||||
|
@ -71,22 +69,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
let schema
|
let schema
|
||||||
let providerId
|
|
||||||
let repeaterId
|
|
||||||
|
|
||||||
$: formattedFields = convertOldFieldFormat(fields)
|
$: formattedFields = convertOldFieldFormat(fields)
|
||||||
$: fieldsOrDefault = getDefaultFields(formattedFields, schema)
|
$: fieldsOrDefault = getDefaultFields(formattedFields, schema)
|
||||||
$: fetchSchema(dataSource)
|
$: fetchSchema(dataSource)
|
||||||
$: dataProvider = `{{ literal ${safe(providerId)} }}`
|
|
||||||
$: filter = [
|
|
||||||
{
|
|
||||||
field: "_id",
|
|
||||||
operator: "equal",
|
|
||||||
type: "string",
|
|
||||||
value: !rowId ? `{{ ${safe("url")}.${safe("id")} }}` : rowId,
|
|
||||||
valueType: "Binding",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
// We could simply spread $$props into the inner form and append our
|
// We could simply spread $$props into the inner form and append our
|
||||||
// additions, but that would create svelte warnings about unused props and
|
// additions, but that would create svelte warnings about unused props and
|
||||||
// make maintenance in future more confusing as we typically always have a
|
// make maintenance in future more confusing as we typically always have a
|
||||||
|
@ -102,11 +88,10 @@
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
schema,
|
schema,
|
||||||
repeaterId,
|
|
||||||
notificationOverride,
|
notificationOverride,
|
||||||
buttons:
|
buttons:
|
||||||
buttons ||
|
buttons ||
|
||||||
Utils.buildDynamicButtonConfig({
|
Utils.buildFormBlockButtonConfig({
|
||||||
_id: $component.id,
|
_id: $component.id,
|
||||||
showDeleteButton,
|
showDeleteButton,
|
||||||
showSaveButton,
|
showSaveButton,
|
||||||
|
@ -124,43 +109,6 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Block>
|
<FormBlockWrapper {actionType} {dataSource} {rowId} {noRowsMessage}>
|
||||||
{#if actionType === "Create"}
|
<InnerFormBlock {...innerProps} />
|
||||||
<BlockComponent
|
</FormBlockWrapper>
|
||||||
type="container"
|
|
||||||
props={{
|
|
||||||
direction: "column",
|
|
||||||
hAlign: "left",
|
|
||||||
vAlign: "stretch",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<InnerFormBlock {...innerProps} />
|
|
||||||
</BlockComponent>
|
|
||||||
{:else}
|
|
||||||
<BlockComponent
|
|
||||||
type="dataprovider"
|
|
||||||
context="provider"
|
|
||||||
bind:id={providerId}
|
|
||||||
props={{
|
|
||||||
dataSource,
|
|
||||||
filter,
|
|
||||||
limit: 1,
|
|
||||||
paginate: false,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<BlockComponent
|
|
||||||
type="repeater"
|
|
||||||
context="repeater"
|
|
||||||
bind:id={repeaterId}
|
|
||||||
props={{
|
|
||||||
dataProvider,
|
|
||||||
noRowsMessage: noRowsMessage || "We couldn't find a row to display",
|
|
||||||
direction: "column",
|
|
||||||
hAlign: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<InnerFormBlock {...innerProps} />
|
|
||||||
</BlockComponent>
|
|
||||||
</BlockComponent>
|
|
||||||
{/if}
|
|
||||||
</Block>
|
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
<script>
|
||||||
|
import BlockComponent from "components/BlockComponent.svelte"
|
||||||
|
import Block from "components/Block.svelte"
|
||||||
|
import { makePropSafe as safe } from "@budibase/string-templates"
|
||||||
|
import { getContext } from "svelte"
|
||||||
|
|
||||||
|
export let actionType
|
||||||
|
export let dataSource
|
||||||
|
export let rowId
|
||||||
|
export let noRowsMessage
|
||||||
|
|
||||||
|
const component = getContext("component")
|
||||||
|
|
||||||
|
$: providerId = `${$component.id}-provider`
|
||||||
|
$: dataProvider = `{{ literal ${safe(providerId)} }}`
|
||||||
|
$: filter = [
|
||||||
|
{
|
||||||
|
field: "_id",
|
||||||
|
operator: "equal",
|
||||||
|
type: "string",
|
||||||
|
value: !rowId ? `{{ ${safe("url")}.${safe("id")} }}` : rowId,
|
||||||
|
valueType: "Binding",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Block>
|
||||||
|
{#if actionType === "Create"}
|
||||||
|
<BlockComponent
|
||||||
|
type="container"
|
||||||
|
props={{
|
||||||
|
direction: "column",
|
||||||
|
hAlign: "left",
|
||||||
|
vAlign: "stretch",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</BlockComponent>
|
||||||
|
{:else}
|
||||||
|
<BlockComponent
|
||||||
|
type="dataprovider"
|
||||||
|
context="provider"
|
||||||
|
props={{
|
||||||
|
dataSource,
|
||||||
|
filter,
|
||||||
|
limit: 1,
|
||||||
|
paginate: false,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<BlockComponent
|
||||||
|
type="repeater"
|
||||||
|
context="repeater"
|
||||||
|
props={{
|
||||||
|
dataProvider,
|
||||||
|
noRowsMessage: noRowsMessage || "We couldn't find a row to display",
|
||||||
|
direction: "column",
|
||||||
|
hAlign: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</BlockComponent>
|
||||||
|
</BlockComponent>
|
||||||
|
{/if}
|
||||||
|
</Block>
|
|
@ -4,3 +4,4 @@ export { default as repeaterblock } from "./RepeaterBlock.svelte"
|
||||||
export { default as formblock } from "./form/FormBlock.svelte"
|
export { default as formblock } from "./form/FormBlock.svelte"
|
||||||
export { default as chartblock } from "./ChartBlock.svelte"
|
export { default as chartblock } from "./ChartBlock.svelte"
|
||||||
export { default as rowexplorer } from "./RowExplorer.svelte"
|
export { default as rowexplorer } from "./RowExplorer.svelte"
|
||||||
|
export { default as multistepformblock } from "./MultiStepFormblock.svelte"
|
||||||
|
|
|
@ -137,21 +137,23 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.error :global(svg),
|
||||||
|
.helpText :global(svg) {
|
||||||
|
width: 13px;
|
||||||
|
margin-right: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
.error {
|
.error {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-top: var(--spectrum-global-dimension-size-75);
|
margin-top: var(--spectrum-global-dimension-size-75);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error :global(svg) {
|
.error :global(svg) {
|
||||||
width: 14px;
|
|
||||||
color: var(
|
color: var(
|
||||||
--spectrum-semantic-negative-color-default,
|
--spectrum-semantic-negative-color-default,
|
||||||
var(--spectrum-global-color-red-500)
|
var(--spectrum-global-color-red-500)
|
||||||
);
|
);
|
||||||
margin-right: 4px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.error span {
|
.error span {
|
||||||
color: var(
|
color: var(
|
||||||
--spectrum-semantic-negative-color-default,
|
--spectrum-semantic-negative-color-default,
|
||||||
|
@ -165,17 +167,14 @@
|
||||||
margin-top: var(--spectrum-global-dimension-size-75);
|
margin-top: var(--spectrum-global-dimension-size-75);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.helpText :global(svg) {
|
.helpText :global(svg) {
|
||||||
width: 14px;
|
color: var(--spectrum-global-color-gray-600);
|
||||||
color: var(--grey-7);
|
|
||||||
margin-right: 6px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.helpText span {
|
.helpText span {
|
||||||
color: var(--grey-5);
|
color: var(--spectrum-global-color-gray-800);
|
||||||
font-size: var(--spectrum-global-dimension-font-size-75);
|
font-size: var(--spectrum-global-dimension-font-size-75);
|
||||||
}
|
}
|
||||||
|
|
||||||
.spectrum-FieldLabel--right,
|
.spectrum-FieldLabel--right,
|
||||||
.spectrum-FieldLabel--left {
|
.spectrum-FieldLabel--left {
|
||||||
padding-right: var(--spectrum-global-dimension-size-200);
|
padding-right: var(--spectrum-global-dimension-size-200);
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
let loaded = false
|
let loaded = false
|
||||||
let schema
|
let schema
|
||||||
let table
|
let table
|
||||||
let currentStep = writable(getInitialFormStep())
|
let currentStep = getContext("current-step") || writable(getInitialFormStep())
|
||||||
|
|
||||||
$: fetchSchema(dataSource)
|
$: fetchSchema(dataSource)
|
||||||
$: schemaKey = generateSchemaKey(schema)
|
$: schemaKey = generateSchemaKey(schema)
|
||||||
|
|
|
@ -423,10 +423,14 @@
|
||||||
}
|
}
|
||||||
const fieldId = field.fieldState.fieldId
|
const fieldId = field.fieldState.fieldId
|
||||||
const fieldElement = document.getElementById(fieldId)
|
const fieldElement = document.getElementById(fieldId)
|
||||||
fieldElement.focus({ preventScroll: true })
|
if (fieldElement) {
|
||||||
|
fieldElement.focus({ preventScroll: true })
|
||||||
|
}
|
||||||
const label = document.querySelector(`label[for="${fieldId}"]`)
|
const label = document.querySelector(`label[for="${fieldId}"]`)
|
||||||
label.style.scrollMargin = "100px"
|
if (label) {
|
||||||
label.scrollIntoView({ behavior: "smooth", block: "nearest" })
|
label.style.scrollMargin = "100px"
|
||||||
|
label.scrollIntoView({ behavior: "smooth", block: "nearest" })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Action context to pass to children
|
// Action context to pass to children
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<script>
|
<script>
|
||||||
import { onMount, onDestroy } from "svelte"
|
import { onMount, onDestroy } from "svelte"
|
||||||
import IndicatorSet from "./IndicatorSet.svelte"
|
import IndicatorSet from "./IndicatorSet.svelte"
|
||||||
import { builderStore, dndIsDragging } from "stores"
|
import { builderStore, dndIsDragging, hoverStore } from "stores"
|
||||||
|
|
||||||
$: componentId = $builderStore.hoverComponentId
|
$: componentId = $hoverStore.hoveredComponentId
|
||||||
$: zIndex = componentId === $builderStore.selectedComponentId ? 900 : 920
|
$: zIndex = componentId === $builderStore.selectedComponentId ? 900 : 920
|
||||||
|
|
||||||
const onMouseOver = e => {
|
const onMouseOver = e => {
|
||||||
|
@ -23,12 +23,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newId !== componentId) {
|
if (newId !== componentId) {
|
||||||
builderStore.actions.hoverComponent(newId)
|
hoverStore.actions.hoverComponent(newId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onMouseLeave = () => {
|
const onMouseLeave = () => {
|
||||||
builderStore.actions.hoverComponent(null)
|
hoverStore.actions.hoverComponent(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import ClientApp from "./components/ClientApp.svelte"
|
import ClientApp from "./components/ClientApp.svelte"
|
||||||
|
import UpdatingApp from "./components/UpdatingApp.svelte"
|
||||||
import {
|
import {
|
||||||
builderStore,
|
builderStore,
|
||||||
appStore,
|
appStore,
|
||||||
|
@ -7,6 +8,7 @@ import {
|
||||||
environmentStore,
|
environmentStore,
|
||||||
dndStore,
|
dndStore,
|
||||||
eventStore,
|
eventStore,
|
||||||
|
hoverStore,
|
||||||
} from "./stores"
|
} from "./stores"
|
||||||
import loadSpectrumIcons from "@budibase/bbui/spectrum-icons-rollup.js"
|
import loadSpectrumIcons from "@budibase/bbui/spectrum-icons-rollup.js"
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
|
@ -32,7 +34,6 @@ const loadBudibase = async () => {
|
||||||
layout: window["##BUDIBASE_PREVIEW_LAYOUT##"],
|
layout: window["##BUDIBASE_PREVIEW_LAYOUT##"],
|
||||||
screen: window["##BUDIBASE_PREVIEW_SCREEN##"],
|
screen: window["##BUDIBASE_PREVIEW_SCREEN##"],
|
||||||
selectedComponentId: window["##BUDIBASE_SELECTED_COMPONENT_ID##"],
|
selectedComponentId: window["##BUDIBASE_SELECTED_COMPONENT_ID##"],
|
||||||
hoverComponentId: window["##BUDIBASE_HOVER_COMPONENT_ID##"],
|
|
||||||
previewId: window["##BUDIBASE_PREVIEW_ID##"],
|
previewId: window["##BUDIBASE_PREVIEW_ID##"],
|
||||||
theme: window["##BUDIBASE_PREVIEW_THEME##"],
|
theme: window["##BUDIBASE_PREVIEW_THEME##"],
|
||||||
customTheme: window["##BUDIBASE_PREVIEW_CUSTOM_THEME##"],
|
customTheme: window["##BUDIBASE_PREVIEW_CUSTOM_THEME##"],
|
||||||
|
@ -52,6 +53,13 @@ const loadBudibase = async () => {
|
||||||
window["##BUDIBASE_APP_EMBEDDED##"] === "true"
|
window["##BUDIBASE_APP_EMBEDDED##"] === "true"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (window.MIGRATING_APP) {
|
||||||
|
new UpdatingApp({
|
||||||
|
target: window.document.body,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch environment info
|
// Fetch environment info
|
||||||
if (!get(environmentStore)?.loaded) {
|
if (!get(environmentStore)?.loaded) {
|
||||||
await environmentStore.actions.fetchEnvironment()
|
await environmentStore.actions.fetchEnvironment()
|
||||||
|
@ -76,6 +84,10 @@ const loadBudibase = async () => {
|
||||||
} else {
|
} else {
|
||||||
dndStore.actions.reset()
|
dndStore.actions.reset()
|
||||||
}
|
}
|
||||||
|
} else if (type === "hover-component") {
|
||||||
|
hoverStore.actions.hoverComponent(data)
|
||||||
|
} else if (type === "builder-meta") {
|
||||||
|
builderStore.actions.setMetadata(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ const createBuilderStore = () => {
|
||||||
inBuilder: false,
|
inBuilder: false,
|
||||||
screen: null,
|
screen: null,
|
||||||
selectedComponentId: null,
|
selectedComponentId: null,
|
||||||
hoverComponentId: null,
|
|
||||||
editMode: false,
|
editMode: false,
|
||||||
previewId: null,
|
previewId: null,
|
||||||
theme: null,
|
theme: null,
|
||||||
|
@ -18,22 +17,13 @@ const createBuilderStore = () => {
|
||||||
hiddenComponentIds: [],
|
hiddenComponentIds: [],
|
||||||
usedPlugins: null,
|
usedPlugins: null,
|
||||||
eventResolvers: {},
|
eventResolvers: {},
|
||||||
|
metadata: null,
|
||||||
|
|
||||||
// Legacy - allow the builder to specify a layout
|
// Legacy - allow the builder to specify a layout
|
||||||
layout: null,
|
layout: null,
|
||||||
}
|
}
|
||||||
const store = writable(initialState)
|
const store = writable(initialState)
|
||||||
const actions = {
|
const actions = {
|
||||||
hoverComponent: id => {
|
|
||||||
if (id === get(store).hoverComponentId) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
store.update(state => ({
|
|
||||||
...state,
|
|
||||||
hoverComponentId: id,
|
|
||||||
}))
|
|
||||||
eventStore.actions.dispatchEvent("hover-component", { id })
|
|
||||||
},
|
|
||||||
selectComponent: id => {
|
selectComponent: id => {
|
||||||
if (id === get(store).selectedComponentId) {
|
if (id === get(store).selectedComponentId) {
|
||||||
return
|
return
|
||||||
|
@ -123,6 +113,12 @@ const createBuilderStore = () => {
|
||||||
parentType,
|
parentType,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
setMetadata: metadata => {
|
||||||
|
store.update(state => ({
|
||||||
|
...state,
|
||||||
|
metadata,
|
||||||
|
}))
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...store,
|
...store,
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { get, writable } from "svelte/store"
|
||||||
|
import { eventStore } from "./events.js"
|
||||||
|
|
||||||
|
const createHoverStore = () => {
|
||||||
|
const store = writable({
|
||||||
|
hoveredComponentId: null,
|
||||||
|
})
|
||||||
|
|
||||||
|
const hoverComponent = id => {
|
||||||
|
if (id === get(store).hoveredComponentId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
store.set({ hoveredComponentId: id })
|
||||||
|
eventStore.actions.dispatchEvent("hover-component", { id })
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...store,
|
||||||
|
actions: {
|
||||||
|
hoverComponent,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const hoverStore = createHoverStore()
|
|
@ -27,6 +27,7 @@ export {
|
||||||
dndIsDragging,
|
dndIsDragging,
|
||||||
} from "./dnd"
|
} from "./dnd"
|
||||||
export { sidePanelStore } from "./sidePanel"
|
export { sidePanelStore } from "./sidePanel"
|
||||||
|
export { hoverStore } from "./hover"
|
||||||
|
|
||||||
// Context stores are layered and duplicated, so it is not a singleton
|
// Context stores are layered and duplicated, so it is not a singleton
|
||||||
export { createContextStore } from "./context"
|
export { createContextStore } from "./context"
|
||||||
|
|
|
@ -33,6 +33,7 @@ import { buildEnvironmentVariableEndpoints } from "./environmentVariables"
|
||||||
import { buildEventEndpoints } from "./events"
|
import { buildEventEndpoints } from "./events"
|
||||||
import { buildAuditLogsEndpoints } from "./auditLogs"
|
import { buildAuditLogsEndpoints } from "./auditLogs"
|
||||||
import { buildLogsEndpoints } from "./logs"
|
import { buildLogsEndpoints } from "./logs"
|
||||||
|
import { buildMigrationEndpoints } from "./migrations"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Random identifier to uniquely identify a session in a tab. This is
|
* Random identifier to uniquely identify a session in a tab. This is
|
||||||
|
@ -298,6 +299,7 @@ export const createAPIClient = config => {
|
||||||
...buildEventEndpoints(API),
|
...buildEventEndpoints(API),
|
||||||
...buildAuditLogsEndpoints(API),
|
...buildAuditLogsEndpoints(API),
|
||||||
...buildLogsEndpoints(API),
|
...buildLogsEndpoints(API),
|
||||||
|
...buildMigrationEndpoints(API),
|
||||||
viewV2: buildViewV2Endpoints(API),
|
viewV2: buildViewV2Endpoints(API),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
export const buildMigrationEndpoints = API => ({
|
||||||
|
/**
|
||||||
|
* Gets the info about the current app migration
|
||||||
|
*/
|
||||||
|
getMigrationStatus: async () => {
|
||||||
|
return await API.get({
|
||||||
|
url: "/api/migrations/status",
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue