diff --git a/docs/budibase-0.2.0.tgz b/docs/budibase-0.2.0.tgz new file mode 100644 index 0000000000..379b92cbb7 Binary files /dev/null and b/docs/budibase-0.2.0.tgz differ diff --git a/docs/index.yaml b/docs/index.yaml index 4e064f3dd0..b050330477 100644 --- a/docs/index.yaml +++ b/docs/index.yaml @@ -1,9 +1,35 @@ apiVersion: v1 entries: budibase: + - apiVersion: v2 + appVersion: 0.9.163 + created: "2021-10-12T21:58:00.515555+01:00" + dependencies: + - condition: services.couchdb.enabled + name: couchdb + repository: https://apache.github.io/couchdb-helm + version: 3.3.4 + - condition: ingress.nginx + name: ingress-nginx + repository: https://github.com/kubernetes/ingress-nginx + version: 3.35.0 + description: Budibase is an open source low-code platform, helping thousands of teams build apps for their workplace in minutes. + digest: f369536c0eac1f6959d51e8ce6d74a87a7a9df29ae84fb9cbed0a273ab77429b + keywords: + - low-code + - database + - cluster + name: budibase + sources: + - https://github.com/Budibase/budibase + - https://budibase.com + type: application + urls: + - https://budibase.github.io/budibase/budibase-0.2.0.tgz + version: 0.2.0 - apiVersion: v2 appVersion: 0.9.56 - created: "2021-08-18T18:41:52.640176+01:00" + created: "2021-10-12T21:58:00.512062+01:00" dependencies: - condition: services.couchdb.enabled name: couchdb @@ -28,7 +54,7 @@ entries: version: 0.1.1 - apiVersion: v2 appVersion: 0.9.56 - created: "2021-08-18T18:41:52.635603+01:00" + created: "2021-10-12T21:58:00.507257+01:00" dependencies: - condition: services.couchdb.enabled name: couchdb @@ -51,4 +77,4 @@ entries: urls: - https://budibase.github.io/budibase/budibase-0.1.0.tgz version: 0.1.0 -generated: "2021-08-18T18:41:52.629415+01:00" +generated: "2021-10-12T21:58:00.503447+01:00" diff --git a/hosting/kubernetes/budibase/templates/.helmignore b/hosting/kubernetes/budibase/.helmignore similarity index 100% rename from hosting/kubernetes/budibase/templates/.helmignore rename to hosting/kubernetes/budibase/.helmignore diff --git a/hosting/kubernetes/budibase/Chart.yaml b/hosting/kubernetes/budibase/Chart.yaml index d00b228b0e..fa652ed28f 100644 --- a/hosting/kubernetes/budibase/Chart.yaml +++ b/hosting/kubernetes/budibase/Chart.yaml @@ -22,13 +22,13 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.1 +version: 0.2.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "0.9.56" +appVersion: "0.9.163" dependencies: - name: couchdb @@ -37,5 +37,5 @@ dependencies: condition: services.couchdb.enabled - name: ingress-nginx version: 3.35.0 - repository: https://kubernetes.github.io/ingress-nginx - condition: services.ingress.nginx + repository: https://github.com/kubernetes/ingress-nginx + condition: ingress.nginx diff --git a/hosting/kubernetes/budibase/templates/alb-ingress.yaml b/hosting/kubernetes/budibase/templates/alb-ingress.yaml index ea3bd674d5..388bcf1d3e 100644 --- a/hosting/kubernetes/budibase/templates/alb-ingress.yaml +++ b/hosting/kubernetes/budibase/templates/alb-ingress.yaml @@ -7,6 +7,8 @@ metadata: kubernetes.io/ingress.class: alb alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/target-type: ip + alb.ingress.kubernetes.io/success-codes: 200,301 + alb.ingress.kubernetes.io/healthcheck-path: / {{- if .Values.ingress.certificateArn }} alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}' alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]' diff --git a/hosting/kubernetes/budibase/templates/app-service-deployment.yaml b/hosting/kubernetes/budibase/templates/app-service-deployment.yaml index 98fdc8dfd0..bce532016a 100644 --- a/hosting/kubernetes/budibase/templates/app-service-deployment.yaml +++ b/hosting/kubernetes/budibase/templates/app-service-deployment.yaml @@ -14,7 +14,7 @@ spec: matchLabels: io.kompose.service: app-service strategy: - type: Recreate + type: RollingUpdate template: metadata: annotations: @@ -73,13 +73,11 @@ spec: name: {{ template "budibase.fullname" . }} key: objectStoreSecret - name: MINIO_URL - {{ if .Values.services.objectStore.url }} value: {{ .Values.services.objectStore.url }} - {{ else }} - value: http://minio-service:{{ .Values.services.objectStore.port }} - {{ end }} - name: PORT value: {{ .Values.services.apps.port | quote }} + - name: MULTI_TENANCY + value: "1" - name: REDIS_PASSWORD value: {{ .Values.services.redis.password }} - name: REDIS_URL @@ -92,14 +90,20 @@ spec: value: {{ .Values.globals.selfHosted | quote }} - name: SENTRY_DSN value: {{ .Values.globals.sentryDSN }} + - name: POSTHOG_TOKEN + value: {{ .Values.globals.posthogToken }} - name: WORKER_URL - value: worker-service:{{ .Values.services.worker.port }} - - name: COOKIE_DOMAIN - value: {{ .Values.globals.cookieDomain | quote }} + value: http://worker-service:{{ .Values.services.worker.port }} + - name: PLATFORM_URL + value: {{ .Values.globals.platformUrl | quote }} + - name: USE_QUOTAS + value: "1" - name: ACCOUNT_PORTAL_URL value: {{ .Values.globals.accountPortalUrl | quote }} - name: ACCOUNT_PORTAL_API_KEY value: {{ .Values.globals.accountPortalApiKey | quote }} + - name: COOKIE_DOMAIN + value: {{ .Values.globals.cookieDomain | quote }} image: budibase/apps imagePullPolicy: Always name: bbapps diff --git a/hosting/kubernetes/budibase/templates/proxy-service-deployment.yaml b/hosting/kubernetes/budibase/templates/proxy-service-deployment.yaml index 0f802da843..2e453d1c5b 100644 --- a/hosting/kubernetes/budibase/templates/proxy-service-deployment.yaml +++ b/hosting/kubernetes/budibase/templates/proxy-service-deployment.yaml @@ -14,7 +14,7 @@ spec: matchLabels: app.kubernetes.io/name: budibase-proxy strategy: - type: Recreate + type: RollingUpdate template: metadata: annotations: @@ -26,7 +26,7 @@ spec: spec: containers: - image: budibase/proxy - imagePullPolicy: "" + imagePullPolicy: Always name: proxy-service ports: - containerPort: {{ .Values.services.proxy.port }} diff --git a/hosting/kubernetes/budibase/templates/worker-service-deployment.yaml b/hosting/kubernetes/budibase/templates/worker-service-deployment.yaml index 08b40d3b6b..563b1b4193 100644 --- a/hosting/kubernetes/budibase/templates/worker-service-deployment.yaml +++ b/hosting/kubernetes/budibase/templates/worker-service-deployment.yaml @@ -15,7 +15,7 @@ spec: matchLabels: io.kompose.service: worker-service strategy: - type: Recreate + type: RollingUpdate template: metadata: annotations: @@ -70,13 +70,11 @@ spec: name: {{ template "budibase.fullname" . }} key: objectStoreSecret - name: MINIO_URL - {{ if .Values.services.objectStore.url }} value: {{ .Values.services.objectStore.url }} - {{ else }} - value: http://minio-service:{{ .Values.services.objectStore.port }} - {{ end }} - name: PORT value: {{ .Values.services.worker.port | quote }} + - name: MULTI_TENANCY + value: "1" - name: REDIS_PASSWORD value: {{ .Values.services.redis.password | quote }} - name: REDIS_URL @@ -91,8 +89,22 @@ spec: value: {{ .Values.globals.accountPortalUrl | quote }} - name: ACCOUNT_PORTAL_API_KEY value: {{ .Values.globals.accountPortalApiKey | quote }} + - name: PLATFORM_URL + value: {{ .Values.globals.platformUrl | quote }} - name: COOKIE_DOMAIN value: {{ .Values.globals.cookieDomain | quote }} + - name: SMTP_FALLBACK_ENABLED + value: {{ .Values.globals.smtp.enabled | quote }} + - name: SMTP_USER + value: {{ .Values.globals.smtp.user | quote }} + - name: SMTP_PASSWORD + value: {{ .Values.globals.smtp.password | quote }} + - name: SMTP_HOST + value: {{ .Values.globals.smtp.host | quote }} + - name: SMTP_PORT + value: {{ .Values.globals.smtp.port | quote }} + - name: SMTP_FROM_ADDRESS + value: {{ .Values.globals.smtp.from | quote }} image: budibase/worker imagePullPolicy: Always name: bbworker diff --git a/hosting/kubernetes/budibase/values.yaml b/hosting/kubernetes/budibase/values.yaml index 5999f9c4bc..774f7ea102 100644 --- a/hosting/kubernetes/budibase/values.yaml +++ b/hosting/kubernetes/budibase/values.yaml @@ -40,11 +40,12 @@ service: port: 10000 ingress: - enabled: true - nginx: true - certificateArn: "" + enabled: false + aws: false + nginx: true + certificateArn: "" className: "" - annotations: + annotations: kubernetes.io/ingress.class: nginx hosts: - host: # change if using custom domain @@ -55,7 +56,7 @@ ingress: service: name: proxy-service port: - number: 10000 + number: 10000 resources: {} # We usually recommend not to specify default resources and to leave this as a conscious @@ -84,20 +85,24 @@ affinity: {} globals: budibaseEnv: PRODUCTION - enableAnalytics: false - posthogToken: "" + enableAnalytics: true sentryDSN: "" + posthogToken: "" logLevel: info - selfHosted: 1 - accountPortalUrL: "" + selfHosted: "" + accountPortalUrl: "" accountPortalApiKey: "" - cookieDomain: "" + cookieDomain: "" + platformUrl: "" + 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 internalApiKey: "" jwtSecret: "" + smtp: + enabled: false services: dns: cluster.local @@ -118,12 +123,12 @@ services: couchdb: enabled: true replicaCount: 3 - url: "" # only change if pointing to existing couch server - user: "" # only change if pointing to existing couch server - password: "" # only change if pointing to existing couch server + # url: "" # only change if pointing to existing couch server + # user: "" # only change if pointing to existing couch server + # password: "" # only change if pointing to existing couch server port: 5984 storage: 100Mi - + redis: enabled: true # disable if using external redis port: 6379 @@ -131,7 +136,7 @@ services: url: "" # only change if pointing to existing redis cluster and enabled: false password: "budibase" # recommended to override if using built-in redis storage: 100Mi - + objectStore: minio: true browser: true diff --git a/lerna.json b/lerna.json index 9d4d302f12..798c1a4222 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.163", + "version": "0.9.166", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index fbf9c98ddb..0d677551fb 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.163", + "version": "0.9.166", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/auth/src/middleware/authenticated.js b/packages/auth/src/middleware/authenticated.js index 944f3ee9d9..4223e7e395 100644 --- a/packages/auth/src/middleware/authenticated.js +++ b/packages/auth/src/middleware/authenticated.js @@ -42,8 +42,9 @@ module.exports = ( internal = false if (authCookie) { let error = null - const sessionId = authCookie.sessionId, - userId = authCookie.userId + const sessionId = authCookie.sessionId + const userId = authCookie.userId + const session = await getSession(userId, sessionId) if (!session) { error = "No session found" diff --git a/packages/auth/src/security/sessions.js b/packages/auth/src/security/sessions.js index 83ca9d9bcd..93c2d0a9ca 100644 --- a/packages/auth/src/security/sessions.js +++ b/packages/auth/src/security/sessions.js @@ -24,17 +24,24 @@ exports.createASession = async (userId, session) => { await client.store(makeSessionID(userId, sessionId), session, EXPIRY_SECONDS) } -exports.invalidateSessions = async (userId, sessionId = null) => { +exports.invalidateSessions = async (userId, sessionIds = null) => { let sessions = [] - if (sessionId) { - sessions.push({ key: makeSessionID(userId, sessionId) }) - } else { + + // If no sessionIds, get all the sessions for the user + if (!sessionIds) { sessions = await getSessionsForUser(userId) sessions.forEach( session => (session.key = makeSessionID(session.userId, session.sessionId)) ) + } else { + // use the passed array of sessionIds + sessions = Array.isArray(sessionIds) ? sessionIds : [sessionIds] + sessions = sessions.map(sessionId => ({ + key: makeSessionID(userId, sessionId), + })) } + const client = await redis.getSessionClient() const promises = [] for (let session of sessions) { diff --git a/packages/auth/src/utils.js b/packages/auth/src/utils.js index f509a626c1..823fd06322 100644 --- a/packages/auth/src/utils.js +++ b/packages/auth/src/utils.js @@ -7,7 +7,7 @@ const { const jwt = require("jsonwebtoken") const { options } = require("./middleware/passport/jwt") const { createUserEmailView } = require("./db/views") -const { Headers, UserStatus } = require("./constants") +const { Headers, UserStatus, Cookies } = require("./constants") const { getGlobalDB, updateTenantId, @@ -19,6 +19,7 @@ const accounts = require("./cloud/accounts") const { hash } = require("./hashing") const userCache = require("./cache/user") const env = require("./environment") +const { getUserSessions, invalidateSessions } = require("./security/sessions") const APP_PREFIX = DocumentTypes.APP + SEPARATOR @@ -235,3 +236,28 @@ exports.saveUser = async ( } } } + +/** + * Logs a user out from budibase. Re-used across account portal and builder. + */ +exports.platformLogout = async ({ ctx, userId, keepActiveSession }) => { + if (!ctx) throw new Error("Koa context must be supplied to logout.") + + const currentSession = this.getCookie(ctx, Cookies.Auth) + let sessions = await getUserSessions(userId) + + if (keepActiveSession) { + sessions = sessions.filter( + session => session.sessionId !== currentSession.sessionId + ) + } else { + // clear cookies + this.clearCookie(ctx, Cookies.Auth) + this.clearCookie(ctx, Cookies.CurrentApp) + } + + await invalidateSessions( + userId, + sessions.map(({ sessionId }) => sessionId) + ) +} diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 362c4732e4..55d23cbea4 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "0.9.163", + "version": "0.9.166", "license": "AGPL-3.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/bbui/src/Table/CellRenderer.svelte b/packages/bbui/src/Table/CellRenderer.svelte index d6a2f3196d..1c3822e51e 100644 --- a/packages/bbui/src/Table/CellRenderer.svelte +++ b/packages/bbui/src/Table/CellRenderer.svelte @@ -5,11 +5,14 @@ import RelationshipRenderer from "./RelationshipRenderer.svelte" import AttachmentRenderer from "./AttachmentRenderer.svelte" import ArrayRenderer from "./ArrayRenderer.svelte" + import InternalRenderer from "./InternalRenderer.svelte" + export let row export let schema export let value export let customRenderers = [] + let renderer const typeMap = { boolean: BooleanRenderer, datetime: DateTimeRenderer, @@ -20,7 +23,9 @@ number: StringRenderer, longform: StringRenderer, array: ArrayRenderer, + internal: InternalRenderer, } + $: type = schema?.type ?? "string" $: customRenderer = customRenderers?.find(x => x.column === schema?.name) $: renderer = customRenderer?.component ?? typeMap[type] ?? StringRenderer diff --git a/packages/bbui/src/Table/InternalRenderer.svelte b/packages/bbui/src/Table/InternalRenderer.svelte new file mode 100644 index 0000000000..0f894ac853 --- /dev/null +++ b/packages/bbui/src/Table/InternalRenderer.svelte @@ -0,0 +1,28 @@ + + +
+ +
+ + diff --git a/packages/builder/cypress/integration/createTable.spec.js b/packages/builder/cypress/integration/createTable.spec.js index 07a3b8ac96..dad1cd5c37 100644 --- a/packages/builder/cypress/integration/createTable.spec.js +++ b/packages/builder/cypress/integration/createTable.spec.js @@ -31,6 +31,7 @@ context("Create a Table", () => { cy.contains("nameupdated ").should("contain", "nameupdated") }) + /* it("edits a row", () => { cy.contains("button", "Edit").click({ force: true }) cy.wait(1000) @@ -39,7 +40,7 @@ context("Create a Table", () => { cy.contains("Save").click() cy.contains("Updated").should("have.text", "Updated") }) - + */ it("deletes a row", () => { cy.get(".spectrum-Checkbox-input").check({ force: true }) cy.contains("Delete 1 row(s)").click() diff --git a/packages/builder/package.json b/packages/builder/package.json index a3d7488a27..0873727982 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.163", + "version": "0.9.166", "license": "AGPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.163", - "@budibase/client": "^0.9.163", + "@budibase/bbui": "^0.9.166", + "@budibase/client": "^0.9.166", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.163", + "@budibase/string-templates": "^0.9.166", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/builder/src/builderStore/store/automation/Automation.js b/packages/builder/src/builderStore/store/automation/Automation.js index 49928c69a9..af0c03cb5a 100644 --- a/packages/builder/src/builderStore/store/automation/Automation.js +++ b/packages/builder/src/builderStore/store/automation/Automation.js @@ -14,7 +14,7 @@ export default class Automation { } addTestData(data) { - this.automation.testData = data + this.automation.testData = { ...this.automation.testData, ...data } } addBlock(block, idx) { diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/TestDataModal.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/TestDataModal.svelte index 8caba9d351..3c75c9963d 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/TestDataModal.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/TestDataModal.svelte @@ -5,20 +5,24 @@ import { cloneDeep } from "lodash/fp" let failedParse = null + let trigger = {} + let schemaProperties = {} + // clone the trigger so we're not mutating the reference - let trigger = cloneDeep( + $: trigger = cloneDeep( $automationStore.selectedAutomation.automation.definition.trigger ) - let schemaProperties = Object.entries(trigger.schema.outputs.properties || {}) + + // get the outputs so we can define the fields + $: 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 + $: 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] @@ -41,7 +45,6 @@ showConfirmButton={true} disabled={isError} onConfirm={() => { - automationStore.actions.addTestDataToAutomation(testData) automationStore.actions.test( $automationStore.selectedAutomation?.automation, testData @@ -53,7 +56,7 @@ >
{:else if value.customType === "webhookUrl"} - + onChange(e, key)} + value={inputData[key]} + /> {:else if value.customType === "triggerSchema"} onChange(e, key)} value={inputData[key]} /> {:else if value.customType === "code"} @@ -249,6 +268,10 @@
{/each} + + + + {#if stepId === "WEBHOOK"} {/if} diff --git a/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte b/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte index 9eacc99fb1..34aaced503 100644 --- a/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte +++ b/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte @@ -5,16 +5,29 @@ import AutomationBindingPanel from "../../common/bindings/ServerBindingPanel.svelte" import { createEventDispatcher } from "svelte" import ModalBindableInput from "components/common/bindings/ModalBindableInput.svelte" + import LinkedRowSelector from "components/common/LinkedRowSelector.svelte" import { automationStore } from "builderStore" const dispatch = createEventDispatcher() export let value export let bindings - $: table = $tables.list.find(table => table._id === value?.tableId) - $: schemaFields = Object.entries(table?.schema ?? {}) + let table + let schemaFields + + $: { + table = $tables.list.find(table => table._id === value?.tableId) + schemaFields = Object.entries(table?.schema ?? {}) + // surface the schema so the user can see it in the json + schemaFields.map(([, schema]) => { + if (!schema.autocolumn && !value[schema.name]) { + value[schema.name] = "" + } + }) + } + const onChangeTable = e => { - value = { tableId: e.detail } + value["tableId"] = e.detail dispatch("change", value) } @@ -69,6 +82,8 @@ label={field} options={schema.constraints.inclusion} /> + {:else if schema.type === "link"} + {:else if schema.type === "string" || schema.type === "number"} {#if $automationStore.selectedAutomation.automation.testData} import { Icon } from "@budibase/bbui" import { automationStore } from "builderStore" - import { database } from "stores/backend" import WebhookDisplay from "./WebhookDisplay.svelte" import { ModalContent } from "@budibase/bbui" import { onMount, onDestroy } from "svelte" @@ -12,7 +11,6 @@ let schemaURL let propCount = 0 - $: instanceId = $database._id $: automation = $automationStore.selectedAutomation?.automation onMount(async () => { diff --git a/packages/builder/src/components/backend/DataTable/DataTable.svelte b/packages/builder/src/components/backend/DataTable/DataTable.svelte index 1cba1c31d9..f1d23e8f3d 100644 --- a/packages/builder/src/components/backend/DataTable/DataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/DataTable.svelte @@ -16,11 +16,29 @@ import { Pagination } from "@budibase/bbui" let hideAutocolumns = true - + let schema $: isUsersTable = $tables.selected?._id === TableNames.USERS - $: schema = $tables.selected?.schema $: type = $tables.selected?.type $: isInternal = type !== "external" + $: { + schema = $tables.selected?.schema + + // Manually add these as we don't want them to be 'real' auto-columns + schema._id = { + type: "internal", + editable: false, + displayName: "ID", + autocolumn: true, + } + if (isInternal) { + schema._rev = { + type: "internal", + editable: false, + displayName: "Revision", + autocolumn: true, + } + } + } $: id = $tables.selected?._id $: search = searchTable(id) $: columnOptions = Object.keys($search.schema || {}) diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index 011c9bee43..cd437bcad2 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -32,6 +32,7 @@ const FORMULA_TYPE = FIELDS.FORMULA.type const LINK_TYPE = FIELDS.LINK.type const dispatch = createEventDispatcher() + const PROHIBITED_COLUMN_NAMES = ["type", "_id", "_rev", "tableId"] const { hide } = getContext(Context.Modal) let fieldDefinitions = cloneDeep(FIELDS) @@ -66,7 +67,11 @@ (field.type === LINK_TYPE && !field.tableId) || Object.keys($tables.draft?.schema ?? {}).some( key => key !== originalName && key === field.name - ) + ) || + columnNameInvalid + $: columnNameInvalid = PROHIBITED_COLUMN_NAMES.some( + name => field.name === name + ) // used to select what different options can be displayed for column type $: canBeSearched = @@ -200,6 +205,9 @@ label="Name" bind:value={field.name} disabled={uneditable || (linkEditDisabled && field.type === LINK_TYPE)} + error={columnNameInvalid + ? `${PROHIBITED_COLUMN_NAMES.join(", ")} are not allowed as column names` + : ""} />