merge develop into branch
|
@ -1,6 +1,6 @@
|
||||||
name: Budibase Release
|
name: Budibase Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
@ -9,20 +9,20 @@ env:
|
||||||
POSTHOG_TOKEN: ${{ secrets.POSTHOG_TOKEN }}
|
POSTHOG_TOKEN: ${{ secrets.POSTHOG_TOKEN }}
|
||||||
POSTHOG_URL: ${{ secrets.POSTHOG_URL }}
|
POSTHOG_URL: ${{ secrets.POSTHOG_URL }}
|
||||||
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
|
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-node@v1
|
- uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 12.x
|
node-version: 12.x
|
||||||
- run: yarn
|
- run: yarn
|
||||||
- run: yarn bootstrap
|
- run: yarn bootstrap
|
||||||
- run: yarn lint
|
- run: yarn lint
|
||||||
- run: yarn build
|
- run: yarn build
|
||||||
- run: yarn test
|
- run: yarn test
|
||||||
|
|
||||||
- name: Configure AWS Credentials
|
- name: Configure AWS Credentials
|
||||||
|
@ -35,19 +35,19 @@ jobs:
|
||||||
- name: Publish budibase packages to NPM
|
- name: Publish budibase packages to NPM
|
||||||
env:
|
env:
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
# setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default
|
# setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default
|
||||||
git config user.name "Budibase Release Bot"
|
git config user.name "Budibase Release Bot"
|
||||||
git config user.email "<>"
|
git config user.email "<>"
|
||||||
echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} >> .npmrc
|
echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} >> .npmrc
|
||||||
yarn release
|
yarn release
|
||||||
|
|
||||||
- name: Get Previous tag
|
- name: 'Get Previous tag'
|
||||||
id: previoustag
|
id: previoustag
|
||||||
uses: "WyriHaximus/github-action-get-previous-tag@v1"
|
uses: "WyriHaximus/github-action-get-previous-tag@v1"
|
||||||
|
|
||||||
- name: Build/release Docker images
|
- name: Build/release Docker images
|
||||||
run: |
|
run: |
|
||||||
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
|
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
|
||||||
yarn build
|
yarn build
|
||||||
yarn build:docker
|
yarn build:docker
|
||||||
|
@ -68,4 +68,3 @@ jobs:
|
||||||
charts_dir: docs
|
charts_dir: docs
|
||||||
env:
|
env:
|
||||||
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
|
3
LICENSE
|
@ -5,8 +5,7 @@ Each Budibase package has its own license:
|
||||||
builder: GPLv3
|
builder: GPLv3
|
||||||
server: GPLv3
|
server: GPLv3
|
||||||
client: MPLv2.0
|
client: MPLv2.0
|
||||||
standard-components: MPLv2.0
|
|
||||||
|
|
||||||
You can consider Budibase to be GPLv3 licensed.
|
You can consider Budibase to be GPLv3 licensed.
|
||||||
|
|
||||||
The apps that you build with Budibase do not fall under GPLv3 - hence why our components and client library are licensed differently.
|
The apps that you build with Budibase do not fall under GPLv3 - hence why our components and client library are licensed differently.
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Versions
|
||||||
|
|
||||||
|
As an open source product, we will only patch the latest major version for security vulnerabilities. Previous versions of budibase will not be retroactively patched.
|
||||||
|
|
||||||
|
## Disclosing
|
||||||
|
|
||||||
|
You can get in touch with us regarding a vulnerability via email at community@budibase.com.
|
||||||
|
|
||||||
|
You can also disclose via huntr.dev. If you believe you have found a vulnerability, please disclose it on huntr and let us know.
|
||||||
|
|
||||||
|
https://huntr.dev/bounties/disclose
|
||||||
|
|
||||||
|
This will enable us to review the vulnerability and potentially reward you for your work.
|
|
@ -51,6 +51,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}
|
||||||
|
ACCOUNT_PORTAL_URL: https://portal.budi.live
|
||||||
volumes:
|
volumes:
|
||||||
- ./logs:/logs
|
- ./logs:/logs
|
||||||
depends_on:
|
depends_on:
|
||||||
|
@ -107,7 +108,7 @@ services:
|
||||||
depends_on:
|
depends_on:
|
||||||
- couchdb-service
|
- couchdb-service
|
||||||
command: ["sh","-c","sleep 10 && $${PUT_CALL}/_users && $${PUT_CALL}/_replicator; fg;"]
|
command: ["sh","-c","sleep 10 && $${PUT_CALL}/_users && $${PUT_CALL}/_replicator; fg;"]
|
||||||
|
|
||||||
redis-service:
|
redis-service:
|
||||||
restart: always
|
restart: always
|
||||||
image: redis
|
image: redis
|
||||||
|
@ -116,9 +117,11 @@ services:
|
||||||
- "${REDIS_PORT}:6379"
|
- "${REDIS_PORT}:6379"
|
||||||
volumes:
|
volumes:
|
||||||
- redis_data:/data
|
- redis_data:/data
|
||||||
|
|
||||||
watchtower-service:
|
watchtower-service:
|
||||||
image: containrrr/watchtower
|
image: containrrr/watchtower
|
||||||
|
ports:
|
||||||
|
- "${WATCHTOWER_PORT}:8080"
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
command: --debug --http-api-update bbapps bbworker
|
command: --debug --http-api-update bbapps bbworker
|
||||||
|
@ -128,8 +131,6 @@ services:
|
||||||
- WATCHTOWER_CLEANUP=true
|
- WATCHTOWER_CLEANUP=true
|
||||||
labels:
|
labels:
|
||||||
- "com.centurylinklabs.watchtower.enable=false"
|
- "com.centurylinklabs.watchtower.enable=false"
|
||||||
ports:
|
|
||||||
- 6161:8080
|
|
||||||
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
@ -17,4 +17,5 @@ WORKER_PORT=4003
|
||||||
MINIO_PORT=4004
|
MINIO_PORT=4004
|
||||||
COUCH_DB_PORT=4005
|
COUCH_DB_PORT=4005
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
|
WATCHTOWER_PORT=6161
|
||||||
BUDIBASE_ENVIRONMENT=PRODUCTION
|
BUDIBASE_ENVIRONMENT=PRODUCTION
|
||||||
|
|
|
@ -87,6 +87,8 @@ spec:
|
||||||
{{ end }}
|
{{ end }}
|
||||||
- name: SELF_HOSTED
|
- name: SELF_HOSTED
|
||||||
value: {{ .Values.globals.selfHosted | quote }}
|
value: {{ .Values.globals.selfHosted | quote }}
|
||||||
|
- name: ACCOUNT_PORTAL_URL
|
||||||
|
value: {{ .Values.globals.accountPortalUrl | quote }}
|
||||||
image: budibase/worker
|
image: budibase/worker
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
name: bbworker
|
name: bbworker
|
||||||
|
|
|
@ -44,7 +44,7 @@ ingress:
|
||||||
nginx: true
|
nginx: true
|
||||||
certificateArn: ""
|
certificateArn: ""
|
||||||
className: ""
|
className: ""
|
||||||
annotations:
|
annotations:
|
||||||
kubernetes.io/ingress.class: nginx
|
kubernetes.io/ingress.class: nginx
|
||||||
hosts:
|
hosts:
|
||||||
- host: # change if using custom domain
|
- host: # change if using custom domain
|
||||||
|
@ -55,7 +55,7 @@ ingress:
|
||||||
service:
|
service:
|
||||||
name: proxy-service
|
name: proxy-service
|
||||||
port:
|
port:
|
||||||
number: 10000
|
number: 10000
|
||||||
|
|
||||||
resources: {}
|
resources: {}
|
||||||
# We usually recommend not to specify default resources and to leave this as a conscious
|
# We usually recommend not to specify default resources and to leave this as a conscious
|
||||||
|
@ -86,9 +86,10 @@ globals:
|
||||||
budibaseEnv: PRODUCTION
|
budibaseEnv: PRODUCTION
|
||||||
enableAnalytics: false
|
enableAnalytics: false
|
||||||
posthogToken: ""
|
posthogToken: ""
|
||||||
sentryDSN: ""
|
sentryDSN: ""
|
||||||
logLevel: info
|
logLevel: info
|
||||||
selfHosted: 1
|
selfHosted: 1
|
||||||
|
accountPortalUrL: ""
|
||||||
createSecrets: true # creates an internal API key, JWT secrets and redis password for you
|
createSecrets: true # creates an internal API key, JWT secrets and redis password for you
|
||||||
|
|
||||||
# if createSecrets is set to false, you can hard-code your secrets here
|
# if createSecrets is set to false, you can hard-code your secrets here
|
||||||
|
@ -120,7 +121,7 @@ services:
|
||||||
password: "" # only change if pointing to existing couch server
|
password: "" # only change if pointing to existing couch server
|
||||||
port: 5984
|
port: 5984
|
||||||
storage: 100Mi
|
storage: 100Mi
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
enabled: true # disable if using external redis
|
enabled: true # disable if using external redis
|
||||||
port: 6379
|
port: 6379
|
||||||
|
@ -128,15 +129,15 @@ services:
|
||||||
url: "" # only change if pointing to existing redis cluster and enabled: false
|
url: "" # only change if pointing to existing redis cluster and enabled: false
|
||||||
password: "budibase" # recommended to override if using built-in redis
|
password: "budibase" # recommended to override if using built-in redis
|
||||||
storage: 100Mi
|
storage: 100Mi
|
||||||
|
|
||||||
objectStore:
|
objectStore:
|
||||||
minio: true
|
minio: true
|
||||||
browser: true
|
browser: true
|
||||||
port: 9000
|
port: 9000
|
||||||
replicaCount: 1
|
replicaCount: 1
|
||||||
accessKey: "" # AWS_ACCESS_KEY if using S3 or existing minio access key
|
accessKey: "" # AWS_ACCESS_KEY if using S3 or existing minio access key
|
||||||
secretKey: "" # AWS_SECRET_ACCESS_KEY if using S3 or existing minio secret
|
secretKey: "" # AWS_SECRET_ACCESS_KEY if using S3 or existing minio secret
|
||||||
region: "" # AWS_REGION if using S3 or existing minio secret
|
region: "" # AWS_REGION if using S3 or existing minio secret
|
||||||
url: "" # only change if pointing to existing minio cluster and minio: false
|
url: "" # only change if pointing to existing minio cluster and minio: false
|
||||||
storage: 100Mi
|
storage: 100Mi
|
||||||
|
|
||||||
|
|
|
@ -28,27 +28,35 @@ static_resources:
|
||||||
- match: { prefix: "/builder" }
|
- match: { prefix: "/builder" }
|
||||||
route:
|
route:
|
||||||
cluster: app-service
|
cluster: app-service
|
||||||
|
|
||||||
- match: { prefix: "/app_" }
|
- match: { prefix: "/app_" }
|
||||||
route:
|
route:
|
||||||
cluster: app-service
|
cluster: app-service
|
||||||
|
|
||||||
# special case for worker admin API
|
# special cases for worker admin (deprecated), global and system API
|
||||||
|
- match: { prefix: "/api/global/" }
|
||||||
|
route:
|
||||||
|
cluster: worker-service
|
||||||
|
|
||||||
- match: { prefix: "/api/admin/" }
|
- match: { prefix: "/api/admin/" }
|
||||||
route:
|
route:
|
||||||
cluster: worker-service
|
cluster: worker-service
|
||||||
|
|
||||||
|
- match: { prefix: "/api/system/" }
|
||||||
|
route:
|
||||||
|
cluster: worker-service
|
||||||
|
|
||||||
- match: { path: "/" }
|
- match: { path: "/" }
|
||||||
route:
|
route:
|
||||||
cluster: app-service
|
cluster: app-service
|
||||||
|
|
||||||
# special case for when API requests are made, can just forward, not to minio
|
# special case for when API requests are made, can just forward, not to minio
|
||||||
- match: { prefix: "/api/" }
|
- match: { prefix: "/api/" }
|
||||||
route:
|
route:
|
||||||
cluster: app-service
|
cluster: app-service
|
||||||
|
|
||||||
- match: { prefix: "/worker/" }
|
- match: { prefix: "/worker/" }
|
||||||
route:
|
route:
|
||||||
cluster: worker-service
|
cluster: worker-service
|
||||||
prefix_rewrite: "/"
|
prefix_rewrite: "/"
|
||||||
|
|
||||||
|
@ -77,7 +85,7 @@ static_resources:
|
||||||
- lb_endpoints:
|
- lb_endpoints:
|
||||||
- endpoint:
|
- endpoint:
|
||||||
address:
|
address:
|
||||||
socket_address:
|
socket_address:
|
||||||
address: app-service.budibase.svc.cluster.local
|
address: app-service.budibase.svc.cluster.local
|
||||||
port_value: 4002
|
port_value: 4002
|
||||||
|
|
||||||
|
@ -105,7 +113,7 @@ static_resources:
|
||||||
- lb_endpoints:
|
- lb_endpoints:
|
||||||
- endpoint:
|
- endpoint:
|
||||||
address:
|
address:
|
||||||
socket_address:
|
socket_address:
|
||||||
address: worker-service.budibase.svc.cluster.local
|
address: worker-service.budibase.svc.cluster.local
|
||||||
port_value: 4001
|
port_value: 4001
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "0.9.105-alpha.31",
|
"version": "0.9.125-alpha.13",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
"setup": "node ./hosting/scripts/setup.js && yarn && yarn bootstrap && yarn build && yarn dev",
|
"setup": "node ./hosting/scripts/setup.js && yarn && yarn bootstrap && yarn build && yarn dev",
|
||||||
"bootstrap": "lerna link && lerna bootstrap",
|
"bootstrap": "lerna link && lerna bootstrap",
|
||||||
"build": "lerna run build",
|
"build": "lerna run build",
|
||||||
"initialise": "lerna run initialise",
|
|
||||||
"publishdev": "lerna run publishdev",
|
"publishdev": "lerna run publishdev",
|
||||||
"publishnpm": "yarn build && lerna publish --force-publish",
|
"publishnpm": "yarn build && lerna publish --force-publish",
|
||||||
"release": "yarn build && lerna publish patch --yes --force-publish",
|
"release": "yarn build && lerna publish patch --yes --force-publish",
|
||||||
|
@ -48,6 +47,8 @@
|
||||||
"release:helm": "./scripts/release_helm_chart.sh",
|
"release:helm": "./scripts/release_helm_chart.sh",
|
||||||
"multi:enable": "lerna run multi:enable",
|
"multi:enable": "lerna run multi:enable",
|
||||||
"multi:disable": "lerna run multi:disable",
|
"multi:disable": "lerna run multi:disable",
|
||||||
|
"selfhost:enable": "lerna run selfhost:enable",
|
||||||
|
"selfhost:disable": "lerna run selfhost:disable",
|
||||||
"postinstall": "husky install"
|
"postinstall": "husky install"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/auth",
|
"name": "@budibase/auth",
|
||||||
"version": "0.9.105-alpha.31",
|
"version": "0.9.125-alpha.13",
|
||||||
"description": "Authentication middlewares for budibase builder and apps",
|
"description": "Authentication middlewares for budibase builder and apps",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
|
|
|
@ -3,7 +3,29 @@ const { getTenantId, lookupTenantId, getGlobalDB } = require("../tenancy")
|
||||||
|
|
||||||
const EXPIRY_SECONDS = 3600
|
const EXPIRY_SECONDS = 3600
|
||||||
|
|
||||||
exports.getUser = async (userId, tenantId = null) => {
|
/**
|
||||||
|
* The default populate user function
|
||||||
|
*/
|
||||||
|
const populateFromDB = async (userId, tenantId) => {
|
||||||
|
const user = await getGlobalDB(tenantId).get(userId)
|
||||||
|
user.budibaseAccess = true
|
||||||
|
return user
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the requested user by id.
|
||||||
|
* Use redis cache to first read the user.
|
||||||
|
* If not present fallback to loading the user directly and re-caching.
|
||||||
|
* @param {*} userId the id of the user to get
|
||||||
|
* @param {*} tenantId the tenant of the user to get
|
||||||
|
* @param {*} populateUser function to provide the user for re-caching. default to couch db
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
exports.getUser = async (
|
||||||
|
userId,
|
||||||
|
tenantId = null,
|
||||||
|
populateUser = populateFromDB
|
||||||
|
) => {
|
||||||
if (!tenantId) {
|
if (!tenantId) {
|
||||||
try {
|
try {
|
||||||
tenantId = getTenantId()
|
tenantId = getTenantId()
|
||||||
|
@ -15,9 +37,13 @@ exports.getUser = async (userId, tenantId = null) => {
|
||||||
// try cache
|
// try cache
|
||||||
let user = await client.get(userId)
|
let user = await client.get(userId)
|
||||||
if (!user) {
|
if (!user) {
|
||||||
user = await getGlobalDB(tenantId).get(userId)
|
user = await populateUser(userId, tenantId)
|
||||||
client.store(userId, user, EXPIRY_SECONDS)
|
client.store(userId, user, EXPIRY_SECONDS)
|
||||||
}
|
}
|
||||||
|
if (user && !user.tenantId && tenantId) {
|
||||||
|
// make sure the tenant ID is always correct/set
|
||||||
|
user.tenantId = tenantId
|
||||||
|
}
|
||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,6 @@ exports.APP_PREFIX = DocumentTypes.APP + SEPARATOR
|
||||||
exports.APP_DEV = exports.APP_DEV_PREFIX = DocumentTypes.APP_DEV + SEPARATOR
|
exports.APP_DEV = exports.APP_DEV_PREFIX = DocumentTypes.APP_DEV + SEPARATOR
|
||||||
exports.SEPARATOR = SEPARATOR
|
exports.SEPARATOR = SEPARATOR
|
||||||
|
|
||||||
function isDevApp(app) {
|
|
||||||
return app.appId.startsWith(exports.APP_DEV_PREFIX)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If creating DB allDocs/query params with only a single top level ID this can be used, this
|
* If creating DB allDocs/query params with only a single top level ID this can be used, this
|
||||||
* is usually the case as most of our docs are top level e.g. tables, automations, users and so on.
|
* is usually the case as most of our docs are top level e.g. tables, automations, users and so on.
|
||||||
|
@ -62,6 +58,35 @@ function getDocParams(docType, docId = null, otherProps = {}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.isDevAppID = appId => {
|
||||||
|
return appId.startsWith(exports.APP_DEV_PREFIX)
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.isProdAppID = appId => {
|
||||||
|
return appId.startsWith(exports.APP_PREFIX) && !exports.isDevAppID(appId)
|
||||||
|
}
|
||||||
|
|
||||||
|
function isDevApp(app) {
|
||||||
|
return exports.isDevAppID(app.appId)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given an app ID this will attempt to retrieve the tenant ID from it.
|
||||||
|
* @return {null|string} The tenant ID found within the app ID.
|
||||||
|
*/
|
||||||
|
exports.getTenantIDFromAppID = appId => {
|
||||||
|
const split = appId.split(SEPARATOR)
|
||||||
|
const hasDev = split[1] === DocumentTypes.DEV
|
||||||
|
if ((hasDev && split.length === 3) || (!hasDev && split.length === 2)) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
if (hasDev) {
|
||||||
|
return split[2]
|
||||||
|
} else {
|
||||||
|
return split[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a new workspace ID.
|
* Generates a new workspace ID.
|
||||||
* @returns {string} The new workspace ID which the workspace doc can be stored under.
|
* @returns {string} The new workspace ID which the workspace doc can be stored under.
|
||||||
|
|
|
@ -11,6 +11,7 @@ const {
|
||||||
oidc,
|
oidc,
|
||||||
auditLog,
|
auditLog,
|
||||||
tenancy,
|
tenancy,
|
||||||
|
appTenancy,
|
||||||
} = require("./middleware")
|
} = require("./middleware")
|
||||||
const { setDB } = require("./db")
|
const { setDB } = require("./db")
|
||||||
const userCache = require("./cache/user")
|
const userCache = require("./cache/user")
|
||||||
|
@ -57,6 +58,7 @@ module.exports = {
|
||||||
oidc,
|
oidc,
|
||||||
jwt: require("jsonwebtoken"),
|
jwt: require("jsonwebtoken"),
|
||||||
buildTenancyMiddleware: tenancy,
|
buildTenancyMiddleware: tenancy,
|
||||||
|
buildAppTenancyMiddleware: appTenancy,
|
||||||
auditLog,
|
auditLog,
|
||||||
},
|
},
|
||||||
cache: {
|
cache: {
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
const {
|
||||||
|
isMultiTenant,
|
||||||
|
updateTenantId,
|
||||||
|
isTenantIdSet,
|
||||||
|
DEFAULT_TENANT_ID,
|
||||||
|
} = require("../tenancy")
|
||||||
|
const ContextFactory = require("../tenancy/FunctionContext")
|
||||||
|
const { getTenantIDFromAppID } = require("../db/utils")
|
||||||
|
|
||||||
|
module.exports = () => {
|
||||||
|
return ContextFactory.getMiddleware(ctx => {
|
||||||
|
// if not in multi-tenancy mode make sure its default and exit
|
||||||
|
if (!isMultiTenant()) {
|
||||||
|
updateTenantId(DEFAULT_TENANT_ID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// if tenant ID already set no need to continue
|
||||||
|
if (isTenantIdSet()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const appId = ctx.appId ? ctx.appId : ctx.user ? ctx.user.appId : null
|
||||||
|
const tenantId = getTenantIDFromAppID(appId) || DEFAULT_TENANT_ID
|
||||||
|
updateTenantId(tenantId)
|
||||||
|
})
|
||||||
|
}
|
|
@ -21,7 +21,10 @@ function finalise(
|
||||||
* The tenancy modules should not be used here and it should be assumed that the tenancy context
|
* The tenancy modules should not be used here and it should be assumed that the tenancy context
|
||||||
* has not yet been populated.
|
* has not yet been populated.
|
||||||
*/
|
*/
|
||||||
module.exports = (noAuthPatterns = [], opts = { publicAllowed: false }) => {
|
module.exports = (
|
||||||
|
noAuthPatterns = [],
|
||||||
|
opts = { publicAllowed: false, populateUser: null }
|
||||||
|
) => {
|
||||||
const noAuthOptions = noAuthPatterns ? buildMatcherRegex(noAuthPatterns) : []
|
const noAuthOptions = noAuthPatterns ? buildMatcherRegex(noAuthPatterns) : []
|
||||||
return async (ctx, next) => {
|
return async (ctx, next) => {
|
||||||
let publicEndpoint = false
|
let publicEndpoint = false
|
||||||
|
@ -46,7 +49,15 @@ module.exports = (noAuthPatterns = [], opts = { publicAllowed: false }) => {
|
||||||
error = "No session found"
|
error = "No session found"
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
user = await getUser(userId, session.tenantId)
|
if (opts && opts.populateUser) {
|
||||||
|
user = await getUser(
|
||||||
|
userId,
|
||||||
|
session.tenantId,
|
||||||
|
opts.populateUser(ctx)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
user = await getUser(userId, session.tenantId)
|
||||||
|
}
|
||||||
delete user.password
|
delete user.password
|
||||||
authenticated = true
|
authenticated = true
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ const oidc = require("./passport/oidc")
|
||||||
const authenticated = require("./authenticated")
|
const authenticated = require("./authenticated")
|
||||||
const auditLog = require("./auditLog")
|
const auditLog = require("./auditLog")
|
||||||
const tenancy = require("./tenancy")
|
const tenancy = require("./tenancy")
|
||||||
|
const appTenancy = require("./appTenancy")
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
google,
|
google,
|
||||||
|
@ -14,4 +15,5 @@ module.exports = {
|
||||||
authenticated,
|
authenticated,
|
||||||
auditLog,
|
auditLog,
|
||||||
tenancy,
|
tenancy,
|
||||||
|
appTenancy,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,17 @@ const { setTenantId } = require("../tenancy")
|
||||||
const ContextFactory = require("../tenancy/FunctionContext")
|
const ContextFactory = require("../tenancy/FunctionContext")
|
||||||
const { buildMatcherRegex, matches } = require("./matchers")
|
const { buildMatcherRegex, matches } = require("./matchers")
|
||||||
|
|
||||||
module.exports = (allowQueryStringPatterns, noTenancyPatterns) => {
|
module.exports = (
|
||||||
|
allowQueryStringPatterns,
|
||||||
|
noTenancyPatterns,
|
||||||
|
opts = { noTenancyRequired: false }
|
||||||
|
) => {
|
||||||
const allowQsOptions = buildMatcherRegex(allowQueryStringPatterns)
|
const allowQsOptions = buildMatcherRegex(allowQueryStringPatterns)
|
||||||
const noTenancyOptions = buildMatcherRegex(noTenancyPatterns)
|
const noTenancyOptions = buildMatcherRegex(noTenancyPatterns)
|
||||||
|
|
||||||
return ContextFactory.getMiddleware(ctx => {
|
return ContextFactory.getMiddleware(ctx => {
|
||||||
const allowNoTenant = !!matches(ctx, noTenancyOptions)
|
const allowNoTenant =
|
||||||
|
opts.noTenancyRequired || !!matches(ctx, noTenancyOptions)
|
||||||
const allowQs = !!matches(ctx, allowQsOptions)
|
const allowQs = !!matches(ctx, allowQsOptions)
|
||||||
setTenantId(ctx, { allowQs, allowNoTenant })
|
setTenantId(ctx, { allowQs, allowNoTenant })
|
||||||
})
|
})
|
||||||
|
|
|
@ -56,9 +56,13 @@ function init() {
|
||||||
if (CLIENT) {
|
if (CLIENT) {
|
||||||
CLIENT.disconnect()
|
CLIENT.disconnect()
|
||||||
}
|
}
|
||||||
const { opts, host, port } = getRedisOptions(CLUSTERED)
|
|
||||||
|
const { redisProtocolUrl, opts, host, port } = getRedisOptions(CLUSTERED)
|
||||||
|
|
||||||
if (CLUSTERED) {
|
if (CLUSTERED) {
|
||||||
CLIENT = new Redis.Cluster([{ host, port }], opts)
|
CLIENT = new Redis.Cluster([{ host, port }], opts)
|
||||||
|
} else if (redisProtocolUrl) {
|
||||||
|
CLIENT = new Redis(redisProtocolUrl)
|
||||||
} else {
|
} else {
|
||||||
CLIENT = new Redis(opts)
|
CLIENT = new Redis(opts)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,17 +8,27 @@ const REDIS_PASSWORD = !env.REDIS_PASSWORD ? "budibase" : env.REDIS_PASSWORD
|
||||||
|
|
||||||
exports.Databases = {
|
exports.Databases = {
|
||||||
PW_RESETS: "pwReset",
|
PW_RESETS: "pwReset",
|
||||||
|
VERIFICATIONS: "verification",
|
||||||
INVITATIONS: "invitation",
|
INVITATIONS: "invitation",
|
||||||
DEV_LOCKS: "devLocks",
|
DEV_LOCKS: "devLocks",
|
||||||
DEBOUNCE: "debounce",
|
DEBOUNCE: "debounce",
|
||||||
SESSIONS: "session",
|
SESSIONS: "session",
|
||||||
USER_CACHE: "users",
|
USER_CACHE: "users",
|
||||||
|
FLAGS: "flags",
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.SEPARATOR = SEPARATOR
|
exports.SEPARATOR = SEPARATOR
|
||||||
|
|
||||||
exports.getRedisOptions = (clustered = false) => {
|
exports.getRedisOptions = (clustered = false) => {
|
||||||
const [host, port] = REDIS_URL.split(":")
|
const [host, port, ...rest] = REDIS_URL.split(":")
|
||||||
|
|
||||||
|
let redisProtocolUrl
|
||||||
|
|
||||||
|
// fully qualified redis URL
|
||||||
|
if (rest.length && /rediss?/.test(host)) {
|
||||||
|
redisProtocolUrl = REDIS_URL
|
||||||
|
}
|
||||||
|
|
||||||
const opts = {
|
const opts = {
|
||||||
connectTimeout: CONNECT_TIMEOUT_MS,
|
connectTimeout: CONNECT_TIMEOUT_MS,
|
||||||
}
|
}
|
||||||
|
@ -33,7 +43,7 @@ exports.getRedisOptions = (clustered = false) => {
|
||||||
opts.port = port
|
opts.port = port
|
||||||
opts.password = REDIS_PASSWORD
|
opts.password = REDIS_PASSWORD
|
||||||
}
|
}
|
||||||
return { opts, host, port }
|
return { opts, host, port, redisProtocolUrl }
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.addDbPrefix = (db, key) => {
|
exports.addDbPrefix = (db, key) => {
|
||||||
|
|
|
@ -21,9 +21,7 @@ exports.doInTenant = (tenantId, task) => {
|
||||||
cls.setOnContext(TENANT_ID, tenantId)
|
cls.setOnContext(TENANT_ID, tenantId)
|
||||||
|
|
||||||
// invoke the task
|
// invoke the task
|
||||||
const result = task()
|
return task()
|
||||||
|
|
||||||
return result
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/bbui",
|
"name": "@budibase/bbui",
|
||||||
"description": "A UI solution used in the different Budibase projects.",
|
"description": "A UI solution used in the different Budibase projects.",
|
||||||
"version": "0.9.105-alpha.31",
|
"version": "0.9.125-alpha.13",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"svelte": "src/index.js",
|
"svelte": "src/index.js",
|
||||||
"module": "dist/bbui.es.js",
|
"module": "dist/bbui.es.js",
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
export let dataCy = null
|
export let dataCy = null
|
||||||
export let size = "M"
|
export let size = "M"
|
||||||
export let active = false
|
export let active = false
|
||||||
|
export let fullWidth = false
|
||||||
|
|
||||||
function longPress(element) {
|
function longPress(element) {
|
||||||
if (!longPressable) return
|
if (!longPressable) return
|
||||||
|
@ -40,6 +41,7 @@
|
||||||
class:spectrum-ActionButton--quiet={quiet}
|
class:spectrum-ActionButton--quiet={quiet}
|
||||||
class:spectrum-ActionButton--emphasized={emphasized}
|
class:spectrum-ActionButton--emphasized={emphasized}
|
||||||
class:is-selected={selected}
|
class:is-selected={selected}
|
||||||
|
class:fullWidth
|
||||||
class="spectrum-ActionButton spectrum-ActionButton--size{size}"
|
class="spectrum-ActionButton spectrum-ActionButton--size{size}"
|
||||||
class:active
|
class:active
|
||||||
{disabled}
|
{disabled}
|
||||||
|
@ -71,6 +73,9 @@
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.fullWidth {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
.active,
|
.active,
|
||||||
.active svg {
|
.active svg {
|
||||||
color: var(--spectrum-global-color-blue-600);
|
color: var(--spectrum-global-color-blue-600);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
export let orange = false
|
export let orange = false
|
||||||
export let yellow = false
|
export let yellow = false
|
||||||
export let seafoam = false
|
export let seafoam = false
|
||||||
|
export let green = false
|
||||||
export let active = false
|
export let active = false
|
||||||
export let inactive = false
|
export let inactive = false
|
||||||
</script>
|
</script>
|
||||||
|
@ -17,6 +18,7 @@
|
||||||
class:spectrum-Label--large={size === "L"}
|
class:spectrum-Label--large={size === "L"}
|
||||||
class:spectrum-Label--grey={grey}
|
class:spectrum-Label--grey={grey}
|
||||||
class:spectrum-Label--red={red}
|
class:spectrum-Label--red={red}
|
||||||
|
class:spectrum-Label--green={green}
|
||||||
class:spectrum-Label--orange={orange}
|
class:spectrum-Label--orange={orange}
|
||||||
class:spectrum-Label--yellow={yellow}
|
class:spectrum-Label--yellow={yellow}
|
||||||
class:spectrum-Label--seafoam={seafoam}
|
class:spectrum-Label--seafoam={seafoam}
|
||||||
|
|
|
@ -6,9 +6,8 @@
|
||||||
import Heading from "../Typography/Heading.svelte"
|
import Heading from "../Typography/Heading.svelte"
|
||||||
|
|
||||||
export let title
|
export let title
|
||||||
|
export let fillWidth
|
||||||
let visible = false
|
let visible = false
|
||||||
|
|
||||||
export function show() {
|
export function show() {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
return
|
return
|
||||||
|
@ -34,7 +33,7 @@
|
||||||
|
|
||||||
{#if visible}
|
{#if visible}
|
||||||
<Portal>
|
<Portal>
|
||||||
<section class="drawer" transition:slide>
|
<section class:fillWidth class="drawer" transition:slide>
|
||||||
<header>
|
<header>
|
||||||
<div class="text">
|
<div class="text">
|
||||||
<Heading size="XS">{title}</Heading>
|
<Heading size="XS">{title}</Heading>
|
||||||
|
@ -63,6 +62,10 @@
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fillWidth {
|
||||||
|
width: calc(100% - 260px) !important;
|
||||||
|
}
|
||||||
|
|
||||||
header {
|
header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
export let enableTime = true
|
export let enableTime = true
|
||||||
export let value = null
|
export let value = null
|
||||||
export let placeholder = null
|
export let placeholder = null
|
||||||
|
export let appendTo = null
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const flatpickrId = `${generateID()}-wrapper`
|
const flatpickrId = `${generateID()}-wrapper`
|
||||||
|
@ -24,6 +25,7 @@
|
||||||
altInput: true,
|
altInput: true,
|
||||||
altFormat: enableTime ? "F j Y, H:i" : "F j, Y",
|
altFormat: enableTime ? "F j Y, H:i" : "F j, Y",
|
||||||
wrap: true,
|
wrap: true,
|
||||||
|
appendTo,
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleChange = event => {
|
const handleChange = event => {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
export let error = null
|
export let error = null
|
||||||
export let enableTime = true
|
export let enableTime = true
|
||||||
export let placeholder = null
|
export let placeholder = null
|
||||||
|
export let appendTo = null
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = e => {
|
const onChange = e => {
|
||||||
|
@ -26,6 +27,7 @@
|
||||||
{value}
|
{value}
|
||||||
{placeholder}
|
{placeholder}
|
||||||
{enableTime}
|
{enableTime}
|
||||||
|
{appendTo}
|
||||||
on:change={onChange}
|
on:change={onChange}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
transition: color var(--spectrum-global-animation-duration-100, 130ms);
|
transition: color var(--spectrum-global-animation-duration-100, 130ms);
|
||||||
}
|
}
|
||||||
svg.hoverable:hover {
|
svg.hoverable:hover {
|
||||||
color: var(--spectrum-alias-icon-color-selected);
|
color: var(--spectrum-alias-icon-color-selected-hover);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,5 @@
|
||||||
.wide {
|
.wide {
|
||||||
max-width: none;
|
max-width: none;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: var(--spacing-xl) calc(var(--spacing-xl) * 2)
|
|
||||||
calc(var(--spacing-xl) * 2) calc(var(--spacing-xl) * 2);
|
|
||||||
min-height: calc(100% - var(--spacing-xl) * 3);
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -46,8 +46,10 @@
|
||||||
<h1
|
<h1
|
||||||
class="spectrum-Dialog-heading spectrum-Dialog-heading--noHeader"
|
class="spectrum-Dialog-heading spectrum-Dialog-heading--noHeader"
|
||||||
class:noDivider={!showDivider}
|
class:noDivider={!showDivider}
|
||||||
|
class:header-spacing={$$slots.header}
|
||||||
>
|
>
|
||||||
{title}
|
{title}
|
||||||
|
<slot name="header" />
|
||||||
</h1>
|
</h1>
|
||||||
{#if showDivider}
|
{#if showDivider}
|
||||||
<Divider size="M" />
|
<Divider size="M" />
|
||||||
|
@ -120,4 +122,9 @@
|
||||||
.close-icon :global(svg) {
|
.close-icon :global(svg) {
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header-spacing {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export let value = false
|
export let value = null
|
||||||
export let minValue = 0
|
export let minValue = 0
|
||||||
export let maxValue = 100
|
export let maxValue = 100
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
<div
|
<div
|
||||||
on:click
|
on:click
|
||||||
class:spectrum-ProgressCircle--indeterminate={!value}
|
class:spectrum-ProgressCircle--indeterminate={value == null}
|
||||||
class:spectrum-ProgressCircle--overBackground={overBackground}
|
class:spectrum-ProgressCircle--overBackground={overBackground}
|
||||||
class="spectrum-ProgressCircle spectrum-ProgressCircle--{convertSize(size)}"
|
class="spectrum-ProgressCircle spectrum-ProgressCircle--{convertSize(size)}"
|
||||||
>
|
>
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
class="spectrum-SideNav-item"
|
class="spectrum-SideNav-item"
|
||||||
class:is-selected={selected}
|
class:is-selected={selected}
|
||||||
class:is-disabled={disabled}
|
class:is-disabled={disabled}
|
||||||
|
on:click
|
||||||
>
|
>
|
||||||
{#if heading}
|
{#if heading}
|
||||||
<h2 class="spectrum-SideNav-heading" id="nav-heading-{heading}">
|
<h2 class="spectrum-SideNav-heading" id="nav-heading-{heading}">
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<script>
|
||||||
|
import "@spectrum-css/label/dist/index-vars.css"
|
||||||
|
import Badge from "../Badge/Badge.svelte"
|
||||||
|
export let value
|
||||||
|
|
||||||
|
const displayLimit = 5
|
||||||
|
|
||||||
|
$: badges = value?.slice(0, displayLimit) ?? []
|
||||||
|
$: leftover = (value?.length ?? 0) - badges.length
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#each badges as badge}
|
||||||
|
<Badge size="S" grey>{badge}</Badge>
|
||||||
|
{/each}
|
||||||
|
{#if leftover}
|
||||||
|
<div>+{leftover} more</div>
|
||||||
|
{/if}
|
|
@ -4,7 +4,7 @@
|
||||||
import DateTimeRenderer from "./DateTimeRenderer.svelte"
|
import DateTimeRenderer from "./DateTimeRenderer.svelte"
|
||||||
import RelationshipRenderer from "./RelationshipRenderer.svelte"
|
import RelationshipRenderer from "./RelationshipRenderer.svelte"
|
||||||
import AttachmentRenderer from "./AttachmentRenderer.svelte"
|
import AttachmentRenderer from "./AttachmentRenderer.svelte"
|
||||||
|
import ArrayRenderer from "./ArrayRenderer.svelte"
|
||||||
export let row
|
export let row
|
||||||
export let schema
|
export let schema
|
||||||
export let value
|
export let value
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
options: StringRenderer,
|
options: StringRenderer,
|
||||||
number: StringRenderer,
|
number: StringRenderer,
|
||||||
longform: StringRenderer,
|
longform: StringRenderer,
|
||||||
|
array: ArrayRenderer,
|
||||||
}
|
}
|
||||||
$: type = schema?.type ?? "string"
|
$: type = schema?.type ?? "string"
|
||||||
$: customRenderer = customRenderers?.find(x => x.column === schema?.name)
|
$: customRenderer = customRenderers?.find(x => x.column === schema?.name)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import "@spectrum-css/table/dist/index-vars.css"
|
import "@spectrum-css/table/dist/index-vars.css"
|
||||||
import CellRenderer from "./CellRenderer.svelte"
|
import CellRenderer from "./CellRenderer.svelte"
|
||||||
import SelectEditRenderer from "./SelectEditRenderer.svelte"
|
import SelectEditRenderer from "./SelectEditRenderer.svelte"
|
||||||
|
import { cloneDeep } from "lodash"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The expected schema is our normal couch schemas for our tables.
|
* The expected schema is our normal couch schemas for our tables.
|
||||||
|
@ -197,7 +198,7 @@
|
||||||
|
|
||||||
const editRow = (e, row) => {
|
const editRow = (e, row) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
dispatch("editrow", row)
|
dispatch("editrow", cloneDeep(row))
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleSelectRow = row => {
|
const toggleSelectRow = row => {
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<svg width="71" height="55" viewBox="0 0 71 55" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g clip-path="url(#clip0)">
|
||||||
|
<path d="M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z" fill="#5865F2"/>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0">
|
||||||
|
<rect width="71" height="55" fill="white"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.0 KiB |
|
@ -0,0 +1,33 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 25.4.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
viewBox="0 0 132 132" style="enable-background:new 0 0 132 132;" xml:space="preserve">
|
||||||
|
<style type="text/css">
|
||||||
|
.st0{fill:#E01E5A;}
|
||||||
|
.st1{fill:#36C5F0;}
|
||||||
|
.st2{fill:#2EB67D;}
|
||||||
|
.st3{fill:#ECB22E;}
|
||||||
|
</style>
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<path class="st0" d="M30.4,82.2c0,7.1-5.8,12.9-12.9,12.9S4.6,89.3,4.6,82.2c0-7.1,5.8-12.9,12.9-12.9h12.9V82.2z"/>
|
||||||
|
<path class="st0" d="M36.9,82.2c0-7.1,5.8-12.9,12.9-12.9s12.9,5.8,12.9,12.9v32.3c0,7.1-5.8,12.9-12.9,12.9s-12.9-5.8-12.9-12.9
|
||||||
|
C36.9,114.5,36.9,82.2,36.9,82.2z"/>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<path class="st1" d="M49.8,30.4c-7.1,0-12.9-5.8-12.9-12.9S42.7,4.6,49.8,4.6s12.9,5.8,12.9,12.9v12.9H49.8z"/>
|
||||||
|
<path class="st1" d="M49.8,36.9c7.1,0,12.9,5.8,12.9,12.9s-5.8,12.9-12.9,12.9H17.5c-7.1,0-12.9-5.8-12.9-12.9s5.8-12.9,12.9-12.9
|
||||||
|
C17.5,36.9,49.8,36.9,49.8,36.9z"/>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<path class="st2" d="M101.6,49.8c0-7.1,5.8-12.9,12.9-12.9c7.1,0,12.9,5.8,12.9,12.9s-5.8,12.9-12.9,12.9h-12.9V49.8z"/>
|
||||||
|
<path class="st2" d="M95.1,49.8c0,7.1-5.8,12.9-12.9,12.9c-7.1,0-12.9-5.8-12.9-12.9V17.5c0-7.1,5.8-12.9,12.9-12.9
|
||||||
|
c7.1,0,12.9,5.8,12.9,12.9V49.8z"/>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<path class="st3" d="M82.2,101.6c7.1,0,12.9,5.8,12.9,12.9c0,7.1-5.8,12.9-12.9,12.9c-7.1,0-12.9-5.8-12.9-12.9v-12.9H82.2z"/>
|
||||||
|
<path class="st3" d="M82.2,95.1c-7.1,0-12.9-5.8-12.9-12.9c0-7.1,5.8-12.9,12.9-12.9h32.3c7.1,0,12.9,5.8,12.9,12.9
|
||||||
|
c0,7.1-5.8,12.9-12.9,12.9H82.2z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 12 KiB |
|
@ -7,26 +7,42 @@ context("Create a automation", () => {
|
||||||
// https://on.cypress.io/interacting-with-elements
|
// https://on.cypress.io/interacting-with-elements
|
||||||
it("should create a automation", () => {
|
it("should create a automation", () => {
|
||||||
cy.createTestTableWithData()
|
cy.createTestTableWithData()
|
||||||
|
cy.wait(2000)
|
||||||
cy.contains("Automate").click()
|
cy.contains("Automate").click()
|
||||||
cy.get("[data-cy='new-screen'] > .spectrum-Icon").click()
|
cy.get("[data-cy='new-screen'] > .spectrum-Icon").click()
|
||||||
cy.get(".spectrum-Dialog-grid").within(() => {
|
cy.get(".modal-inner-wrapper").within(() => {
|
||||||
cy.get("input").type("Add Row")
|
cy.get("input").type("Add Row")
|
||||||
|
cy.contains("Row Created").click()
|
||||||
|
cy.wait(500)
|
||||||
cy.get(".spectrum-Button--cta").click()
|
cy.get(".spectrum-Button--cta").click()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Add trigger
|
// Setup trigger
|
||||||
cy.contains("Trigger").click()
|
cy.contains("Setup").click()
|
||||||
cy.contains("Row Created").click()
|
cy.get(".spectrum-Picker-label").click()
|
||||||
cy.get(".setup").within(() => {
|
cy.wait(500)
|
||||||
cy.get(".spectrum-Picker-label").click()
|
cy.contains("dog").click()
|
||||||
cy.contains("dog").click()
|
|
||||||
})
|
|
||||||
|
|
||||||
// Create action
|
// Create action
|
||||||
cy.contains("Action").click()
|
cy.contains("Add Action").click()
|
||||||
cy.contains("Create Row").click()
|
cy.get(".modal-inner-wrapper").within(() => {
|
||||||
cy.get(".setup").within(() => {
|
cy.wait(1000)
|
||||||
|
cy.contains("Create Row").trigger('mouseover').click().click()
|
||||||
|
cy.get(".spectrum-Button--cta").click()
|
||||||
|
})
|
||||||
|
cy.contains("Setup").click()
|
||||||
|
cy.get(".spectrum-Picker-label").click()
|
||||||
|
cy.contains("dog").click()
|
||||||
|
cy.get(".spectrum-Textfield-input")
|
||||||
|
.first()
|
||||||
|
.type("goodboy")
|
||||||
|
cy.get(".spectrum-Textfield-input")
|
||||||
|
.eq(1)
|
||||||
|
.type("11")
|
||||||
|
|
||||||
|
cy.contains("Run test").click()
|
||||||
|
cy.get(".modal-inner-wrapper").within(() => {
|
||||||
|
cy.wait(1000)
|
||||||
cy.get(".spectrum-Picker-label").click()
|
cy.get(".spectrum-Picker-label").click()
|
||||||
cy.contains("dog").click()
|
cy.contains("dog").click()
|
||||||
cy.get(".spectrum-Textfield-input")
|
cy.get(".spectrum-Textfield-input")
|
||||||
|
@ -35,19 +51,12 @@ context("Create a automation", () => {
|
||||||
cy.get(".spectrum-Textfield-input")
|
cy.get(".spectrum-Textfield-input")
|
||||||
.eq(1)
|
.eq(1)
|
||||||
.type("11")
|
.type("11")
|
||||||
|
cy.get(".spectrum-Textfield-input")
|
||||||
|
.eq(2)
|
||||||
|
.type("123456")
|
||||||
|
cy.get(".spectrum-Textfield-input")
|
||||||
|
.eq(3)
|
||||||
|
.type("123456")
|
||||||
})
|
})
|
||||||
|
|
||||||
// Save
|
|
||||||
cy.contains("Save Automation").click()
|
|
||||||
|
|
||||||
// Activate Automation
|
|
||||||
cy.get("[data-cy=activate-automation]").click()
|
|
||||||
})
|
|
||||||
|
|
||||||
it("should add row when a new row is added", () => {
|
|
||||||
cy.contains("Data").click()
|
|
||||||
cy.addRow(["Rover", 15])
|
|
||||||
cy.reload()
|
|
||||||
cy.contains("goodboy").should("have.text", "goodboy")
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -23,6 +23,7 @@ process.env.MINIO_SECRET_KEY = "budibase"
|
||||||
process.env.COUCH_DB_USER = "budibase"
|
process.env.COUCH_DB_USER = "budibase"
|
||||||
process.env.COUCH_DB_PASSWORD = "budibase"
|
process.env.COUCH_DB_PASSWORD = "budibase"
|
||||||
process.env.INTERNAL_API_KEY = "budibase"
|
process.env.INTERNAL_API_KEY = "budibase"
|
||||||
|
process.env.ALLOW_DEV_AUTOMATIONS = 1
|
||||||
|
|
||||||
// Stop info logs polluting test outputs
|
// Stop info logs polluting test outputs
|
||||||
process.env.LOG_LEVEL = "error"
|
process.env.LOG_LEVEL = "error"
|
||||||
|
|
|
@ -34,12 +34,11 @@ Cypress.Commands.add("createApp", name => {
|
||||||
cy.get(".spectrum-Modal")
|
cy.get(".spectrum-Modal")
|
||||||
.within(() => {
|
.within(() => {
|
||||||
cy.get("input").eq(0).type(name).should("have.value", name).blur()
|
cy.get("input").eq(0).type(name).should("have.value", name).blur()
|
||||||
cy.contains("Create app").click()
|
cy.get(".spectrum-ButtonGroup").contains("Create app").click()
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
cy.get(".selected > .content", {
|
cy.expandBudibaseConnection()
|
||||||
timeout: 20000,
|
cy.get(".nav-item.selected > .content").should("be.visible")
|
||||||
}).should("be.visible")
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -83,6 +82,7 @@ Cypress.Commands.add("createTable", tableName => {
|
||||||
|
|
||||||
Cypress.Commands.add("addColumn", (tableName, columnName, type) => {
|
Cypress.Commands.add("addColumn", (tableName, columnName, type) => {
|
||||||
// Select Table
|
// Select Table
|
||||||
|
cy.selectTable(tableName)
|
||||||
cy.contains(".nav-item", tableName).click()
|
cy.contains(".nav-item", tableName).click()
|
||||||
cy.contains("Create column").click()
|
cy.contains("Create column").click()
|
||||||
|
|
||||||
|
@ -161,3 +161,15 @@ Cypress.Commands.add("createScreen", (screenName, route) => {
|
||||||
cy.get(".spectrum-Button--cta").click()
|
cy.get(".spectrum-Button--cta").click()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Cypress.Commands.add("expandBudibaseConnection", () => {
|
||||||
|
if (Cypress.$(".nav-item > .content > .opened").length === 0) {
|
||||||
|
// expand the Budibase DB connection string
|
||||||
|
cy.get(".icon.arrow").eq(0).click()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
Cypress.Commands.add("selectTable", tableName => {
|
||||||
|
cy.expandBudibaseConnection()
|
||||||
|
cy.contains(".nav-item", tableName).click()
|
||||||
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/builder",
|
"name": "@budibase/builder",
|
||||||
"version": "0.9.105-alpha.31",
|
"version": "0.9.125-alpha.13",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -65,10 +65,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/bbui": "^0.9.105-alpha.31",
|
"@budibase/bbui": "^0.9.125-alpha.13",
|
||||||
"@budibase/client": "^0.9.105-alpha.31",
|
"@budibase/client": "^0.9.125-alpha.13",
|
||||||
"@budibase/colorpicker": "1.1.2",
|
"@budibase/colorpicker": "1.1.2",
|
||||||
"@budibase/string-templates": "^0.9.105-alpha.31",
|
"@budibase/string-templates": "^0.9.125-alpha.13",
|
||||||
"@sentry/browser": "5.19.1",
|
"@sentry/browser": "5.19.1",
|
||||||
"@spectrum-css/page": "^3.0.1",
|
"@spectrum-css/page": "^3.0.1",
|
||||||
"@spectrum-css/vars": "^3.0.1",
|
"@spectrum-css/vars": "^3.0.1",
|
||||||
|
|
|
@ -23,6 +23,7 @@ async function activate() {
|
||||||
if (posthogConfigured) {
|
if (posthogConfigured) {
|
||||||
posthog.init(process.env.POSTHOG_TOKEN, {
|
posthog.init(process.env.POSTHOG_TOKEN, {
|
||||||
autocapture: false,
|
autocapture: false,
|
||||||
|
capture_pageview: false,
|
||||||
api_host: process.env.POSTHOG_URL,
|
api_host: process.env.POSTHOG_URL,
|
||||||
})
|
})
|
||||||
posthog.set_config({ persistence: "cookie" })
|
posthog.set_config({ persistence: "cookie" })
|
||||||
|
@ -79,6 +80,7 @@ const isFeedbackTimeElapsed = sinceDateStr => {
|
||||||
const feedbackMilliseconds = feedbackHours * 60 * 60 * 1000
|
const feedbackMilliseconds = feedbackHours * 60 * 60 * 1000
|
||||||
return Date.now() > sinceDate + feedbackMilliseconds
|
return Date.now() > sinceDate + feedbackMilliseconds
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitFeedback(values) {
|
function submitFeedback(values) {
|
||||||
if (!analyticsEnabled || !process.env.POSTHOG_TOKEN) return
|
if (!analyticsEnabled || !process.env.POSTHOG_TOKEN) return
|
||||||
localStorage.setItem(FEEDBACK_SUBMITTED_KEY, Date.now())
|
localStorage.setItem(FEEDBACK_SUBMITTED_KEY, Date.now())
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { findComponent, findComponentPath } from "./storeUtils"
|
import {
|
||||||
|
findComponent,
|
||||||
|
findComponentPath,
|
||||||
|
findAllMatchingComponents,
|
||||||
|
} from "./storeUtils"
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
import { tables as tablesStore, queries as queriesStores } from "stores/backend"
|
import { tables as tablesStore, queries as queriesStores } from "stores/backend"
|
||||||
import { makePropSafe } from "@budibase/string-templates"
|
import { makePropSafe } from "@budibase/string-templates"
|
||||||
|
@ -18,7 +22,9 @@ export const getBindableProperties = (asset, componentId) => {
|
||||||
const userBindings = getUserBindings()
|
const userBindings = getUserBindings()
|
||||||
const urlBindings = getUrlBindings(asset)
|
const urlBindings = getUrlBindings(asset)
|
||||||
const deviceBindings = getDeviceBindings()
|
const deviceBindings = getDeviceBindings()
|
||||||
|
const stateBindings = getStateBindings()
|
||||||
return [
|
return [
|
||||||
|
...stateBindings,
|
||||||
...deviceBindings,
|
...deviceBindings,
|
||||||
...urlBindings,
|
...urlBindings,
|
||||||
...contextBindings,
|
...contextBindings,
|
||||||
|
@ -256,6 +262,22 @@ const getDeviceBindings = () => {
|
||||||
return bindings
|
return bindings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all state bindings that are globally available.
|
||||||
|
*/
|
||||||
|
const getStateBindings = () => {
|
||||||
|
let bindings = []
|
||||||
|
if (get(store).clientFeatures?.state) {
|
||||||
|
const safeState = makePropSafe("state")
|
||||||
|
bindings = getAllStateVariables().map(key => ({
|
||||||
|
type: "context",
|
||||||
|
runtimeBinding: `${safeState}.${makePropSafe(key)}`,
|
||||||
|
readableBinding: `State.${key}`,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
return bindings
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all bindable properties from URL parameters.
|
* Gets all bindable properties from URL parameters.
|
||||||
*/
|
*/
|
||||||
|
@ -458,3 +480,49 @@ export function runtimeToReadableBinding(bindableProperties, textWithBindings) {
|
||||||
"readableBinding"
|
"readableBinding"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of the keys of any state variables which are set anywhere
|
||||||
|
* in the app.
|
||||||
|
*/
|
||||||
|
export const getAllStateVariables = () => {
|
||||||
|
let allComponents = []
|
||||||
|
|
||||||
|
// Find all onClick settings in all layouts
|
||||||
|
get(store).layouts.forEach(layout => {
|
||||||
|
const components = findAllMatchingComponents(
|
||||||
|
layout.props,
|
||||||
|
c => c.onClick != null
|
||||||
|
)
|
||||||
|
allComponents = allComponents.concat(components || [])
|
||||||
|
})
|
||||||
|
|
||||||
|
// Find all onClick settings in all screens
|
||||||
|
get(store).screens.forEach(screen => {
|
||||||
|
const components = findAllMatchingComponents(
|
||||||
|
screen.props,
|
||||||
|
c => c.onClick != null
|
||||||
|
)
|
||||||
|
allComponents = allComponents.concat(components || [])
|
||||||
|
})
|
||||||
|
|
||||||
|
// Add state bindings for all state actions
|
||||||
|
let bindingSet = new Set()
|
||||||
|
allComponents.forEach(component => {
|
||||||
|
if (!Array.isArray(component.onClick)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
component.onClick.forEach(action => {
|
||||||
|
if (
|
||||||
|
action["##eventHandlerType"] === "Update State" &&
|
||||||
|
action.parameters?.type === "set" &&
|
||||||
|
action.parameters?.key &&
|
||||||
|
action.parameters?.value
|
||||||
|
) {
|
||||||
|
bindingSet.add(action.parameters.key)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return Array.from(bindingSet)
|
||||||
|
}
|
||||||
|
|
|
@ -13,6 +13,10 @@ export default class Automation {
|
||||||
return this.automation.definition.trigger
|
return this.automation.definition.trigger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addTestData(data) {
|
||||||
|
this.automation.testData = data
|
||||||
|
}
|
||||||
|
|
||||||
addBlock(block) {
|
addBlock(block) {
|
||||||
// Make sure to add trigger if doesn't exist
|
// Make sure to add trigger if doesn't exist
|
||||||
if (!this.hasTrigger() && block.type === "TRIGGER") {
|
if (!this.hasTrigger() && block.type === "TRIGGER") {
|
||||||
|
|
|
@ -17,7 +17,6 @@ const automationActions = store => ({
|
||||||
state.blockDefinitions = {
|
state.blockDefinitions = {
|
||||||
TRIGGER: jsonResponses[1].trigger,
|
TRIGGER: jsonResponses[1].trigger,
|
||||||
ACTION: jsonResponses[1].action,
|
ACTION: jsonResponses[1].action,
|
||||||
LOGIC: jsonResponses[1].logic,
|
|
||||||
}
|
}
|
||||||
// if previously selected find the new obj and select it
|
// if previously selected find the new obj and select it
|
||||||
if (selected) {
|
if (selected) {
|
||||||
|
@ -81,8 +80,16 @@ const automationActions = store => ({
|
||||||
},
|
},
|
||||||
trigger: async ({ automation }) => {
|
trigger: async ({ automation }) => {
|
||||||
const { _id } = automation
|
const { _id } = automation
|
||||||
const TRIGGER_AUTOMATION_URL = `/api/automations/${_id}/trigger`
|
return await api.post(`/api/automations/${_id}/trigger`)
|
||||||
return await api.post(TRIGGER_AUTOMATION_URL)
|
},
|
||||||
|
test: async ({ automation }, testData) => {
|
||||||
|
const { _id } = automation
|
||||||
|
const response = await api.post(`/api/automations/${_id}/test`, testData)
|
||||||
|
const json = await response.json()
|
||||||
|
store.update(state => {
|
||||||
|
state.selectedAutomation.testResults = json
|
||||||
|
return state
|
||||||
|
})
|
||||||
},
|
},
|
||||||
select: automation => {
|
select: automation => {
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
|
@ -91,6 +98,12 @@ const automationActions = store => ({
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
addTestDataToAutomation: data => {
|
||||||
|
store.update(state => {
|
||||||
|
state.selectedAutomation.addTestData(data)
|
||||||
|
return state
|
||||||
|
})
|
||||||
|
},
|
||||||
addBlockToAutomation: block => {
|
addBlockToAutomation: block => {
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
const newBlock = state.selectedAutomation.addBlock(cloneDeep(block))
|
const newBlock = state.selectedAutomation.addBlock(cloneDeep(block))
|
||||||
|
@ -132,7 +145,6 @@ export const getAutomationStore = () => {
|
||||||
blockDefinitions: {
|
blockDefinitions: {
|
||||||
TRIGGER: [],
|
TRIGGER: [],
|
||||||
ACTION: [],
|
ACTION: [],
|
||||||
LOGIC: [],
|
|
||||||
},
|
},
|
||||||
selectedAutomation: null,
|
selectedAutomation: null,
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,9 @@ const INITIAL_FRONTEND_STATE = {
|
||||||
spectrumThemes: false,
|
spectrumThemes: false,
|
||||||
intelligentLoading: false,
|
intelligentLoading: false,
|
||||||
deviceAwareness: false,
|
deviceAwareness: false,
|
||||||
|
state: false,
|
||||||
|
customThemes: false,
|
||||||
|
devicePreview: false,
|
||||||
},
|
},
|
||||||
currentFrontEndType: "none",
|
currentFrontEndType: "none",
|
||||||
selectedScreenId: "",
|
selectedScreenId: "",
|
||||||
|
@ -53,6 +56,8 @@ const INITIAL_FRONTEND_STATE = {
|
||||||
routes: {},
|
routes: {},
|
||||||
clientLibPath: "",
|
clientLibPath: "",
|
||||||
theme: "",
|
theme: "",
|
||||||
|
customTheme: {},
|
||||||
|
previewDevice: "desktop",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getFrontendStore = () => {
|
export const getFrontendStore = () => {
|
||||||
|
@ -77,6 +82,7 @@ export const getFrontendStore = () => {
|
||||||
layouts,
|
layouts,
|
||||||
screens,
|
screens,
|
||||||
theme: application.theme || "spectrum--light",
|
theme: application.theme || "spectrum--light",
|
||||||
|
customTheme: application.customTheme,
|
||||||
hasAppPackage: true,
|
hasAppPackage: true,
|
||||||
appInstance: application.instance,
|
appInstance: application.instance,
|
||||||
clientLibPath,
|
clientLibPath,
|
||||||
|
@ -110,6 +116,22 @@ export const getFrontendStore = () => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
customTheme: {
|
||||||
|
save: async customTheme => {
|
||||||
|
const appId = get(store).appId
|
||||||
|
const response = await api.put(`/api/applications/${appId}`, {
|
||||||
|
customTheme,
|
||||||
|
})
|
||||||
|
if (response.status === 200) {
|
||||||
|
store.update(state => {
|
||||||
|
state.customTheme = customTheme
|
||||||
|
return state
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
throw new Error("Error updating theme")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
routing: {
|
routing: {
|
||||||
fetch: async () => {
|
fetch: async () => {
|
||||||
const response = await api.get("/api/routing")
|
const response = await api.get("/api/routing")
|
||||||
|
@ -210,6 +232,12 @@ export const getFrontendStore = () => {
|
||||||
await store.actions.layouts.save(selectedAsset)
|
await store.actions.layouts.save(selectedAsset)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
setDevice: device => {
|
||||||
|
store.update(state => {
|
||||||
|
state.previewDevice = device
|
||||||
|
return state
|
||||||
|
})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
layouts: {
|
layouts: {
|
||||||
select: layoutId => {
|
select: layoutId => {
|
||||||
|
|
|
@ -43,6 +43,7 @@ const createScreen = table => {
|
||||||
tableId: table._id,
|
tableId: table._id,
|
||||||
type: "table",
|
type: "table",
|
||||||
},
|
},
|
||||||
|
size: "spectrum--medium",
|
||||||
})
|
})
|
||||||
|
|
||||||
const fieldGroup = new Component("@budibase/standard-components/fieldgroup")
|
const fieldGroup = new Component("@budibase/standard-components/fieldgroup")
|
||||||
|
|
|
@ -101,7 +101,6 @@ const createScreen = table => {
|
||||||
.instanceName("Form")
|
.instanceName("Form")
|
||||||
.customProps({
|
.customProps({
|
||||||
actionType: "Update",
|
actionType: "Update",
|
||||||
theme: "spectrum--lightest",
|
|
||||||
size: "spectrum--medium",
|
size: "spectrum--medium",
|
||||||
dataSource: {
|
dataSource: {
|
||||||
label: table.name,
|
label: table.name,
|
||||||
|
|
|
@ -65,6 +65,7 @@ const createScreen = table => {
|
||||||
tableId: table._id,
|
tableId: table._id,
|
||||||
type: "table",
|
type: "table",
|
||||||
},
|
},
|
||||||
|
size: "spectrum--medium",
|
||||||
paginate: true,
|
paginate: true,
|
||||||
limit: 8,
|
limit: 8,
|
||||||
})
|
})
|
||||||
|
|
|
@ -131,6 +131,7 @@ const fieldTypeToComponentMap = {
|
||||||
string: "stringfield",
|
string: "stringfield",
|
||||||
number: "numberfield",
|
number: "numberfield",
|
||||||
options: "optionsfield",
|
options: "optionsfield",
|
||||||
|
array: "multifieldselect",
|
||||||
boolean: "booleanfield",
|
boolean: "booleanfield",
|
||||||
longform: "longformfield",
|
longform: "longformfield",
|
||||||
datetime: "datetimefield",
|
datetime: "datetimefield",
|
||||||
|
@ -167,6 +168,13 @@ export function makeDatasourceFormComponents(datasource) {
|
||||||
optionsSource: "schema",
|
optionsSource: "schema",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if (fieldType === "array") {
|
||||||
|
component.customProps({
|
||||||
|
placeholder: "Choose an option",
|
||||||
|
optionsSource: "schema",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (fieldType === "link") {
|
if (fieldType === "link") {
|
||||||
let placeholder =
|
let placeholder =
|
||||||
fieldSchema.relationshipType === "one-to-many"
|
fieldSchema.relationshipType === "one-to-many"
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
<script>
|
<script>
|
||||||
import { automationStore } from "builderStore"
|
import { automationStore } from "builderStore"
|
||||||
import Flowchart from "./FlowChart/FlowChart.svelte"
|
import Flowchart from "./FlowChart/FlowChart.svelte"
|
||||||
import BlockList from "./BlockList.svelte"
|
|
||||||
|
|
||||||
$: automation = $automationStore.selectedAutomation?.automation
|
$: automation = $automationStore.selectedAutomation?.automation
|
||||||
|
|
||||||
function onSelect(block) {
|
function onSelect(block) {
|
||||||
automationStore.update(state => {
|
automationStore.update(state => {
|
||||||
state.selectedBlock = block
|
state.selectedBlock = block
|
||||||
|
@ -14,6 +12,5 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if automation}
|
{#if automation}
|
||||||
<BlockList />
|
|
||||||
<Flowchart {automation} {onSelect} />
|
<Flowchart {automation} {onSelect} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -1,108 +0,0 @@
|
||||||
<script>
|
|
||||||
import { sortBy } from "lodash/fp"
|
|
||||||
import { automationStore } from "builderStore"
|
|
||||||
import { ActionButton, Popover, Modal } from "@budibase/bbui"
|
|
||||||
import { DropdownContainer, DropdownItem } from "components/common/Dropdowns"
|
|
||||||
import CreateWebhookModal from "../Shared/CreateWebhookModal.svelte"
|
|
||||||
|
|
||||||
$: hasTrigger = $automationStore.selectedAutomation.hasTrigger()
|
|
||||||
$: tabs = [
|
|
||||||
{
|
|
||||||
label: "Trigger",
|
|
||||||
value: "TRIGGER",
|
|
||||||
icon: "Algorithm",
|
|
||||||
disabled: hasTrigger,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Action",
|
|
||||||
value: "ACTION",
|
|
||||||
icon: "Actions",
|
|
||||||
disabled: !hasTrigger,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Logic",
|
|
||||||
value: "LOGIC",
|
|
||||||
icon: "Filter",
|
|
||||||
disabled: !hasTrigger,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
let selectedIndex
|
|
||||||
let anchors = []
|
|
||||||
let popover
|
|
||||||
let webhookModal
|
|
||||||
$: selectedTab = selectedIndex == null ? null : tabs[selectedIndex].value
|
|
||||||
$: anchor = selectedIndex === -1 ? null : anchors[selectedIndex]
|
|
||||||
$: blocks = sortBy(entry => entry[1].name)(
|
|
||||||
Object.entries($automationStore.blockDefinitions[selectedTab] ?? {})
|
|
||||||
)
|
|
||||||
|
|
||||||
function onChangeTab(idx) {
|
|
||||||
selectedIndex = idx
|
|
||||||
popover.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
function closePopover() {
|
|
||||||
selectedIndex = null
|
|
||||||
popover.hide()
|
|
||||||
}
|
|
||||||
|
|
||||||
function addBlockToAutomation(stepId, blockDefinition) {
|
|
||||||
const newBlock = $automationStore.selectedAutomation.constructBlock(
|
|
||||||
selectedTab,
|
|
||||||
stepId,
|
|
||||||
blockDefinition
|
|
||||||
)
|
|
||||||
automationStore.actions.addBlockToAutomation(newBlock)
|
|
||||||
closePopover()
|
|
||||||
if (stepId === "WEBHOOK") {
|
|
||||||
webhookModal.show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="tab-container">
|
|
||||||
{#each tabs as tab, idx}
|
|
||||||
<div bind:this={anchors[idx]}>
|
|
||||||
<ActionButton
|
|
||||||
quiet
|
|
||||||
size="S"
|
|
||||||
icon={tab.icon}
|
|
||||||
disabled={tab.disabled}
|
|
||||||
on:click={tab.disabled ? null : () => onChangeTab(idx)}
|
|
||||||
>
|
|
||||||
{tab.label}
|
|
||||||
</ActionButton>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
<Popover
|
|
||||||
on:close={() => (selectedIndex = null)}
|
|
||||||
bind:this={popover}
|
|
||||||
{anchor}
|
|
||||||
align="left"
|
|
||||||
>
|
|
||||||
<DropdownContainer>
|
|
||||||
{#each blocks as [stepId, blockDefinition]}
|
|
||||||
<DropdownItem
|
|
||||||
icon={blockDefinition.icon}
|
|
||||||
title={blockDefinition.name}
|
|
||||||
subtitle={blockDefinition.description}
|
|
||||||
on:click={() => addBlockToAutomation(stepId, blockDefinition)}
|
|
||||||
/>
|
|
||||||
{/each}
|
|
||||||
</DropdownContainer>
|
|
||||||
</Popover>
|
|
||||||
<Modal bind:this={webhookModal} width="30%">
|
|
||||||
<CreateWebhookModal />
|
|
||||||
</Modal>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.tab-container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: flex-start;
|
|
||||||
align-items: center;
|
|
||||||
min-height: 24px;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -0,0 +1,136 @@
|
||||||
|
<script>
|
||||||
|
import { ModalContent, Layout, Detail, Body, Icon } from "@budibase/bbui"
|
||||||
|
import { automationStore } from "builderStore"
|
||||||
|
import { database } from "stores/backend"
|
||||||
|
import { externalActions } from "./ExternalActions"
|
||||||
|
$: instanceId = $database._id
|
||||||
|
|
||||||
|
let selectedAction
|
||||||
|
let actionVal
|
||||||
|
let actions = Object.entries($automationStore.blockDefinitions.ACTION)
|
||||||
|
export let blockComplete
|
||||||
|
|
||||||
|
const external = actions.reduce((acc, elm) => {
|
||||||
|
const [k, v] = elm
|
||||||
|
if (!v.internal) {
|
||||||
|
acc[k] = v
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}, {})
|
||||||
|
|
||||||
|
const internal = actions.reduce((acc, elm) => {
|
||||||
|
const [k, v] = elm
|
||||||
|
if (v.internal) {
|
||||||
|
acc[k] = v
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}, {})
|
||||||
|
|
||||||
|
const selectAction = action => {
|
||||||
|
actionVal = action
|
||||||
|
selectedAction = action.name
|
||||||
|
}
|
||||||
|
|
||||||
|
async function addBlockToAutomation() {
|
||||||
|
const newBlock = $automationStore.selectedAutomation.constructBlock(
|
||||||
|
"ACTION",
|
||||||
|
actionVal.stepId,
|
||||||
|
actionVal
|
||||||
|
)
|
||||||
|
automationStore.actions.addBlockToAutomation(newBlock)
|
||||||
|
await automationStore.actions.save({
|
||||||
|
instanceId,
|
||||||
|
automation: $automationStore.selectedAutomation?.automation,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<ModalContent
|
||||||
|
title="Create Automation"
|
||||||
|
confirmText="Save"
|
||||||
|
size="M"
|
||||||
|
disabled={!selectedAction}
|
||||||
|
onConfirm={() => {
|
||||||
|
blockComplete = true
|
||||||
|
addBlockToAutomation()
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Body size="XS">Select an app or event.</Body>
|
||||||
|
<Layout noPadding>
|
||||||
|
<Body size="S">Apps</Body>
|
||||||
|
|
||||||
|
<div class="item-list">
|
||||||
|
{#each Object.entries(external) as [idx, action]}
|
||||||
|
<div
|
||||||
|
class="item"
|
||||||
|
class:selected={selectedAction === action.name}
|
||||||
|
on:click={() => selectAction(action)}
|
||||||
|
>
|
||||||
|
<div class="item-body">
|
||||||
|
<img
|
||||||
|
width="20"
|
||||||
|
height="20"
|
||||||
|
src={externalActions[action.stepId].icon}
|
||||||
|
alt="zapier"
|
||||||
|
/>
|
||||||
|
<span class="icon-spacing">
|
||||||
|
<Body size="XS">{idx.charAt(0).toUpperCase() + idx.slice(1)}</Body
|
||||||
|
></span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Detail size="S">Actions</Detail>
|
||||||
|
|
||||||
|
<div class="item-list">
|
||||||
|
{#each Object.entries(internal) as [idx, action]}
|
||||||
|
<div
|
||||||
|
class="item"
|
||||||
|
class:selected={selectedAction === action.name}
|
||||||
|
on:click={() => selectAction(action)}
|
||||||
|
>
|
||||||
|
<div class="item-body">
|
||||||
|
<Icon name={action.icon} />
|
||||||
|
<span class="icon-spacing">
|
||||||
|
<Body size="XS">{action.name}</Body></span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
</Layout>
|
||||||
|
</ModalContent>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.icon-spacing {
|
||||||
|
margin-left: var(--spacing-m);
|
||||||
|
}
|
||||||
|
.item-body {
|
||||||
|
display: flex;
|
||||||
|
margin-left: var(--spacing-m);
|
||||||
|
}
|
||||||
|
.item-list {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||||
|
grid-gap: var(--spectrum-alias-grid-baseline);
|
||||||
|
}
|
||||||
|
|
||||||
|
.item {
|
||||||
|
cursor: pointer;
|
||||||
|
display: grid;
|
||||||
|
grid-gap: var(--spectrum-alias-grid-margin-xsmall);
|
||||||
|
padding: var(--spectrum-alias-item-padding-s);
|
||||||
|
background: var(--spectrum-alias-background-color-secondary);
|
||||||
|
transition: 0.3s all;
|
||||||
|
border: solid #3b3d3c;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-width: 2px;
|
||||||
|
}
|
||||||
|
.item:hover,
|
||||||
|
.selected {
|
||||||
|
background: var(--spectrum-alias-background-color-tertiary);
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -6,6 +6,7 @@
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
|
stroke-dasharray="5,5"
|
||||||
d="M5.0625 70H9L4.5 75L0 70H3.9375V65H5.0625V70Z"
|
d="M5.0625 70H9L4.5 75L0 70H3.9375V65H5.0625V70Z"
|
||||||
fill="var(--grey-5)"
|
fill="var(--grey-5)"
|
||||||
/>
|
/>
|
||||||
|
|
Before Width: | Height: | Size: 326 B After Width: | Height: | Size: 353 B |
|
@ -0,0 +1,11 @@
|
||||||
|
import DiscordLogo from "assets/discord.svg"
|
||||||
|
import ZapierLogo from "assets/zapier.png"
|
||||||
|
import IntegromatLogo from "assets/integromat.png"
|
||||||
|
import SlackLogo from "assets/slack.svg"
|
||||||
|
|
||||||
|
export const externalActions = {
|
||||||
|
zapier: { name: "zapier", icon: ZapierLogo },
|
||||||
|
discord: { name: "discord", icon: DiscordLogo },
|
||||||
|
slack: { name: "slack", icon: SlackLogo },
|
||||||
|
integromat: { name: "integromat", icon: IntegromatLogo },
|
||||||
|
}
|
|
@ -1,12 +1,25 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { automationStore } from "builderStore"
|
||||||
|
|
||||||
import FlowItem from "./FlowItem.svelte"
|
import FlowItem from "./FlowItem.svelte"
|
||||||
import Arrow from "./Arrow.svelte"
|
import TestDataModal from "./TestDataModal.svelte"
|
||||||
|
|
||||||
import { flip } from "svelte/animate"
|
import { flip } from "svelte/animate"
|
||||||
import { fade, fly } from "svelte/transition"
|
import { fade, fly } from "svelte/transition"
|
||||||
|
import {
|
||||||
|
Detail,
|
||||||
|
Icon,
|
||||||
|
ActionButton,
|
||||||
|
notifications,
|
||||||
|
Modal,
|
||||||
|
} from "@budibase/bbui"
|
||||||
|
import { database } from "stores/backend"
|
||||||
|
|
||||||
export let automation
|
export let automation
|
||||||
export let onSelect
|
export let onSelect
|
||||||
|
let testDataModal
|
||||||
let blocks
|
let blocks
|
||||||
|
$: instanceId = $database._id
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
blocks = []
|
blocks = []
|
||||||
|
@ -17,37 +30,91 @@
|
||||||
blocks = blocks.concat(automation.definition.steps || [])
|
blocks = blocks.concat(automation.definition.steps || [])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function deleteAutomation() {
|
||||||
|
await automationStore.actions.delete({
|
||||||
|
instanceId,
|
||||||
|
automation: $automationStore.selectedAutomation?.automation,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function testAutomation() {
|
||||||
|
const result = await automationStore.actions.trigger({
|
||||||
|
automation: $automationStore.selectedAutomation.automation,
|
||||||
|
})
|
||||||
|
if (result.status === 200) {
|
||||||
|
notifications.success(
|
||||||
|
`Automation ${$automationStore.selectedAutomation.automation.name} triggered successfully.`
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
notifications.error(
|
||||||
|
`Failed to trigger automation ${$automationStore.selectedAutomation.automation.name}.`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if !blocks.length}<i>Add a trigger to your automation to get started</i>{/if}
|
<div class="canvas">
|
||||||
<section class="canvas">
|
<div class="content">
|
||||||
{#each blocks as block, idx (block.id)}
|
<div class="title">
|
||||||
<div
|
<div class="subtitle">
|
||||||
class="block"
|
<Detail size="L">{automation.name}</Detail>
|
||||||
animate:flip={{ duration: 600 }}
|
<div
|
||||||
in:fade|local
|
style="display:flex;
|
||||||
out:fly|local={{ x: 100 }}
|
color: var(--spectrum-global-color-gray-400);"
|
||||||
>
|
>
|
||||||
<FlowItem {onSelect} {block} />
|
<span on:click={() => deleteAutomation()} class="iconPadding">
|
||||||
{#if idx !== blocks.length - 1}
|
<Icon name="DeleteOutline" />
|
||||||
<Arrow />
|
</span>
|
||||||
{/if}
|
<ActionButton
|
||||||
|
on:click={() => {
|
||||||
|
testDataModal.show()
|
||||||
|
}}
|
||||||
|
icon="MultipleCheck"
|
||||||
|
size="S">Run test</ActionButton
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{#each blocks as block, idx (block.id)}
|
||||||
</section>
|
<div
|
||||||
|
class="block"
|
||||||
|
animate:flip={{ duration: 800 }}
|
||||||
|
in:fade|local
|
||||||
|
out:fly|local={{ x: 500 }}
|
||||||
|
>
|
||||||
|
<FlowItem {testDataModal} {testAutomation} {onSelect} {block} />
|
||||||
|
{#if idx !== blocks.length - 1}
|
||||||
|
<div class="separator" />
|
||||||
|
<Icon name="AddCircle" size="S" />
|
||||||
|
<div class="separator" />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
<Modal bind:this={testDataModal} width="30%">
|
||||||
|
<TestDataModal {testAutomation} />
|
||||||
|
</Modal>
|
||||||
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
section {
|
.separator {
|
||||||
|
width: 1px;
|
||||||
|
height: 25px;
|
||||||
|
border-left: 1px dashed var(--grey-4);
|
||||||
|
color: var(--grey-4);
|
||||||
|
/* center horizontally */
|
||||||
|
align-self: center;
|
||||||
|
}
|
||||||
|
.canvas {
|
||||||
margin: 0 -40px calc(-1 * var(--spacing-l)) -40px;
|
margin: 0 -40px calc(-1 * var(--spacing-l)) -40px;
|
||||||
padding: var(--spacing-l) 40px 0 40px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
flex-direction: column;
|
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
flex: 1 1 auto;
|
text-align: center;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
/* Fix for firefox not respecting bottom padding in scrolling containers */
|
/* Fix for firefox not respecting bottom padding in scrolling containers */
|
||||||
section > *:last-child {
|
.canvas > *:last-child {
|
||||||
padding-bottom: 40px;
|
padding-bottom: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +125,24 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
i {
|
.content {
|
||||||
font-size: var(--font-size-m);
|
display: inline-block;
|
||||||
color: var(--grey-5);
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
padding-bottom: var(--spacing-xl);
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
padding-bottom: var(--spacing-xl);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.iconPadding {
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
padding-right: var(--spacing-m);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,86 +1,204 @@
|
||||||
<script>
|
<script>
|
||||||
import { automationStore } from "builderStore"
|
import { automationStore } from "builderStore"
|
||||||
import AutomationBlockTagline from "./AutomationBlockTagline.svelte"
|
import {
|
||||||
import { Icon } from "@budibase/bbui"
|
Icon,
|
||||||
|
Divider,
|
||||||
|
Layout,
|
||||||
|
Body,
|
||||||
|
Detail,
|
||||||
|
Modal,
|
||||||
|
Button,
|
||||||
|
StatusLight,
|
||||||
|
} from "@budibase/bbui"
|
||||||
|
import AutomationBlockSetup from "../../SetupPanel/AutomationBlockSetup.svelte"
|
||||||
|
import CreateWebhookModal from "components/automation/Shared/CreateWebhookModal.svelte"
|
||||||
|
import ResultsModal from "./ResultsModal.svelte"
|
||||||
|
import ActionModal from "./ActionModal.svelte"
|
||||||
|
import { database } from "stores/backend"
|
||||||
|
import { externalActions } from "./ExternalActions"
|
||||||
|
|
||||||
export let onSelect
|
export let onSelect
|
||||||
export let block
|
export let block
|
||||||
|
export let testDataModal
|
||||||
let selected
|
let selected
|
||||||
|
let webhookModal
|
||||||
|
let actionModal
|
||||||
|
let resultsModal
|
||||||
|
let setupToggled
|
||||||
|
let blockComplete
|
||||||
|
$: testResult = $automationStore.selectedAutomation.testResults?.steps.filter(
|
||||||
|
step => step.stepId === block.stepId
|
||||||
|
)
|
||||||
|
$: instanceId = $database._id
|
||||||
|
|
||||||
|
$: isTrigger = block.type === "TRIGGER"
|
||||||
|
|
||||||
$: selected = $automationStore.selectedBlock?.id === block.id
|
$: selected = $automationStore.selectedBlock?.id === block.id
|
||||||
$: steps =
|
$: steps =
|
||||||
$automationStore.selectedAutomation?.automation?.definition?.steps ?? []
|
$automationStore.selectedAutomation?.automation?.definition?.steps ?? []
|
||||||
$: blockIdx = steps.findIndex(step => step.id === block.id)
|
|
||||||
$: allowDeleteTrigger = !steps.length
|
|
||||||
|
|
||||||
function deleteStep() {
|
$: blockIdx = steps.findIndex(step => step.id === block.id)
|
||||||
|
$: lastStep = !isTrigger && blockIdx + 1 === steps.length
|
||||||
|
|
||||||
|
// Logic for hiding / showing the add button.first we check if it has a child
|
||||||
|
// then we check to see whether its inputs have been commpleted
|
||||||
|
$: disableAddButton = isTrigger
|
||||||
|
? $automationStore.selectedAutomation?.automation?.definition?.steps
|
||||||
|
.length > 0
|
||||||
|
: !isTrigger && steps.length - blockIdx > 1
|
||||||
|
$: hasCompletedInputs = Object.keys(
|
||||||
|
block.schema?.inputs?.properties || {}
|
||||||
|
).every(x => block?.inputs[x])
|
||||||
|
|
||||||
|
async function deleteStep() {
|
||||||
automationStore.actions.deleteAutomationBlock(block)
|
automationStore.actions.deleteAutomationBlock(block)
|
||||||
|
await automationStore.actions.save({
|
||||||
|
instanceId,
|
||||||
|
automation: $automationStore.selectedAutomation?.automation,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class={`block ${block.type} hoverable`}
|
class={`block ${block.type} hoverable`}
|
||||||
class:selected
|
class:selected
|
||||||
on:click={() => onSelect(block)}
|
on:click={() => {
|
||||||
|
onSelect(block)
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<header>
|
<div class="blockSection">
|
||||||
{#if block.type === "TRIGGER"}
|
<div
|
||||||
<Icon name="Light" />
|
on:click={() => {
|
||||||
<span>When this happens...</span>
|
blockComplete = !blockComplete
|
||||||
{:else if block.type === "ACTION"}
|
}}
|
||||||
<Icon name="FlashOn" />
|
class="splitHeader"
|
||||||
<span>Do this...</span>
|
>
|
||||||
{:else if block.type === "LOGIC"}
|
<div class="center-items">
|
||||||
<Icon name="Branch2" />
|
{#if externalActions[block.stepId]}
|
||||||
<span>Only continue if...</span>
|
<img
|
||||||
{/if}
|
alt={externalActions[block.stepId].name}
|
||||||
<div class="label">
|
width="28px"
|
||||||
{#if block.type === "TRIGGER"}Trigger{:else}Step {blockIdx + 1}{/if}
|
height="28px"
|
||||||
|
src={externalActions[block.stepId].icon}
|
||||||
|
/>
|
||||||
|
{:else}
|
||||||
|
<svg
|
||||||
|
width="28px"
|
||||||
|
height="28px"
|
||||||
|
class="spectrum-Icon"
|
||||||
|
style="color:grey;"
|
||||||
|
focusable="false"
|
||||||
|
>
|
||||||
|
<use xlink:href="#spectrum-icon-18-{block.icon}" />
|
||||||
|
</svg>
|
||||||
|
{/if}
|
||||||
|
<div class="iconAlign">
|
||||||
|
{#if isTrigger}
|
||||||
|
<Body size="XS">When this happens:</Body>
|
||||||
|
{:else}
|
||||||
|
<Body size="XS">Do this:</Body>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<Detail size="S">{block?.name?.toUpperCase() || ""}</Detail>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{#if testResult}
|
||||||
|
<span on:click={() => resultsModal.show()}>
|
||||||
|
<StatusLight
|
||||||
|
positive={isTrigger || testResult[0].outputs?.success}
|
||||||
|
negative={!testResult[0].outputs?.success}
|
||||||
|
><Body size="XS">View response</Body></StatusLight
|
||||||
|
>
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if block.type !== "TRIGGER" || allowDeleteTrigger}
|
</div>
|
||||||
<div on:click|stopPropagation={deleteStep}><Icon name="Close" /></div>
|
{#if !blockComplete}
|
||||||
{/if}
|
<Divider noMargin />
|
||||||
</header>
|
<div class="blockSection">
|
||||||
<hr />
|
<Layout noPadding gap="S">
|
||||||
<p>
|
<div class="splitHeader">
|
||||||
<AutomationBlockTagline {block} />
|
<div
|
||||||
</p>
|
on:click|stopPropagation={() => {
|
||||||
|
setupToggled = !setupToggled
|
||||||
|
}}
|
||||||
|
class="center-items"
|
||||||
|
>
|
||||||
|
{#if setupToggled}
|
||||||
|
<Icon size="M" name="ChevronDown" />
|
||||||
|
{:else}
|
||||||
|
<Icon size="M" name="ChevronRight" />
|
||||||
|
{/if}
|
||||||
|
<Detail size="S">Setup</Detail>
|
||||||
|
</div>
|
||||||
|
{#if !isTrigger}
|
||||||
|
<div on:click={() => deleteStep()}>
|
||||||
|
<Icon name="DeleteOutline" />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if setupToggled}
|
||||||
|
<AutomationBlockSetup
|
||||||
|
schemaProperties={Object.entries(block.schema.inputs.properties)}
|
||||||
|
{block}
|
||||||
|
{webhookModal}
|
||||||
|
/>
|
||||||
|
{#if lastStep}
|
||||||
|
<Button on:click={() => testDataModal.show()} cta
|
||||||
|
>Finish and test automation</Button
|
||||||
|
>
|
||||||
|
{/if}
|
||||||
|
<Button
|
||||||
|
disabled={disableAddButton ? true : !hasCompletedInputs}
|
||||||
|
on:click={() => {
|
||||||
|
setupToggled = false
|
||||||
|
actionModal.show()
|
||||||
|
}}
|
||||||
|
primary={!isTrigger}
|
||||||
|
cta={isTrigger}>Add Action</Button
|
||||||
|
>
|
||||||
|
{/if}
|
||||||
|
</Layout>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<Modal bind:this={resultsModal} width="30%">
|
||||||
|
<ResultsModal {isTrigger} {testResult} />
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<Modal bind:this={actionModal} width="30%">
|
||||||
|
<ActionModal bind:blockComplete />
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<Modal bind:this={webhookModal} width="30%">
|
||||||
|
<CreateWebhookModal />
|
||||||
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.center-items {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.splitHeader {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
.iconAlign {
|
||||||
|
padding: 0 0 0 var(--spacing-m);
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
.block {
|
.block {
|
||||||
width: 360px;
|
width: 360px;
|
||||||
padding: 20px;
|
|
||||||
border-radius: var(--border-radius-m);
|
|
||||||
transition: 0.3s all ease;
|
|
||||||
box-shadow: 0 4px 30px 0 rgba(57, 60, 68, 0.08);
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
background-color: var(--spectrum-global-color-gray-50);
|
background-color: var(--spectrum-alias-background-color-secondary);
|
||||||
color: var(--grey-9);
|
color: var(--grey-9);
|
||||||
}
|
border: 1px solid var(--spectrum-global-color-gray-300);
|
||||||
.block.selected,
|
border-radius: 4px 4px 4px 4px;
|
||||||
.block:hover {
|
|
||||||
transform: scale(1.1);
|
|
||||||
box-shadow: 0 4px 30px 0 rgba(57, 60, 68, 0.15);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
header {
|
.blockSection {
|
||||||
font-size: 16px;
|
padding: var(--spacing-xl);
|
||||||
font-weight: 600;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: flex-start;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--spacing-xs);
|
|
||||||
}
|
|
||||||
header span {
|
|
||||||
flex: 1 1 auto;
|
|
||||||
}
|
|
||||||
header .label {
|
|
||||||
font-size: 14px;
|
|
||||||
padding: var(--spacing-s);
|
|
||||||
border-radius: var(--border-radius-m);
|
|
||||||
background-color: var(--grey-2);
|
|
||||||
color: var(--grey-8);
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
<script>
|
||||||
|
import { ModalContent, Icon, Detail, TextArea } from "@budibase/bbui"
|
||||||
|
|
||||||
|
export let testResult
|
||||||
|
export let isTrigger
|
||||||
|
let inputToggled
|
||||||
|
let outputToggled
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<ModalContent
|
||||||
|
showCloseIcon={false}
|
||||||
|
showConfirmButton={false}
|
||||||
|
title="Test Automation"
|
||||||
|
cancelText="Close"
|
||||||
|
>
|
||||||
|
<div slot="header">
|
||||||
|
<div style="float: right;">
|
||||||
|
{#if isTrigger || testResult[0].outputs.success}
|
||||||
|
<div class="iconSuccess">
|
||||||
|
<Icon size="S" name="CheckmarkCircle" />
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<div class="iconFailure">
|
||||||
|
<Icon size="S" name="CloseCircle" />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
on:click={() => {
|
||||||
|
inputToggled = !inputToggled
|
||||||
|
}}
|
||||||
|
class="toggle splitHeader"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<div style="display: flex; align-items: center;">
|
||||||
|
<span style="padding-left: var(--spacing-s);">
|
||||||
|
<Detail size="S">Input</Detail>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{#if inputToggled}
|
||||||
|
<Icon size="M" name="ChevronDown" />
|
||||||
|
{:else}
|
||||||
|
<Icon size="M" name="ChevronRight" />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{#if inputToggled}
|
||||||
|
<div class="text-area-container">
|
||||||
|
<TextArea
|
||||||
|
disabled
|
||||||
|
value={JSON.stringify(testResult[0].inputs, null, 2)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div
|
||||||
|
on:click={() => {
|
||||||
|
outputToggled = !outputToggled
|
||||||
|
}}
|
||||||
|
class="toggle splitHeader"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<div style="display: flex; align-items: center;">
|
||||||
|
<span style="padding-left: var(--spacing-s);">
|
||||||
|
<Detail size="S">Output</Detail>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{#if outputToggled}
|
||||||
|
<Icon size="M" name="ChevronDown" />
|
||||||
|
{:else}
|
||||||
|
<Icon size="M" name="ChevronRight" />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{#if outputToggled}
|
||||||
|
<div class="text-area-container">
|
||||||
|
<TextArea
|
||||||
|
disabled
|
||||||
|
value={JSON.stringify(testResult[0].outputs, null, 2)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</ModalContent>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.iconSuccess {
|
||||||
|
color: var(--spectrum-global-color-green-600);
|
||||||
|
}
|
||||||
|
|
||||||
|
.iconFailure {
|
||||||
|
color: var(--spectrum-global-color-red-600);
|
||||||
|
}
|
||||||
|
|
||||||
|
.splitHeader {
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-area-container :global(textarea) {
|
||||||
|
height: 150px;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -0,0 +1,88 @@
|
||||||
|
<script>
|
||||||
|
import { ModalContent, Tabs, Tab, TextArea, Label } from "@budibase/bbui"
|
||||||
|
import { automationStore } from "builderStore"
|
||||||
|
import AutomationBlockSetup from "../../SetupPanel/AutomationBlockSetup.svelte"
|
||||||
|
import { cloneDeep } from "lodash/fp"
|
||||||
|
|
||||||
|
let failedParse = null
|
||||||
|
// clone the trigger so we're not mutating the reference
|
||||||
|
let trigger = cloneDeep(
|
||||||
|
$automationStore.selectedAutomation.automation.definition.trigger
|
||||||
|
)
|
||||||
|
let schemaProperties = Object.entries(trigger.schema.outputs.properties || {})
|
||||||
|
|
||||||
|
if (!$automationStore.selectedAutomation.automation.testData) {
|
||||||
|
$automationStore.selectedAutomation.automation.testData = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the outputs so we can define the fields
|
||||||
|
|
||||||
|
// check to see if there is existing test data in the store
|
||||||
|
$: testData = $automationStore.selectedAutomation.automation.testData
|
||||||
|
// Check the schema to see if required fields have been entered
|
||||||
|
$: isError = !trigger.schema.outputs.required.every(
|
||||||
|
required => testData[required]
|
||||||
|
)
|
||||||
|
|
||||||
|
function parseTestJSON(e) {
|
||||||
|
try {
|
||||||
|
const obj = JSON.parse(e.detail)
|
||||||
|
failedParse = null
|
||||||
|
automationStore.actions.addTestDataToAutomation(obj)
|
||||||
|
} catch (e) {
|
||||||
|
failedParse = "Invalid JSON"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<ModalContent
|
||||||
|
title="Add test data"
|
||||||
|
confirmText="Test"
|
||||||
|
showConfirmButton={true}
|
||||||
|
disabled={isError}
|
||||||
|
onConfirm={() => {
|
||||||
|
automationStore.actions.addTestDataToAutomation(testData)
|
||||||
|
automationStore.actions.test($automationStore.selectedAutomation, testData)
|
||||||
|
}}
|
||||||
|
cancelText="Cancel"
|
||||||
|
>
|
||||||
|
<Tabs selected="Form" quiet
|
||||||
|
><Tab icon="Form" title="Form">
|
||||||
|
<div class="tab-content-padding">
|
||||||
|
<AutomationBlockSetup
|
||||||
|
bind:testData
|
||||||
|
{schemaProperties}
|
||||||
|
isTestModal
|
||||||
|
block={trigger}
|
||||||
|
/>
|
||||||
|
</div></Tab
|
||||||
|
>
|
||||||
|
<Tab icon="FileJson" title="JSON">
|
||||||
|
<div class="tab-content-padding">
|
||||||
|
<Label>JSON</Label>
|
||||||
|
<div class="text-area-container">
|
||||||
|
<TextArea
|
||||||
|
value={JSON.stringify(
|
||||||
|
$automationStore.selectedAutomation.automation.testData,
|
||||||
|
null,
|
||||||
|
2
|
||||||
|
)}
|
||||||
|
error={failedParse}
|
||||||
|
on:change={e => parseTestJSON(e)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Tab>
|
||||||
|
</Tabs>
|
||||||
|
</ModalContent>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.text-area-container :global(textarea) {
|
||||||
|
min-height: 200px;
|
||||||
|
height: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-content-padding {
|
||||||
|
padding: 0 var(--spacing-xl);
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -6,7 +6,6 @@
|
||||||
import EditAutomationPopover from "./EditAutomationPopover.svelte"
|
import EditAutomationPopover from "./EditAutomationPopover.svelte"
|
||||||
|
|
||||||
$: selectedAutomationId = $automationStore.selectedAutomation?.automation?._id
|
$: selectedAutomationId = $automationStore.selectedAutomation?.automation?._id
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
automationStore.actions.fetch()
|
automationStore.actions.fetch()
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
import AutomationList from "./AutomationList.svelte"
|
import AutomationList from "./AutomationList.svelte"
|
||||||
import CreateAutomationModal from "./CreateAutomationModal.svelte"
|
import CreateAutomationModal from "./CreateAutomationModal.svelte"
|
||||||
import { Icon, Modal, Tabs, Tab } from "@budibase/bbui"
|
import { Icon, Modal, Tabs, Tab } from "@budibase/bbui"
|
||||||
let modal
|
|
||||||
|
export let modal
|
||||||
|
export let webhookModal
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="title">
|
<div class="title">
|
||||||
|
@ -11,7 +13,7 @@
|
||||||
<div class="tab-content-padding">
|
<div class="tab-content-padding">
|
||||||
<AutomationList />
|
<AutomationList />
|
||||||
<Modal bind:this={modal}>
|
<Modal bind:this={modal}>
|
||||||
<CreateAutomationModal />
|
<CreateAutomationModal {webhookModal} />
|
||||||
</Modal>
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
</Tab>
|
</Tab>
|
||||||
|
|
|
@ -3,12 +3,14 @@
|
||||||
import { database } from "stores/backend"
|
import { database } from "stores/backend"
|
||||||
import { automationStore } from "builderStore"
|
import { automationStore } from "builderStore"
|
||||||
import { notifications } from "@budibase/bbui"
|
import { notifications } from "@budibase/bbui"
|
||||||
import { Icon, Input, ModalContent } from "@budibase/bbui"
|
import { Input, ModalContent, Layout, Body, Icon } from "@budibase/bbui"
|
||||||
import analytics from "analytics"
|
import analytics from "analytics"
|
||||||
|
|
||||||
let name
|
let name
|
||||||
|
let selectedTrigger
|
||||||
|
let triggerVal
|
||||||
|
export let webhookModal
|
||||||
|
|
||||||
$: valid = !!name
|
|
||||||
$: instanceId = $database._id
|
$: instanceId = $database._id
|
||||||
|
|
||||||
async function createAutomation() {
|
async function createAutomation() {
|
||||||
|
@ -16,41 +18,97 @@
|
||||||
name,
|
name,
|
||||||
instanceId,
|
instanceId,
|
||||||
})
|
})
|
||||||
|
const newBlock = $automationStore.selectedAutomation.constructBlock(
|
||||||
|
"TRIGGER",
|
||||||
|
triggerVal.stepId,
|
||||||
|
triggerVal
|
||||||
|
)
|
||||||
|
|
||||||
|
automationStore.actions.addBlockToAutomation(newBlock)
|
||||||
|
if (triggerVal.stepId === "WEBHOOK") {
|
||||||
|
webhookModal.show
|
||||||
|
}
|
||||||
|
|
||||||
|
await automationStore.actions.save({
|
||||||
|
instanceId,
|
||||||
|
automation: $automationStore.selectedAutomation?.automation,
|
||||||
|
})
|
||||||
|
|
||||||
notifications.success(`Automation ${name} created.`)
|
notifications.success(`Automation ${name} created.`)
|
||||||
|
|
||||||
$goto(`./${$automationStore.selectedAutomation.automation._id}`)
|
$goto(`./${$automationStore.selectedAutomation.automation._id}`)
|
||||||
analytics.captureEvent("Automation Created", { name })
|
analytics.captureEvent("Automation Created", { name })
|
||||||
}
|
}
|
||||||
|
$: triggers = Object.entries($automationStore.blockDefinitions.TRIGGER)
|
||||||
|
|
||||||
|
const selectTrigger = trigger => {
|
||||||
|
triggerVal = trigger
|
||||||
|
selectedTrigger = trigger.name
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ModalContent
|
<ModalContent
|
||||||
title="Create Automation"
|
title="Create Automation"
|
||||||
confirmText="Create"
|
confirmText="Save"
|
||||||
size="L"
|
size="M"
|
||||||
onConfirm={createAutomation}
|
onConfirm={createAutomation}
|
||||||
disabled={!valid}
|
disabled={!selectedTrigger}
|
||||||
>
|
>
|
||||||
|
<Body size="XS"
|
||||||
|
>Please name your automation, then select a trigger. Every automation must
|
||||||
|
start with a trigger.
|
||||||
|
</Body>
|
||||||
<Input bind:value={name} label="Name" />
|
<Input bind:value={name} label="Name" />
|
||||||
<a
|
|
||||||
slot="footer"
|
<Layout noPadding>
|
||||||
target="_blank"
|
<Body size="S">Triggers</Body>
|
||||||
href="https://docs.budibase.com/automate/introduction-to-automate"
|
|
||||||
>
|
<div class="item-list">
|
||||||
<Icon name="InfoOutline" />
|
{#each triggers as [idx, trigger]}
|
||||||
<span>Learn about automations</span>
|
<div
|
||||||
</a>
|
class="item"
|
||||||
|
class:selected={selectedTrigger === trigger.name}
|
||||||
|
on:click={() => selectTrigger(trigger)}
|
||||||
|
>
|
||||||
|
<div class="item-body">
|
||||||
|
<Icon name={trigger.icon} />
|
||||||
|
<span class="icon-spacing">
|
||||||
|
<Body size="S">{trigger.name}</Body></span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
</Layout>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
a {
|
.icon-spacing {
|
||||||
color: var(--ink);
|
margin-left: var(--spacing-m);
|
||||||
font-size: 14px;
|
|
||||||
vertical-align: middle;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
}
|
||||||
a span {
|
.item-body {
|
||||||
text-decoration: underline;
|
display: flex;
|
||||||
margin-left: var(--spectrum-alias-item-padding-s);
|
margin-left: var(--spacing-m);
|
||||||
|
}
|
||||||
|
.item-list {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||||
|
grid-gap: var(--spectrum-alias-grid-baseline);
|
||||||
|
}
|
||||||
|
|
||||||
|
.item {
|
||||||
|
cursor: pointer;
|
||||||
|
display: grid;
|
||||||
|
grid-gap: var(--spectrum-alias-grid-margin-xsmall);
|
||||||
|
padding: var(--spectrum-alias-item-padding-s);
|
||||||
|
background: var(--spectrum-alias-background-color-secondary);
|
||||||
|
transition: 0.3s all;
|
||||||
|
border: solid #3b3d3c;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-width: 2px;
|
||||||
|
}
|
||||||
|
.selected {
|
||||||
|
background: var(--spectrum-alias-background-color-tertiary);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -2,8 +2,16 @@
|
||||||
import TableSelector from "./TableSelector.svelte"
|
import TableSelector from "./TableSelector.svelte"
|
||||||
import RowSelector from "./RowSelector.svelte"
|
import RowSelector from "./RowSelector.svelte"
|
||||||
import SchemaSetup from "./SchemaSetup.svelte"
|
import SchemaSetup from "./SchemaSetup.svelte"
|
||||||
import { Button, Input, Select, Label } from "@budibase/bbui"
|
import {
|
||||||
|
Button,
|
||||||
|
Input,
|
||||||
|
Select,
|
||||||
|
Label,
|
||||||
|
ActionButton,
|
||||||
|
Drawer,
|
||||||
|
} from "@budibase/bbui"
|
||||||
import { automationStore } from "builderStore"
|
import { automationStore } from "builderStore"
|
||||||
|
import { tables } from "stores/backend"
|
||||||
import WebhookDisplay from "../Shared/WebhookDisplay.svelte"
|
import WebhookDisplay from "../Shared/WebhookDisplay.svelte"
|
||||||
import DrawerBindableInput from "../../common/bindings/DrawerBindableInput.svelte"
|
import DrawerBindableInput from "../../common/bindings/DrawerBindableInput.svelte"
|
||||||
import AutomationBindingPanel from "../../common/bindings/ServerBindingPanel.svelte"
|
import AutomationBindingPanel from "../../common/bindings/ServerBindingPanel.svelte"
|
||||||
|
@ -12,15 +20,50 @@
|
||||||
import QueryParamSelector from "./QueryParamSelector.svelte"
|
import QueryParamSelector from "./QueryParamSelector.svelte"
|
||||||
import CronBuilder from "./CronBuilder.svelte"
|
import CronBuilder from "./CronBuilder.svelte"
|
||||||
import Editor from "components/integration/QueryEditor.svelte"
|
import Editor from "components/integration/QueryEditor.svelte"
|
||||||
|
import { database } from "stores/backend"
|
||||||
|
import { debounce } from "lodash"
|
||||||
|
import ModalBindableInput from "components/common/bindings/ModalBindableInput.svelte"
|
||||||
|
import FilterDrawer from "components/design/PropertiesPanel/PropertyControls/FilterEditor/FilterDrawer.svelte"
|
||||||
|
// need the client lucene builder to convert to the structure API expects
|
||||||
|
import { buildLuceneQuery } from "../../../../../client/src/utils/lucene"
|
||||||
|
|
||||||
export let block
|
export let block
|
||||||
export let webhookModal
|
export let webhookModal
|
||||||
$: inputs = Object.entries(block.schema?.inputs?.properties || {})
|
export let testData
|
||||||
|
export let schemaProperties
|
||||||
|
export let isTestModal = false
|
||||||
|
let drawer
|
||||||
|
let tempFilters = lookForFilters(schemaProperties) || []
|
||||||
|
let fillWidth = true
|
||||||
|
|
||||||
$: stepId = block.stepId
|
$: stepId = block.stepId
|
||||||
$: bindings = getAvailableBindings(
|
$: bindings = getAvailableBindings(
|
||||||
block,
|
block || $automationStore.selectedBlock,
|
||||||
$automationStore.selectedAutomation?.automation?.definition
|
$automationStore.selectedAutomation?.automation?.definition
|
||||||
)
|
)
|
||||||
|
$: instanceId = $database._id
|
||||||
|
|
||||||
|
$: inputData = testData ? testData : block.inputs
|
||||||
|
$: tableId = inputData ? inputData.tableId : null
|
||||||
|
$: table = tableId
|
||||||
|
? $tables.list.find(table => table._id === inputData.tableId)
|
||||||
|
: { schema: {} }
|
||||||
|
$: schemaFields = table ? Object.values(table.schema) : []
|
||||||
|
|
||||||
|
const onChange = debounce(
|
||||||
|
async function (e, key) {
|
||||||
|
if (isTestModal) {
|
||||||
|
testData[key] = e.detail
|
||||||
|
} else {
|
||||||
|
block.inputs[key] = e.detail
|
||||||
|
await automationStore.actions.save({
|
||||||
|
instanceId,
|
||||||
|
automation: $automationStore.selectedAutomation?.automation,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isTestModal ? 0 : 800
|
||||||
|
)
|
||||||
|
|
||||||
function getAvailableBindings(block, automation) {
|
function getAvailableBindings(block, automation) {
|
||||||
if (!block || !automation) {
|
if (!block || !automation) {
|
||||||
|
@ -52,64 +95,158 @@
|
||||||
}
|
}
|
||||||
return bindings
|
return bindings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function lookForFilters(properties) {
|
||||||
|
if (!properties) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
let filters
|
||||||
|
const inputs = testData ? testData : block.inputs
|
||||||
|
for (let [key, field] of properties) {
|
||||||
|
// need to look for the builder definition (keyed separately, see saveFilters)
|
||||||
|
const defKey = `${key}-def`
|
||||||
|
if (field.customType === "filters" && inputs?.[defKey]) {
|
||||||
|
filters = inputs[defKey]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filters || []
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveFilters(key) {
|
||||||
|
const filters = buildLuceneQuery(tempFilters)
|
||||||
|
const defKey = `${key}-def`
|
||||||
|
inputData[key] = filters
|
||||||
|
inputData[defKey] = tempFilters
|
||||||
|
onChange({ detail: filters }, key)
|
||||||
|
// need to store the builder definition in the automation
|
||||||
|
onChange({ detail: tempFilters }, defKey)
|
||||||
|
drawer.hide()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="fields">
|
<div class="fields">
|
||||||
<div class="block-label">{block.name}</div>
|
{#each schemaProperties as [key, value]}
|
||||||
{#each inputs as [key, value]}
|
|
||||||
<div class="block-field">
|
<div class="block-field">
|
||||||
<Label>{value.title}</Label>
|
<Label>{value.title || (key === "row" ? "Table" : key)}</Label>
|
||||||
{#if value.type === "string" && value.enum}
|
{#if value.type === "string" && value.enum}
|
||||||
<Select
|
<Select
|
||||||
bind:value={block.inputs[key]}
|
on:change={e => onChange(e, key)}
|
||||||
|
value={inputData[key]}
|
||||||
options={value.enum}
|
options={value.enum}
|
||||||
getOptionLabel={(x, idx) => (value.pretty ? value.pretty[idx] : x)}
|
getOptionLabel={(x, idx) => (value.pretty ? value.pretty[idx] : x)}
|
||||||
/>
|
/>
|
||||||
|
{:else if value.customType === "column"}
|
||||||
|
<Select
|
||||||
|
on:change={e => onChange(e, key)}
|
||||||
|
value={inputData[key]}
|
||||||
|
options={Object.keys(table.schema)}
|
||||||
|
/>
|
||||||
|
{:else if value.customType === "filters"}
|
||||||
|
<ActionButton on:click={drawer.show}>Define filters</ActionButton>
|
||||||
|
<Drawer bind:this={drawer} {fillWidth} title="Filtering">
|
||||||
|
<Button cta slot="buttons" on:click={() => saveFilters(key)}
|
||||||
|
>Save</Button
|
||||||
|
>
|
||||||
|
<FilterDrawer
|
||||||
|
slot="body"
|
||||||
|
bind:filters={tempFilters}
|
||||||
|
{bindings}
|
||||||
|
{schemaFields}
|
||||||
|
panel={AutomationBindingPanel}
|
||||||
|
/>
|
||||||
|
</Drawer>
|
||||||
{:else if value.customType === "password"}
|
{:else if value.customType === "password"}
|
||||||
<Input type="password" bind:value={block.inputs[key]} />
|
<Input
|
||||||
|
type="password"
|
||||||
|
on:change={e => onChange(e, key)}
|
||||||
|
value={inputData[key]}
|
||||||
|
/>
|
||||||
{:else if value.customType === "email"}
|
{:else if value.customType === "email"}
|
||||||
<DrawerBindableInput
|
{#if isTestModal}
|
||||||
title={value.title}
|
<ModalBindableInput
|
||||||
panel={AutomationBindingPanel}
|
title={value.title}
|
||||||
type="email"
|
value={inputData[key]}
|
||||||
value={block.inputs[key]}
|
panel={AutomationBindingPanel}
|
||||||
on:change={e => (block.inputs[key] = e.detail)}
|
type="email"
|
||||||
|
on:change={e => onChange(e, key)}
|
||||||
|
{bindings}
|
||||||
|
fillWidth
|
||||||
|
/>
|
||||||
|
{:else}
|
||||||
|
<DrawerBindableInput
|
||||||
|
fillWidth
|
||||||
|
title={value.title}
|
||||||
|
panel={AutomationBindingPanel}
|
||||||
|
type="email"
|
||||||
|
value={inputData[key]}
|
||||||
|
on:change={e => onChange(e, key)}
|
||||||
|
{bindings}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
{:else if value.customType === "query"}
|
||||||
|
<QuerySelector
|
||||||
|
on:change={e => onChange(e, key)}
|
||||||
|
value={inputData[key]}
|
||||||
|
/>
|
||||||
|
{:else if value.customType === "cron"}
|
||||||
|
<CronBuilder on:change={e => onChange(e, key)} value={inputData[key]} />
|
||||||
|
{:else if value.customType === "queryParams"}
|
||||||
|
<QueryParamSelector
|
||||||
|
on:change={e => onChange(e, key)}
|
||||||
|
value={inputData[key]}
|
||||||
{bindings}
|
{bindings}
|
||||||
/>
|
/>
|
||||||
{:else if value.customType === "query"}
|
|
||||||
<QuerySelector bind:value={block.inputs[key]} />
|
|
||||||
{:else if value.customType === "cron"}
|
|
||||||
<CronBuilder bind:value={block.inputs[key]} />
|
|
||||||
{:else if value.customType === "queryParams"}
|
|
||||||
<QueryParamSelector bind:value={block.inputs[key]} {bindings} />
|
|
||||||
{:else if value.customType === "table"}
|
{:else if value.customType === "table"}
|
||||||
<TableSelector bind:value={block.inputs[key]} />
|
<TableSelector
|
||||||
|
value={inputData[key]}
|
||||||
|
on:change={e => onChange(e, key)}
|
||||||
|
/>
|
||||||
{:else if value.customType === "row"}
|
{:else if value.customType === "row"}
|
||||||
<RowSelector bind:value={block.inputs[key]} {bindings} />
|
<RowSelector
|
||||||
|
value={inputData[key]}
|
||||||
|
on:change={e => onChange(e, key)}
|
||||||
|
{bindings}
|
||||||
|
/>
|
||||||
{:else if value.customType === "webhookUrl"}
|
{:else if value.customType === "webhookUrl"}
|
||||||
<WebhookDisplay value={block.inputs[key]} />
|
<WebhookDisplay value={inputData[key]} />
|
||||||
{:else if value.customType === "triggerSchema"}
|
{:else if value.customType === "triggerSchema"}
|
||||||
<SchemaSetup bind:value={block.inputs[key]} />
|
<SchemaSetup on:change={e => onChange(e, key)} value={value[key]} />
|
||||||
{:else if value.customType === "code"}
|
{:else if value.customType === "code"}
|
||||||
<CodeEditorModal>
|
<CodeEditorModal>
|
||||||
<pre>{JSON.stringify(bindings, null, 2)}</pre>
|
<pre>{JSON.stringify(bindings, null, 2)}</pre>
|
||||||
<Editor
|
<Editor
|
||||||
mode="javascript"
|
mode="javascript"
|
||||||
on:change={e => {
|
on:change={e => {
|
||||||
block.inputs[key] = e.detail.value
|
onChange(e, key)
|
||||||
|
inputData[key] = e.detail.value
|
||||||
}}
|
}}
|
||||||
value={block.inputs[key]}
|
value={inputData[key]}
|
||||||
/>
|
/>
|
||||||
</CodeEditorModal>
|
</CodeEditorModal>
|
||||||
{:else if value.type === "string" || value.type === "number"}
|
{:else if value.type === "string" || value.type === "number"}
|
||||||
<DrawerBindableInput
|
{#if isTestModal}
|
||||||
title={value.title}
|
<ModalBindableInput
|
||||||
panel={AutomationBindingPanel}
|
title={value.title}
|
||||||
type={value.customType}
|
value={inputData[key]}
|
||||||
value={block.inputs[key]}
|
panel={AutomationBindingPanel}
|
||||||
on:change={e => (block.inputs[key] = e.detail)}
|
type={value.customType}
|
||||||
{bindings}
|
on:change={e => onChange(e, key)}
|
||||||
/>
|
{bindings}
|
||||||
|
/>
|
||||||
|
{:else}
|
||||||
|
<div class="test">
|
||||||
|
<DrawerBindableInput
|
||||||
|
fillWidth={true}
|
||||||
|
title={value.title}
|
||||||
|
panel={AutomationBindingPanel}
|
||||||
|
type={value.customType}
|
||||||
|
value={inputData[key]}
|
||||||
|
on:change={e => onChange(e, key)}
|
||||||
|
{bindings}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
@ -132,9 +269,7 @@
|
||||||
grid-gap: 5px;
|
grid-gap: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.block-label {
|
.test :global(.drawer) {
|
||||||
font-weight: 600;
|
width: 10000px !important;
|
||||||
font-size: var(--font-size-s);
|
|
||||||
color: var(--grey-7);
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
<script>
|
<script>
|
||||||
import { Button, Select, Input } from "@budibase/bbui"
|
import { Button, Select, Input } from "@budibase/bbui"
|
||||||
|
import { createEventDispatcher } from "svelte"
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
export let value
|
export let value
|
||||||
|
const onChange = e => {
|
||||||
|
value = e.detail
|
||||||
|
dispatch("change", e.detail)
|
||||||
|
}
|
||||||
|
|
||||||
let presets = false
|
let presets = false
|
||||||
|
|
||||||
|
@ -30,7 +36,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="block-field">
|
<div class="block-field">
|
||||||
<Input bind:value />
|
<Input on:change={onChange} {value} />
|
||||||
|
|
||||||
<div class="presets">
|
<div class="presets">
|
||||||
<Button on:click={() => (presets = !presets)}
|
<Button on:click={() => (presets = !presets)}
|
||||||
|
@ -38,7 +44,8 @@
|
||||||
>
|
>
|
||||||
{#if presets}
|
{#if presets}
|
||||||
<Select
|
<Select
|
||||||
bind:value
|
on:change={onChange}
|
||||||
|
{value}
|
||||||
secondary
|
secondary
|
||||||
extraThin
|
extraThin
|
||||||
label="Presets"
|
label="Presets"
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
label={field.name}
|
label={field.name}
|
||||||
type="string"
|
type="string"
|
||||||
{bindings}
|
{bindings}
|
||||||
|
fillWidth={true}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,12 +3,25 @@
|
||||||
import { Select } from "@budibase/bbui"
|
import { Select } from "@budibase/bbui"
|
||||||
import DrawerBindableInput from "../../common/bindings/DrawerBindableInput.svelte"
|
import DrawerBindableInput from "../../common/bindings/DrawerBindableInput.svelte"
|
||||||
import AutomationBindingPanel from "../../common/bindings/ServerBindingPanel.svelte"
|
import AutomationBindingPanel from "../../common/bindings/ServerBindingPanel.svelte"
|
||||||
|
import { createEventDispatcher } from "svelte"
|
||||||
|
import ModalBindableInput from "components/common/bindings/ModalBindableInput.svelte"
|
||||||
|
import { automationStore } from "builderStore"
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
export let value
|
export let value
|
||||||
export let bindings
|
export let bindings
|
||||||
|
|
||||||
$: table = $tables.list.find(table => table._id === value?.tableId)
|
$: table = $tables.list.find(table => table._id === value?.tableId)
|
||||||
$: schemaFields = Object.entries(table?.schema ?? {})
|
$: schemaFields = Object.entries(table?.schema ?? {})
|
||||||
|
const onChangeTable = e => {
|
||||||
|
value = { tableId: e.detail }
|
||||||
|
dispatch("change", value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const onChange = (e, field) => {
|
||||||
|
value[field] = e.detail
|
||||||
|
dispatch("change", value)
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure any nullish tableId values get set to empty string so
|
// Ensure any nullish tableId values get set to empty string so
|
||||||
// that the select works
|
// that the select works
|
||||||
|
@ -20,7 +33,8 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Select
|
<Select
|
||||||
bind:value={value.tableId}
|
on:change={onChangeTable}
|
||||||
|
value={value.tableId}
|
||||||
options={$tables.list}
|
options={$tables.list}
|
||||||
getOptionLabel={table => table.name}
|
getOptionLabel={table => table.name}
|
||||||
getOptionValue={table => table._id}
|
getOptionValue={table => table._id}
|
||||||
|
@ -32,19 +46,32 @@
|
||||||
{#if !schema.autocolumn}
|
{#if !schema.autocolumn}
|
||||||
{#if schemaHasOptions(schema)}
|
{#if schemaHasOptions(schema)}
|
||||||
<Select
|
<Select
|
||||||
|
on:change={e => onChange(e, field)}
|
||||||
label={field}
|
label={field}
|
||||||
bind:value={value[field]}
|
value={value[field]}
|
||||||
options={schema.constraints.inclusion}
|
options={schema.constraints.inclusion}
|
||||||
/>
|
/>
|
||||||
{:else if schema.type === "string" || schema.type === "number"}
|
{:else if schema.type === "string" || schema.type === "number"}
|
||||||
<DrawerBindableInput
|
{#if $automationStore.selectedAutomation.automation.testData}
|
||||||
panel={AutomationBindingPanel}
|
<ModalBindableInput
|
||||||
value={value[field]}
|
value={value[field]}
|
||||||
on:change={e => (value[field] = e.detail)}
|
panel={AutomationBindingPanel}
|
||||||
label={field}
|
label={field}
|
||||||
type="string"
|
type={value.customType}
|
||||||
{bindings}
|
on:change={e => onChange(e, field)}
|
||||||
/>
|
{bindings}
|
||||||
|
/>
|
||||||
|
{:else}
|
||||||
|
<DrawerBindableInput
|
||||||
|
panel={AutomationBindingPanel}
|
||||||
|
value={value[field]}
|
||||||
|
on:change={e => onChange(e, field)}
|
||||||
|
label={field}
|
||||||
|
type="string"
|
||||||
|
{bindings}
|
||||||
|
fillWidth={true}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<script>
|
<script>
|
||||||
import { Input, Select } from "@budibase/bbui"
|
import { Input, Select } from "@budibase/bbui"
|
||||||
|
import { createEventDispatcher } from "svelte"
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
export let value = {}
|
export let value = {}
|
||||||
$: fieldsArray = Object.entries(value).map(([name, type]) => ({
|
$: fieldsArray = Object.entries(value).map(([name, type]) => ({
|
||||||
|
@ -28,13 +31,13 @@
|
||||||
function addField() {
|
function addField() {
|
||||||
const newValue = { ...value }
|
const newValue = { ...value }
|
||||||
newValue[""] = "string"
|
newValue[""] = "string"
|
||||||
value = newValue
|
dispatch("change", newValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeField(name) {
|
function removeField(name) {
|
||||||
const newValues = { ...value }
|
const newValues = { ...value }
|
||||||
delete newValues[name]
|
delete newValues[name]
|
||||||
value = newValues
|
dispatch("change", newValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
const fieldNameChanged = originalName => e => {
|
const fieldNameChanged = originalName => e => {
|
||||||
|
@ -50,6 +53,7 @@
|
||||||
newVals[current.name] = current.type
|
newVals[current.name] = current.type
|
||||||
return newVals
|
return newVals
|
||||||
}, {})
|
}, {})
|
||||||
|
dispatch("change", value)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -68,7 +72,10 @@
|
||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
value={field.type}
|
value={field.type}
|
||||||
on:change={e => (value[field.name] = e.target.value)}
|
on:change={e => {
|
||||||
|
value[field.name] = e.target.value
|
||||||
|
dispatch("change", value)
|
||||||
|
}}
|
||||||
options={typeOptions}
|
options={typeOptions}
|
||||||
/>
|
/>
|
||||||
<i
|
<i
|
||||||
|
|
|
@ -1,91 +0,0 @@
|
||||||
<script>
|
|
||||||
import { automationStore } from "builderStore"
|
|
||||||
import { notifications, Button, Modal, Heading, Toggle } from "@budibase/bbui"
|
|
||||||
import AutomationBlockSetup from "./AutomationBlockSetup.svelte"
|
|
||||||
import CreateWebookModal from "../Shared/CreateWebhookModal.svelte"
|
|
||||||
|
|
||||||
let webhookModal
|
|
||||||
|
|
||||||
$: automation = $automationStore.selectedAutomation?.automation
|
|
||||||
$: automationLive = automation?.live
|
|
||||||
|
|
||||||
function setAutomationLive(live) {
|
|
||||||
if (automationLive === live) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
automation.live = live
|
|
||||||
automationStore.actions.save(automation)
|
|
||||||
if (live) {
|
|
||||||
notifications.info(`Automation ${automation.name} enabled.`)
|
|
||||||
} else {
|
|
||||||
notifications.error(`Automation ${automation.name} disabled.`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function testAutomation() {
|
|
||||||
const result = await automationStore.actions.trigger({
|
|
||||||
automation: $automationStore.selectedAutomation.automation,
|
|
||||||
})
|
|
||||||
if (result.status === 200) {
|
|
||||||
notifications.success(
|
|
||||||
`Automation ${automation.name} triggered successfully.`
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
notifications.error(`Failed to trigger automation ${automation.name}.`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveAutomation() {
|
|
||||||
await automationStore.actions.save(automation)
|
|
||||||
notifications.success(`Automation ${automation.name} saved.`)
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="title">
|
|
||||||
<Heading size="S">Setup</Heading>
|
|
||||||
<Toggle
|
|
||||||
value={automationLive}
|
|
||||||
on:change={() => setAutomationLive(!automationLive)}
|
|
||||||
dataCy="activate-automation"
|
|
||||||
text="Live"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{#if $automationStore.selectedBlock}
|
|
||||||
<AutomationBlockSetup
|
|
||||||
bind:block={$automationStore.selectedBlock}
|
|
||||||
{webhookModal}
|
|
||||||
/>
|
|
||||||
{:else if automation}
|
|
||||||
<div class="block-label">{automation.name}</div>
|
|
||||||
<Button secondary on:click={testAutomation}>Test Automation</Button>
|
|
||||||
{/if}
|
|
||||||
<Button
|
|
||||||
secondary
|
|
||||||
wide
|
|
||||||
data-cy="save-automation-setup"
|
|
||||||
on:click={saveAutomation}
|
|
||||||
>
|
|
||||||
Save Automation
|
|
||||||
</Button>
|
|
||||||
<Modal bind:this={webhookModal} width="30%">
|
|
||||||
<CreateWebookModal />
|
|
||||||
</Modal>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.title {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--spacing-xs);
|
|
||||||
}
|
|
||||||
.title :global(h1) {
|
|
||||||
flex: 1 1 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.block-label {
|
|
||||||
font-size: var(--spectrum-global-dimension-font-size-75);
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--grey-7);
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,11 +1,20 @@
|
||||||
<script>
|
<script>
|
||||||
import { tables } from "stores/backend"
|
import { tables } from "stores/backend"
|
||||||
import { Select } from "@budibase/bbui"
|
import { Select } from "@budibase/bbui"
|
||||||
|
import { createEventDispatcher } from "svelte"
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
export let value
|
export let value
|
||||||
|
|
||||||
|
const onChange = e => {
|
||||||
|
value = e.detail
|
||||||
|
dispatch("change", e.detail)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Select
|
<Select
|
||||||
|
on:change={onChange}
|
||||||
bind:value
|
bind:value
|
||||||
options={$tables.list}
|
options={$tables.list}
|
||||||
getOptionLabel={table => table.name}
|
getOptionLabel={table => table.name}
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
<script>
|
<script>
|
||||||
import { Input, Select, DatePicker, Toggle, TextArea } from "@budibase/bbui"
|
import {
|
||||||
|
Input,
|
||||||
|
Select,
|
||||||
|
DatePicker,
|
||||||
|
Toggle,
|
||||||
|
TextArea,
|
||||||
|
Multiselect,
|
||||||
|
} from "@budibase/bbui"
|
||||||
import Dropzone from "components/common/Dropzone.svelte"
|
import Dropzone from "components/common/Dropzone.svelte"
|
||||||
import { capitalise } from "helpers"
|
import { capitalise } from "helpers"
|
||||||
import LinkedRowSelector from "components/common/LinkedRowSelector.svelte"
|
import LinkedRowSelector from "components/common/LinkedRowSelector.svelte"
|
||||||
|
@ -27,6 +34,8 @@
|
||||||
<Dropzone {label} bind:value />
|
<Dropzone {label} bind:value />
|
||||||
{:else if type === "boolean"}
|
{:else if type === "boolean"}
|
||||||
<Toggle text={label} bind:value data-cy="{meta.name}-input" />
|
<Toggle text={label} bind:value data-cy="{meta.name}-input" />
|
||||||
|
{:else if type === "array"}
|
||||||
|
<Multiselect bind:value {label} options={meta.constraints.inclusion} />
|
||||||
{:else if type === "link"}
|
{:else if type === "link"}
|
||||||
<LinkedRowSelector bind:linkedRows={value} schema={meta} />
|
<LinkedRowSelector bind:linkedRows={value} schema={meta} />
|
||||||
{:else if type === "longform"}
|
{:else if type === "longform"}
|
||||||
|
|
|
@ -262,6 +262,11 @@
|
||||||
label="Options (one per line)"
|
label="Options (one per line)"
|
||||||
bind:values={field.constraints.inclusion}
|
bind:values={field.constraints.inclusion}
|
||||||
/>
|
/>
|
||||||
|
{:else if field.type === "array"}
|
||||||
|
<ValuesList
|
||||||
|
label="Options (one per line)"
|
||||||
|
bind:values={field.constraints.inclusion}
|
||||||
|
/>
|
||||||
{:else if field.type === "datetime"}
|
{:else if field.type === "datetime"}
|
||||||
<DatePicker
|
<DatePicker
|
||||||
label="Earliest"
|
label="Earliest"
|
||||||
|
|
|
@ -18,12 +18,10 @@
|
||||||
let exportFormat = FORMATS[0].key
|
let exportFormat = FORMATS[0].key
|
||||||
|
|
||||||
async function exportView() {
|
async function exportView() {
|
||||||
const filename = `export.${exportFormat}`
|
|
||||||
download(
|
download(
|
||||||
`/api/views/export?view=${encodeURIComponent(
|
`/api/views/export?view=${encodeURIComponent(
|
||||||
view
|
view
|
||||||
)}&format=${exportFormat}`,
|
)}&format=${exportFormat}`
|
||||||
filename
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -9,7 +9,10 @@
|
||||||
import TableNavigator from "components/backend/TableNavigator/TableNavigator.svelte"
|
import TableNavigator from "components/backend/TableNavigator/TableNavigator.svelte"
|
||||||
import ICONS from "./icons"
|
import ICONS from "./icons"
|
||||||
|
|
||||||
|
let openDataSources = []
|
||||||
|
|
||||||
function selectDatasource(datasource) {
|
function selectDatasource(datasource) {
|
||||||
|
toggleNode(datasource)
|
||||||
datasources.select(datasource._id)
|
datasources.select(datasource._id)
|
||||||
$goto(`./datasource/${datasource._id}`)
|
$goto(`./datasource/${datasource._id}`)
|
||||||
}
|
}
|
||||||
|
@ -19,6 +22,15 @@
|
||||||
$goto(`./datasource/${query.datasourceId}/${query._id}`)
|
$goto(`./datasource/${query.datasourceId}/${query._id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleNode(datasource) {
|
||||||
|
const isOpen = openDataSources.includes(datasource._id)
|
||||||
|
if (isOpen) {
|
||||||
|
openDataSources = openDataSources.filter(id => datasource._id !== id)
|
||||||
|
} else {
|
||||||
|
openDataSources = [...openDataSources, datasource._id]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
datasources.fetch()
|
datasources.fetch()
|
||||||
queries.fetch()
|
queries.fetch()
|
||||||
|
@ -31,8 +43,11 @@
|
||||||
<NavItem
|
<NavItem
|
||||||
border={idx > 0}
|
border={idx > 0}
|
||||||
text={datasource.name}
|
text={datasource.name}
|
||||||
|
opened={openDataSources.includes(datasource._id)}
|
||||||
selected={$datasources.selected === datasource._id}
|
selected={$datasources.selected === datasource._id}
|
||||||
|
withArrow={true}
|
||||||
on:click={() => selectDatasource(datasource)}
|
on:click={() => selectDatasource(datasource)}
|
||||||
|
on:iconClick={() => toggleNode(datasource)}
|
||||||
>
|
>
|
||||||
<div class="datasource-icon" slot="icon">
|
<div class="datasource-icon" slot="icon">
|
||||||
<svelte:component
|
<svelte:component
|
||||||
|
@ -46,13 +61,16 @@
|
||||||
{/if}
|
{/if}
|
||||||
</NavItem>
|
</NavItem>
|
||||||
|
|
||||||
<TableNavigator sourceId={datasource._id} />
|
{#if openDataSources.includes(datasource._id)}
|
||||||
|
<TableNavigator sourceId={datasource._id} />
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#each $queries.list.filter(query => query.datasourceId === datasource._id) as query}
|
{#each $queries.list.filter(query => query.datasourceId === datasource._id) as query}
|
||||||
<NavItem
|
<NavItem
|
||||||
indentLevel={1}
|
indentLevel={1}
|
||||||
icon="SQLQuery"
|
icon="SQLQuery"
|
||||||
text={query.name}
|
text={query.name}
|
||||||
|
opened={$queries.selected === query._id}
|
||||||
selected={$queries.selected === query._id}
|
selected={$queries.selected === query._id}
|
||||||
on:click={() => onClickQuery(query)}
|
on:click={() => onClickQuery(query)}
|
||||||
>
|
>
|
||||||
|
|
|
@ -42,9 +42,9 @@
|
||||||
|
|
||||||
<Modal bind:this={modal} on:hide={onCancel}>
|
<Modal bind:this={modal} on:hide={onCancel}>
|
||||||
<ModalContent
|
<ModalContent
|
||||||
title="Update Datasource"
|
title="Edit Datasource"
|
||||||
size="L"
|
size="L"
|
||||||
confirmText="Update"
|
confirmText="Save"
|
||||||
onConfirm={updateDatasource}
|
onConfirm={updateDatasource}
|
||||||
disabled={error || !name || !datasource?.type}
|
disabled={error || !name || !datasource?.type}
|
||||||
>
|
>
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<div slot="control" class="icon">
|
<div slot="control" class="icon">
|
||||||
<Icon size="S" hoverable name="MoreSmallList" />
|
<Icon size="S" hoverable name="MoreSmallList" />
|
||||||
</div>
|
</div>
|
||||||
<MenuItem icon="Edit" on:click={updateDatasourceDialog.show}>Update</MenuItem>
|
<MenuItem icon="Edit" on:click={updateDatasourceDialog.show}>Edit</MenuItem>
|
||||||
<MenuItem icon="Delete" on:click={confirmDeleteDialog.show}>Delete</MenuItem>
|
<MenuItem icon="Delete" on:click={confirmDeleteDialog.show}>Delete</MenuItem>
|
||||||
</ActionMenu>
|
</ActionMenu>
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,10 @@
|
||||||
label: "Options",
|
label: "Options",
|
||||||
value: FIELDS.OPTIONS.type,
|
value: FIELDS.OPTIONS.type,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "Multi-select",
|
||||||
|
value: FIELDS.ARRAY.type,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -7,16 +7,29 @@
|
||||||
ProgressCircle,
|
ProgressCircle,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import { admin } from "stores/portal"
|
import { admin } from "stores/portal"
|
||||||
|
import { goto } from "@roxi/routify"
|
||||||
|
import { onMount } from "svelte"
|
||||||
|
|
||||||
const MESSAGES = {
|
let width = window.innerWidth
|
||||||
apps: "Create your first app",
|
$: side = width < 500 ? "right" : "left"
|
||||||
smtp: "Set up email",
|
|
||||||
adminUser: "Create your first user",
|
const resizeObserver = new ResizeObserver(entries => {
|
||||||
sso: "Set up single sign-on",
|
if (entries?.[0]) {
|
||||||
}
|
width = entries[0].contentRect?.width
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
const doc = document.documentElement
|
||||||
|
resizeObserver.observe(doc)
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
resizeObserver.unobserve(doc)
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ActionMenu>
|
<ActionMenu align={side}>
|
||||||
<div slot="control" class="icon">
|
<div slot="control" class="icon">
|
||||||
<ProgressCircle size="S" value={$admin.onboardingProgress} />
|
<ProgressCircle size="S" value={$admin.onboardingProgress} />
|
||||||
</div>
|
</div>
|
||||||
|
@ -28,9 +41,12 @@
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{#each Object.keys($admin.checklist) as checklistItem, idx}
|
{#each Object.keys($admin.checklist) as checklistItem, idx}
|
||||||
<MenuItem>
|
<MenuItem>
|
||||||
<div class="item">
|
<div
|
||||||
<span>{idx + 1}. {MESSAGES[checklistItem]}</span>
|
class="item"
|
||||||
<Checkbox value={!!$admin.checklist[checklistItem]} />
|
on:click={() => $goto($admin.checklist[checklistItem].link)}
|
||||||
|
>
|
||||||
|
<span>{idx + 1}. {$admin.checklist[checklistItem].label}</span>
|
||||||
|
<Checkbox value={$admin.checklist[checklistItem].checked} />
|
||||||
</div>
|
</div>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{/each}
|
{/each}
|
||||||
|
@ -40,7 +56,7 @@
|
||||||
.item {
|
.item {
|
||||||
display: grid;
|
display: grid;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
grid-template-columns: 200px 20px;
|
grid-template-columns: 175px 20px;
|
||||||
}
|
}
|
||||||
.icon {
|
.icon {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { Icon } from "@budibase/bbui"
|
import { Icon } from "@budibase/bbui"
|
||||||
|
import { createEventDispatcher } from "svelte"
|
||||||
|
|
||||||
export let icon
|
export let icon
|
||||||
export let withArrow = false
|
export let withArrow = false
|
||||||
|
@ -10,6 +11,13 @@
|
||||||
export let selected = false
|
export let selected = false
|
||||||
export let opened = false
|
export let opened = false
|
||||||
export let draggable = false
|
export let draggable = false
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
function onIconClick(event) {
|
||||||
|
event.stopPropagation()
|
||||||
|
dispatch("iconClick")
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
@ -28,7 +36,7 @@
|
||||||
>
|
>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{#if withArrow}
|
{#if withArrow}
|
||||||
<div class:opened class="icon arrow">
|
<div class:opened class="icon arrow" on:click={onIconClick}>
|
||||||
<Icon size="S" name="ChevronRight" />
|
<Icon size="S" name="ChevronRight" />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
export let placeholder
|
export let placeholder
|
||||||
export let label
|
export let label
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
|
export let fillWidth
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
let bindingDrawer
|
let bindingDrawer
|
||||||
|
@ -45,7 +46,7 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<Drawer bind:this={bindingDrawer} {title}>
|
<Drawer {fillWidth} bind:this={bindingDrawer} {title}>
|
||||||
<svelte:fragment slot="description">
|
<svelte:fragment slot="description">
|
||||||
Add the objects on the left to enrich your text.
|
Add the objects on the left to enrich your text.
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
|
|
|
@ -33,6 +33,6 @@
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
div {
|
div {
|
||||||
padding-right: 8px;
|
width: 100px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -83,10 +83,11 @@
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
margin-top: -10px;
|
|
||||||
}
|
}
|
||||||
.components :global(> *) {
|
.components :global(> *) {
|
||||||
margin-top: 10px;
|
height: 32px;
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.buttonContent {
|
.buttonContent {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { onMount } from "svelte"
|
import { onMount, onDestroy } from "svelte"
|
||||||
import { store, currentAsset } from "builderStore"
|
import { store, currentAsset } from "builderStore"
|
||||||
import iframeTemplate from "./iframeTemplate"
|
import iframeTemplate from "./iframeTemplate"
|
||||||
import { Screen } from "builderStore/store/screenTemplates/utils/Screen"
|
import { Screen } from "builderStore/store/screenTemplates/utils/Screen"
|
||||||
|
@ -49,6 +49,8 @@
|
||||||
selectedComponentId,
|
selectedComponentId,
|
||||||
previewType: $store.currentFrontEndType,
|
previewType: $store.currentFrontEndType,
|
||||||
theme: $store.theme,
|
theme: $store.theme,
|
||||||
|
customTheme: $store.customTheme,
|
||||||
|
previewDevice: $store.previewDevice,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Saving pages and screens to the DB causes them to have _revs.
|
// Saving pages and screens to the DB causes them to have _revs.
|
||||||
|
@ -95,26 +97,53 @@
|
||||||
{ once: true }
|
{ once: true }
|
||||||
)
|
)
|
||||||
|
|
||||||
// Add listener for events sent by cliebt library in preview
|
// Add listener for events sent by client library in preview
|
||||||
iframe.contentWindow.addEventListener("bb-event", event => {
|
iframe.contentWindow.addEventListener("bb-event", handleBudibaseEvent)
|
||||||
const { type, data } = event.detail
|
iframe.contentWindow.addEventListener("keydown", handleKeydownEvent)
|
||||||
if (type === "select-component" && data.id) {
|
|
||||||
store.actions.components.select({ _id: data.id })
|
|
||||||
} else if (type === "update-prop") {
|
|
||||||
store.actions.components.updateProp(data.prop, data.value)
|
|
||||||
} else if (type === "delete-component" && data.id) {
|
|
||||||
idToDelete = data.id
|
|
||||||
confirmDeleteDialog.show()
|
|
||||||
} else if (type === "preview-loaded") {
|
|
||||||
// Wait for this event to show the client library if intelligent
|
|
||||||
// loading is supported
|
|
||||||
loading = false
|
|
||||||
} else {
|
|
||||||
console.warning(`Client sent unknown event type: ${type}`)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// remove all iframe event listeners on component destroy
|
||||||
|
onDestroy(() => {
|
||||||
|
if (iframe.contentWindow) {
|
||||||
|
iframe.contentWindow.removeEventListener("bb-event", handleBudibaseEvent)
|
||||||
|
iframe.contentWindow.removeEventListener("keydown", handleKeydownEvent)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const handleBudibaseEvent = event => {
|
||||||
|
const { type, data } = event.detail
|
||||||
|
if (type === "select-component" && data.id) {
|
||||||
|
store.actions.components.select({ _id: data.id })
|
||||||
|
} else if (type === "update-prop") {
|
||||||
|
store.actions.components.updateProp(data.prop, data.value)
|
||||||
|
} else if (type === "delete-component" && data.id) {
|
||||||
|
confirmDeleteComponent(data.id)
|
||||||
|
} else if (type === "preview-loaded") {
|
||||||
|
// Wait for this event to show the client library if intelligent
|
||||||
|
// loading is supported
|
||||||
|
loading = false
|
||||||
|
} else {
|
||||||
|
console.warning(`Client sent unknown event type: ${type}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleKeydownEvent = event => {
|
||||||
|
if (
|
||||||
|
(event.key === "Delete" || event.key === "Backspace") &&
|
||||||
|
selectedComponentId &&
|
||||||
|
["input", "textarea"].indexOf(
|
||||||
|
iframe.contentWindow.document.activeElement?.tagName.toLowerCase()
|
||||||
|
) === -1
|
||||||
|
) {
|
||||||
|
confirmDeleteComponent(selectedComponentId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmDeleteComponent = componentId => {
|
||||||
|
idToDelete = componentId
|
||||||
|
confirmDeleteDialog.show()
|
||||||
|
}
|
||||||
|
|
||||||
const deleteComponent = () => {
|
const deleteComponent = () => {
|
||||||
store.actions.components.delete({ _id: idToDelete })
|
store.actions.components.delete({ _id: idToDelete })
|
||||||
idToDelete = null
|
idToDelete = null
|
||||||
|
@ -139,11 +168,12 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<iframe
|
<iframe
|
||||||
style="height: 100%; width: 100%"
|
|
||||||
title="componentPreview"
|
title="componentPreview"
|
||||||
bind:this={iframe}
|
bind:this={iframe}
|
||||||
srcdoc={template}
|
srcdoc={template}
|
||||||
class:hidden={loading || error}
|
class:hidden={loading || error}
|
||||||
|
class:tablet={$store.previewDevice === "tablet"}
|
||||||
|
class:mobile={$store.previewDevice === "mobile"}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
|
@ -159,6 +189,8 @@
|
||||||
.component-container {
|
.component-container {
|
||||||
grid-row-start: middle;
|
grid-row-start: middle;
|
||||||
grid-column-start: middle;
|
grid-column-start: middle;
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
|
@ -199,4 +231,9 @@
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iframe {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
<script>
|
||||||
|
import { ActionGroup, ActionButton } from "@budibase/bbui"
|
||||||
|
import { store } from "builderStore"
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<ActionGroup compact>
|
||||||
|
<ActionButton
|
||||||
|
icon="DeviceDesktop"
|
||||||
|
selected={$store.previewDevice === "desktop"}
|
||||||
|
on:click={() => store.actions.preview.setDevice("desktop")}
|
||||||
|
/>
|
||||||
|
<ActionButton
|
||||||
|
icon="DeviceTablet"
|
||||||
|
selected={$store.previewDevice === "tablet"}
|
||||||
|
on:click={() => store.actions.preview.setDevice("tablet")}
|
||||||
|
/>
|
||||||
|
<ActionButton
|
||||||
|
icon="DevicePhone"
|
||||||
|
selected={$store.previewDevice === "mobile"}
|
||||||
|
on:click={() => store.actions.preview.setDevice("mobile")}
|
||||||
|
/>
|
||||||
|
</ActionGroup>
|
|
@ -0,0 +1,140 @@
|
||||||
|
<script>
|
||||||
|
import { get } from "svelte/store"
|
||||||
|
import {
|
||||||
|
ActionButton,
|
||||||
|
Modal,
|
||||||
|
ModalContent,
|
||||||
|
Layout,
|
||||||
|
ColorPicker,
|
||||||
|
Label,
|
||||||
|
Select,
|
||||||
|
Button,
|
||||||
|
} from "@budibase/bbui"
|
||||||
|
import { store } from "builderStore"
|
||||||
|
import AppThemeSelect from "./AppThemeSelect.svelte"
|
||||||
|
|
||||||
|
let modal
|
||||||
|
|
||||||
|
const defaultTheme = {
|
||||||
|
primaryColor: "var(--spectrum-global-color-blue-600)",
|
||||||
|
primaryColorHover: "var(--spectrum-global-color-blue-500)",
|
||||||
|
buttonBorderRadius: "16px",
|
||||||
|
navBackground: "var(--spectrum-global-color-gray-100)",
|
||||||
|
navTextColor: "var(--spectrum-global-color-gray-800)",
|
||||||
|
}
|
||||||
|
|
||||||
|
const buttonBorderRadiusOptions = [
|
||||||
|
{
|
||||||
|
label: "None",
|
||||||
|
value: "0",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Small",
|
||||||
|
value: "4px",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Medium",
|
||||||
|
value: "8px",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Large",
|
||||||
|
value: "16px",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
const updateProperty = property => {
|
||||||
|
return e => {
|
||||||
|
store.actions.customTheme.save({
|
||||||
|
...get(store).customTheme,
|
||||||
|
[property]: e.detail,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const resetTheme = () => {
|
||||||
|
store.actions.customTheme.save(null)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<ActionButton icon="Brush" on:click={modal.show}>Theme</ActionButton>
|
||||||
|
</div>
|
||||||
|
<Modal bind:this={modal}>
|
||||||
|
<ModalContent
|
||||||
|
showConfirmButton={false}
|
||||||
|
cancelText="Close"
|
||||||
|
showCloseIcon={false}
|
||||||
|
title="Theme settings"
|
||||||
|
>
|
||||||
|
<Layout noPadding gap="S">
|
||||||
|
<div class="setting">
|
||||||
|
<Label size="L">Theme</Label>
|
||||||
|
<AppThemeSelect />
|
||||||
|
</div>
|
||||||
|
<div class="setting">
|
||||||
|
<Label size="L">Button roundness</Label>
|
||||||
|
<div class="select-wrapper">
|
||||||
|
<Select
|
||||||
|
placeholder={null}
|
||||||
|
value={$store.customTheme?.buttonBorderRadius ||
|
||||||
|
defaultTheme.buttonBorderRadius}
|
||||||
|
on:change={updateProperty("buttonBorderRadius")}
|
||||||
|
options={buttonBorderRadiusOptions}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="setting">
|
||||||
|
<Label size="L">Primary color</Label>
|
||||||
|
<ColorPicker
|
||||||
|
spectrumTheme={$store.theme}
|
||||||
|
value={$store.customTheme?.primaryColor || defaultTheme.primaryColor}
|
||||||
|
on:change={updateProperty("primaryColor")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="setting">
|
||||||
|
<Label size="L">Primary color (hover)</Label>
|
||||||
|
<ColorPicker
|
||||||
|
spectrumTheme={$store.theme}
|
||||||
|
value={$store.customTheme?.primaryColorHover ||
|
||||||
|
defaultTheme.primaryColorHover}
|
||||||
|
on:change={updateProperty("primaryColorHover")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="setting">
|
||||||
|
<Label size="L">Navigation bar background color</Label>
|
||||||
|
<ColorPicker
|
||||||
|
spectrumTheme={$store.theme}
|
||||||
|
value={$store.customTheme?.navBackground ||
|
||||||
|
defaultTheme.navBackground}
|
||||||
|
on:change={updateProperty("navBackground")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="setting">
|
||||||
|
<Label size="L">Navigation bar text color</Label>
|
||||||
|
<ColorPicker
|
||||||
|
spectrumTheme={$store.theme}
|
||||||
|
value={$store.customTheme?.navTextColor || defaultTheme.navTextColor}
|
||||||
|
on:change={updateProperty("navTextColor")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Layout>
|
||||||
|
<div slot="footer">
|
||||||
|
<Button secondary quiet on:click={resetTheme}>Reset</Button>
|
||||||
|
</div>
|
||||||
|
</ModalContent>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.container {
|
||||||
|
padding-right: 8px;
|
||||||
|
}
|
||||||
|
.setting {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.select-wrapper {
|
||||||
|
width: 100px;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -21,7 +21,8 @@
|
||||||
"datetimefield",
|
"datetimefield",
|
||||||
"attachmentfield",
|
"attachmentfield",
|
||||||
"relationshipfield",
|
"relationshipfield",
|
||||||
"daterangepicker"
|
"daterangepicker",
|
||||||
|
"multifieldselect"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,18 +17,14 @@ export default `
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
html {
|
html {
|
||||||
height: calc(100% - 16px);
|
height: 100%;
|
||||||
width: calc(100% - 16px);
|
width: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin: 8px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
}
|
}
|
||||||
html.loaded {
|
|
||||||
box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
body {
|
body {
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@ -66,7 +62,9 @@ export default `
|
||||||
screen,
|
screen,
|
||||||
previewType,
|
previewType,
|
||||||
appId,
|
appId,
|
||||||
theme
|
theme,
|
||||||
|
customTheme,
|
||||||
|
previewDevice
|
||||||
} = parsed
|
} = parsed
|
||||||
|
|
||||||
// Set some flags so the app knows we're in the builder
|
// Set some flags so the app knows we're in the builder
|
||||||
|
@ -78,6 +76,8 @@ export default `
|
||||||
window["##BUDIBASE_PREVIEW_ID##"] = Math.random()
|
window["##BUDIBASE_PREVIEW_ID##"] = Math.random()
|
||||||
window["##BUDIBASE_PREVIEW_TYPE##"] = previewType
|
window["##BUDIBASE_PREVIEW_TYPE##"] = previewType
|
||||||
window["##BUDIBASE_PREVIEW_THEME##"] = theme
|
window["##BUDIBASE_PREVIEW_THEME##"] = theme
|
||||||
|
window["##BUDIBASE_PREVIEW_CUSTOM_THEME##"] = customTheme
|
||||||
|
window["##BUDIBASE_PREVIEW_DEVICE##"] = previewDevice
|
||||||
|
|
||||||
// Initialise app
|
// Initialise app
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { store, allScreens, selectedAccessRole } from "builderStore"
|
import { store, allScreens, selectedAccessRole } from "builderStore"
|
||||||
import { tables, roles } from "stores/backend"
|
import { tables } from "stores/backend"
|
||||||
|
import { roles } from "stores/backend"
|
||||||
import { Input, Select, ModalContent, Toggle } from "@budibase/bbui"
|
import { Input, Select, ModalContent, Toggle } from "@budibase/bbui"
|
||||||
import getTemplates from "builderStore/store/screenTemplates"
|
import getTemplates from "builderStore/store/screenTemplates"
|
||||||
import analytics from "analytics"
|
import analytics from "analytics"
|
||||||
|
@ -15,7 +16,7 @@
|
||||||
let createLink = true
|
let createLink = true
|
||||||
let roleId = $selectedAccessRole || "BASIC"
|
let roleId = $selectedAccessRole || "BASIC"
|
||||||
|
|
||||||
$: templates = getTemplates($store, tables.getDataSources())
|
$: templates = getTemplates($store, $tables.list)
|
||||||
$: route = !route && $allScreens.length === 0 ? "*" : route
|
$: route = !route && $allScreens.length === 0 ? "*" : route
|
||||||
$: {
|
$: {
|
||||||
if (templates && templateIndex === undefined) {
|
if (templates && templateIndex === undefined) {
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
export let bindings = []
|
export let bindings = []
|
||||||
|
|
||||||
$: text = value?.label ?? "Choose an option"
|
$: text = value?.label ?? "Choose an option"
|
||||||
$: tables = tablesStore.getDataSources().map(m => ({
|
$: tables = $tablesStore.list.map(m => ({
|
||||||
label: m.name,
|
label: m.name,
|
||||||
tableId: m._id,
|
tableId: m._id,
|
||||||
type: "table",
|
type: "table",
|
||||||
|
|
|
@ -9,11 +9,12 @@
|
||||||
ActionMenu,
|
ActionMenu,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import actionTypes from "./actions"
|
import { getAvailableActions } from "./actions"
|
||||||
import { generate } from "shortid"
|
import { generate } from "shortid"
|
||||||
|
|
||||||
const flipDurationMs = 150
|
const flipDurationMs = 150
|
||||||
const EVENT_TYPE_KEY = "##eventHandlerType"
|
const EVENT_TYPE_KEY = "##eventHandlerType"
|
||||||
|
const actionTypes = getAvailableActions()
|
||||||
|
|
||||||
export let actions
|
export let actions
|
||||||
export let bindings = []
|
export let bindings = []
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
<script>
|
||||||
|
import { Select, Label, Combobox, Checkbox, Body } from "@budibase/bbui"
|
||||||
|
import { onMount } from "svelte"
|
||||||
|
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
|
||||||
|
import { getAllStateVariables } from "builderStore/dataBinding"
|
||||||
|
|
||||||
|
export let parameters
|
||||||
|
export let bindings = []
|
||||||
|
|
||||||
|
const keyOptions = getAllStateVariables()
|
||||||
|
const typeOptions = [
|
||||||
|
{
|
||||||
|
label: "Set value",
|
||||||
|
value: "set",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Delete value",
|
||||||
|
value: "delete",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
if (!parameters.type) {
|
||||||
|
parameters.type = "set"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="root">
|
||||||
|
<Label small>Type</Label>
|
||||||
|
<Select
|
||||||
|
placeholder={null}
|
||||||
|
bind:value={parameters.type}
|
||||||
|
options={typeOptions}
|
||||||
|
/>
|
||||||
|
<Label small>Key</Label>
|
||||||
|
<Combobox bind:value={parameters.key} options={keyOptions} />
|
||||||
|
{#if parameters.type === "set"}
|
||||||
|
<Label small>Value</Label>
|
||||||
|
<DrawerBindableInput
|
||||||
|
{bindings}
|
||||||
|
value={parameters.value}
|
||||||
|
on:change={e => (parameters.value = e.detail)}
|
||||||
|
/>
|
||||||
|
<div />
|
||||||
|
<Checkbox bind:value={parameters.persist} text="Persist this value" />
|
||||||
|
<div />
|
||||||
|
<Body size="XS">
|
||||||
|
Persisted values will remain even after reloading the page or closing the
|
||||||
|
browser.
|
||||||
|
</Body>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.root {
|
||||||
|
display: grid;
|
||||||
|
column-gap: var(--spacing-l);
|
||||||
|
row-gap: var(--spacing-s);
|
||||||
|
grid-template-columns: 60px 1fr;
|
||||||
|
align-items: center;
|
||||||
|
max-width: 400px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,3 +1,6 @@
|
||||||
|
import { store } from "builderStore"
|
||||||
|
import { get } from "svelte/store"
|
||||||
|
|
||||||
import NavigateTo from "./NavigateTo.svelte"
|
import NavigateTo from "./NavigateTo.svelte"
|
||||||
import SaveRow from "./SaveRow.svelte"
|
import SaveRow from "./SaveRow.svelte"
|
||||||
import DeleteRow from "./DeleteRow.svelte"
|
import DeleteRow from "./DeleteRow.svelte"
|
||||||
|
@ -8,6 +11,7 @@ import LogOut from "./LogOut.svelte"
|
||||||
import ClearForm from "./ClearForm.svelte"
|
import ClearForm from "./ClearForm.svelte"
|
||||||
import CloseScreenModal from "./CloseScreenModal.svelte"
|
import CloseScreenModal from "./CloseScreenModal.svelte"
|
||||||
import ChangeFormStep from "./ChangeFormStep.svelte"
|
import ChangeFormStep from "./ChangeFormStep.svelte"
|
||||||
|
import UpdateStateStep from "./UpdateState.svelte"
|
||||||
|
|
||||||
// Defines which actions are available to configure in the front end.
|
// Defines which actions are available to configure in the front end.
|
||||||
// Unfortunately the "name" property is used as the identifier so please don't
|
// Unfortunately the "name" property is used as the identifier so please don't
|
||||||
|
@ -16,45 +20,56 @@ import ChangeFormStep from "./ChangeFormStep.svelte"
|
||||||
// be considered as camel case too.
|
// be considered as camel case too.
|
||||||
// There is technical debt here to sanitize all these and standardise them
|
// There is technical debt here to sanitize all these and standardise them
|
||||||
// across the packages but it's a breaking change to existing apps.
|
// across the packages but it's a breaking change to existing apps.
|
||||||
export default [
|
export const getAvailableActions = () => {
|
||||||
{
|
let actions = [
|
||||||
name: "Save Row",
|
{
|
||||||
component: SaveRow,
|
name: "Save Row",
|
||||||
},
|
component: SaveRow,
|
||||||
{
|
},
|
||||||
name: "Delete Row",
|
{
|
||||||
component: DeleteRow,
|
name: "Delete Row",
|
||||||
},
|
component: DeleteRow,
|
||||||
{
|
},
|
||||||
name: "Navigate To",
|
{
|
||||||
component: NavigateTo,
|
name: "Navigate To",
|
||||||
},
|
component: NavigateTo,
|
||||||
{
|
},
|
||||||
name: "Execute Query",
|
{
|
||||||
component: ExecuteQuery,
|
name: "Execute Query",
|
||||||
},
|
component: ExecuteQuery,
|
||||||
{
|
},
|
||||||
name: "Trigger Automation",
|
{
|
||||||
component: TriggerAutomation,
|
name: "Trigger Automation",
|
||||||
},
|
component: TriggerAutomation,
|
||||||
{
|
},
|
||||||
name: "Validate Form",
|
{
|
||||||
component: ValidateForm,
|
name: "Validate Form",
|
||||||
},
|
component: ValidateForm,
|
||||||
{
|
},
|
||||||
name: "Log Out",
|
{
|
||||||
component: LogOut,
|
name: "Log Out",
|
||||||
},
|
component: LogOut,
|
||||||
{
|
},
|
||||||
name: "Clear Form",
|
{
|
||||||
component: ClearForm,
|
name: "Clear Form",
|
||||||
},
|
component: ClearForm,
|
||||||
{
|
},
|
||||||
name: "Close Screen Modal",
|
{
|
||||||
component: CloseScreenModal,
|
name: "Close Screen Modal",
|
||||||
},
|
component: CloseScreenModal,
|
||||||
{
|
},
|
||||||
name: "Change Form Step",
|
{
|
||||||
component: ChangeFormStep,
|
name: "Change Form Step",
|
||||||
},
|
component: ChangeFormStep,
|
||||||
]
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
if (get(store).clientFeatures?.state) {
|
||||||
|
actions.push({
|
||||||
|
name: "Update State",
|
||||||
|
component: UpdateStateStep,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return actions
|
||||||
|
}
|
||||||
|
|
|
@ -1,22 +1,24 @@
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
DatePicker,
|
|
||||||
Icon,
|
|
||||||
Button,
|
|
||||||
Select,
|
|
||||||
Combobox,
|
|
||||||
Input,
|
|
||||||
DrawerContent,
|
|
||||||
Layout,
|
|
||||||
Body,
|
Body,
|
||||||
|
Button,
|
||||||
|
Combobox,
|
||||||
|
DatePicker,
|
||||||
|
DrawerContent,
|
||||||
|
Icon,
|
||||||
|
Input,
|
||||||
|
Layout,
|
||||||
|
Select,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
|
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
|
||||||
|
import BindingPanel from "components/common/bindings/BindingPanel.svelte"
|
||||||
import { generate } from "shortid"
|
import { generate } from "shortid"
|
||||||
import { OperatorOptions, getValidOperatorsForType } from "helpers/lucene"
|
import { getValidOperatorsForType, OperatorOptions } from "helpers/lucene"
|
||||||
|
|
||||||
export let schemaFields
|
export let schemaFields
|
||||||
export let filters = []
|
export let filters = []
|
||||||
export let bindings = []
|
export let bindings = []
|
||||||
|
export let panel = BindingPanel
|
||||||
|
|
||||||
const BannedTypes = ["link", "attachment", "formula"]
|
const BannedTypes = ["link", "attachment", "formula"]
|
||||||
|
|
||||||
|
@ -59,6 +61,14 @@
|
||||||
expression.operator = validOperators[0] ?? OperatorOptions.Equals.value
|
expression.operator = validOperators[0] ?? OperatorOptions.Equals.value
|
||||||
onOperatorChange(expression, expression.operator)
|
onOperatorChange(expression, expression.operator)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if changed to an array, change default value to empty array
|
||||||
|
const idx = filters.findIndex(x => x.field === field)
|
||||||
|
if (expression.type === "array") {
|
||||||
|
filters[idx].value = []
|
||||||
|
} else {
|
||||||
|
filters[idx].value = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onOperatorChange = (expression, operator) => {
|
const onOperatorChange = (expression, operator) => {
|
||||||
|
@ -117,12 +127,13 @@
|
||||||
title={`Value for "${filter.field}"`}
|
title={`Value for "${filter.field}"`}
|
||||||
value={filter.value}
|
value={filter.value}
|
||||||
placeholder="Value"
|
placeholder="Value"
|
||||||
|
{panel}
|
||||||
{bindings}
|
{bindings}
|
||||||
on:change={event => (filter.value = event.detail)}
|
on:change={event => (filter.value = event.detail)}
|
||||||
/>
|
/>
|
||||||
{:else if ["string", "longform", "number"].includes(filter.type)}
|
{:else if ["string", "longform", "number"].includes(filter.type)}
|
||||||
<Input disabled={filter.noValue} bind:value={filter.value} />
|
<Input disabled={filter.noValue} bind:value={filter.value} />
|
||||||
{:else if filter.type === "options"}
|
{:else if filter.type === "options" || "array"}
|
||||||
<Combobox
|
<Combobox
|
||||||
disabled={filter.noValue}
|
disabled={filter.noValue}
|
||||||
options={getFieldOptions(filter.field)}
|
options={getFieldOptions(filter.field)}
|
||||||
|
|
|
@ -58,11 +58,11 @@
|
||||||
value: "notRegex",
|
value: "notRegex",
|
||||||
},
|
},
|
||||||
Contains: {
|
Contains: {
|
||||||
label: "Must contain row ID",
|
label: "Must contain",
|
||||||
value: "contains",
|
value: "contains",
|
||||||
},
|
},
|
||||||
NotContains: {
|
NotContains: {
|
||||||
label: "Must not contain row ID",
|
label: "Must not contain",
|
||||||
value: "notContains",
|
value: "notContains",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -102,6 +102,13 @@
|
||||||
Constraints.MinLength,
|
Constraints.MinLength,
|
||||||
Constraints.MaxLength,
|
Constraints.MaxLength,
|
||||||
],
|
],
|
||||||
|
["array"]: [
|
||||||
|
Constraints.Required,
|
||||||
|
Constraints.MinLength,
|
||||||
|
Constraints.MaxLength,
|
||||||
|
Constraints.Contains,
|
||||||
|
Constraints.NotContains,
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
$: dataSourceSchema = getDataSourceSchema($currentAsset, $selectedComponent)
|
$: dataSourceSchema = getDataSourceSchema($currentAsset, $selectedComponent)
|
||||||
|
@ -109,7 +116,6 @@
|
||||||
$: schemaRules = parseRulesFromSchema(field, dataSourceSchema || {})
|
$: schemaRules = parseRulesFromSchema(field, dataSourceSchema || {})
|
||||||
$: fieldType = type?.split("/")[1] || "string"
|
$: fieldType = type?.split("/")[1] || "string"
|
||||||
$: constraintOptions = getConstraintsForType(fieldType)
|
$: constraintOptions = getConstraintsForType(fieldType)
|
||||||
|
|
||||||
const getConstraintsForType = type => {
|
const getConstraintsForType = type => {
|
||||||
return ConstraintMap[type]
|
return ConstraintMap[type]
|
||||||
}
|
}
|
||||||
|
@ -190,6 +196,7 @@
|
||||||
valueType: "Binding",
|
valueType: "Binding",
|
||||||
type: fieldType,
|
type: fieldType,
|
||||||
id: generate(),
|
id: generate(),
|
||||||
|
value: fieldType == "array" ? [] : null,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -275,7 +282,7 @@
|
||||||
disabled={rule.constraint === "required"}
|
disabled={rule.constraint === "required"}
|
||||||
on:change={e => (rule.value = e.detail)}
|
on:change={e => (rule.value = e.detail)}
|
||||||
/>
|
/>
|
||||||
{:else if ["maxLength", "minLength", "regex", "notRegex", "contains", "notContains"].includes(rule.constraint)}
|
{:else if rule.type !== "array" && ["maxLength", "minLength", "regex", "notRegex", "contains", "notContains"].includes(rule.constraint)}
|
||||||
<!-- Certain constraints always need string values-->
|
<!-- Certain constraints always need string values-->
|
||||||
<Input
|
<Input
|
||||||
bind:value={rule.value}
|
bind:value={rule.value}
|
||||||
|
@ -289,6 +296,15 @@
|
||||||
bind:value={rule.value}
|
bind:value={rule.value}
|
||||||
placeholder="Constraint value"
|
placeholder="Constraint value"
|
||||||
/>
|
/>
|
||||||
|
{:else if rule.type === "array"}
|
||||||
|
<Select
|
||||||
|
disabled={rule.constraint === "required"}
|
||||||
|
options={dataSourceSchema.schema[field].constraints
|
||||||
|
.inclusion}
|
||||||
|
getOptionLabel={x => x}
|
||||||
|
getOptionValue={x => x}
|
||||||
|
value={rule.value}
|
||||||
|
/>
|
||||||
{:else if rule.type === "boolean"}
|
{:else if rule.type === "boolean"}
|
||||||
<Select
|
<Select
|
||||||
disabled={rule.constraint === "required"}
|
disabled={rule.constraint === "required"}
|
||||||
|
|
|
@ -43,9 +43,11 @@ const componentMap = {
|
||||||
"field/datetime": FormFieldSelect,
|
"field/datetime": FormFieldSelect,
|
||||||
"field/attachment": FormFieldSelect,
|
"field/attachment": FormFieldSelect,
|
||||||
"field/link": FormFieldSelect,
|
"field/link": FormFieldSelect,
|
||||||
|
"field/array": FormFieldSelect,
|
||||||
// Some validation types are the same as others, so not all types are
|
// Some validation types are the same as others, so not all types are
|
||||||
// explicitly listed here. e.g. options uses string validation
|
// explicitly listed here. e.g. options uses string validation
|
||||||
"validation/string": ValidationEditor,
|
"validation/string": ValidationEditor,
|
||||||
|
"validation/array": ValidationEditor,
|
||||||
"validation/number": ValidationEditor,
|
"validation/number": ValidationEditor,
|
||||||
"validation/boolean": ValidationEditor,
|
"validation/boolean": ValidationEditor,
|
||||||
"validation/datetime": ValidationEditor,
|
"validation/datetime": ValidationEditor,
|
||||||
|
|
|
@ -235,6 +235,7 @@
|
||||||
|
|
||||||
.viewer {
|
.viewer {
|
||||||
min-height: 200px;
|
min-height: 200px;
|
||||||
|
width: 640px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.preview {
|
.preview {
|
||||||
|
|
|
@ -54,9 +54,7 @@
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{/if}
|
{/if}
|
||||||
{#if !app.deployed}
|
{#if !app.deployed}
|
||||||
<MenuItem on:click={() => updateApp(app)} icon="Edit">
|
<MenuItem on:click={() => updateApp(app)} icon="Edit">Edit</MenuItem>
|
||||||
Update
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem on:click={() => deleteApp(app)} icon="Delete">
|
<MenuItem on:click={() => deleteApp(app)} icon="Delete">
|
||||||
Delete
|
Delete
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
</Heading>
|
</Heading>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="desktop">
|
||||||
{#if app.updatedAt}
|
{#if app.updatedAt}
|
||||||
{processStringSync("Updated {{ duration time 'millisecond' }} ago", {
|
{processStringSync("Updated {{ duration time 'millisecond' }} ago", {
|
||||||
time: new Date().getTime() - new Date(app.updatedAt).getTime(),
|
time: new Date().getTime() - new Date(app.updatedAt).getTime(),
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
Never updated
|
Never updated
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="desktop">
|
||||||
<StatusLight
|
<StatusLight
|
||||||
positive={!app.lockedYou && !app.lockedOther}
|
positive={!app.lockedYou && !app.lockedOther}
|
||||||
notice={app.lockedYou}
|
notice={app.lockedYou}
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
</StatusLight>
|
</StatusLight>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="desktop">
|
||||||
<StatusLight active={app.deployed} neutral={!app.deployed}>
|
<StatusLight active={app.deployed} neutral={!app.deployed}>
|
||||||
{#if app.deployed}Published{:else}Unpublished{/if}
|
{#if app.deployed}Published{:else}Unpublished{/if}
|
||||||
</StatusLight>
|
</StatusLight>
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{/if}
|
{/if}
|
||||||
{#if !app.deployed}
|
{#if !app.deployed}
|
||||||
<MenuItem on:click={() => updateApp(app)} icon="Edit">Update</MenuItem>
|
<MenuItem on:click={() => updateApp(app)} icon="Edit">Edit</MenuItem>
|
||||||
<MenuItem on:click={() => deleteApp(app)} icon="Delete">Delete</MenuItem>
|
<MenuItem on:click={() => deleteApp(app)} icon="Delete">Delete</MenuItem>
|
||||||
{/if}
|
{/if}
|
||||||
</ActionMenu>
|
</ActionMenu>
|
||||||
|
@ -109,4 +109,10 @@
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: color 130ms ease;
|
transition: color 130ms ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.desktop {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|