From 396c2b806807f71097c98771aaaacf284bb278d4 Mon Sep 17 00:00:00 2001 From: Dean Date: Wed, 23 Nov 2022 15:03:00 +0000 Subject: [PATCH 1/6] Added delete functionality to the edit table row modal --- packages/bbui/src/Modal/ModalContent.svelte | 4 +- .../components/backend/DataTable/Table.svelte | 51 ++++++++++++++++--- .../DataTable/buttons/DeleteRowsButton.svelte | 2 +- .../DataTable/modals/CreateEditRow.svelte | 38 +++++++++----- 4 files changed, 71 insertions(+), 24 deletions(-) diff --git a/packages/bbui/src/Modal/ModalContent.svelte b/packages/bbui/src/Modal/ModalContent.svelte index 7d3a8d7c40..eb73e255d5 100644 --- a/packages/bbui/src/Modal/ModalContent.svelte +++ b/packages/bbui/src/Modal/ModalContent.svelte @@ -28,9 +28,9 @@ let loading = false $: confirmDisabled = disabled || loading - async function secondary() { + async function secondary(e) { loading = true - if (!secondaryAction || (await secondaryAction()) !== false) { + if (!secondaryAction || (await secondaryAction(e)) !== false) { hide() } loading = false diff --git a/packages/builder/src/components/backend/DataTable/Table.svelte b/packages/builder/src/components/backend/DataTable/Table.svelte index adc35a333d..7c9b5bcf3d 100644 --- a/packages/builder/src/components/backend/DataTable/Table.svelte +++ b/packages/builder/src/components/backend/DataTable/Table.svelte @@ -4,6 +4,7 @@ import { Table, Modal, Heading, notifications, Layout } from "@budibase/bbui" import { API } from "api" import Spinner from "components/common/Spinner.svelte" + import ConfirmDialog from "components/common/ConfirmDialog.svelte" import DeleteRowsButton from "./buttons/DeleteRowsButton.svelte" import CreateEditRow from "./modals/CreateEditRow.svelte" import CreateEditUser from "./modals/CreateEditUser.svelte" @@ -34,8 +35,8 @@ let editRowModal let editColumnModal let customRenderers = [] + let confirmDelete - $: isInternal = type !== "external" $: isUsersTable = tableId === TableNames.USERS $: data && resetSelectedRows() $: editRowComponent = isUsersTable ? CreateEditUser : CreateEditRow @@ -89,15 +90,17 @@ ) } - const deleteRows = async () => { + const deleteRows = async targetRows => { try { await API.deleteRows({ tableId, - rows: selectedRows, + rows: targetRows, }) - data = data.filter(row => !selectedRows.includes(row)) - notifications.success(`Successfully deleted ${selectedRows.length} rows`) - selectedRows = [] + + const deletedRowIds = targetRows.map(row => row._id) + data = data.filter(row => deletedRowIds.indexOf(row._id)) + + notifications.success(`Successfully deleted ${targetRows.length} rows`) } catch (error) { notifications.error("Error deleting rows") } @@ -133,7 +136,14 @@
{#if !isUsersTable && selectedRows.length > 0} - + { + await deleteRows(rows) + resetSelectedRows() + }} + /> {/if}
@@ -164,8 +174,33 @@ - + { + confirmDelete.show() + }} + row={editableRow} + /> + + { + if (editableRow) { + await deleteRows([editableRow]) + } + editableRow = undefined + }} + onCancel={async () => { + editRow(editableRow) + }} + title="Confirm Deletion" +> + Are you sure you want to delete this row? + + - - {#each tableSchema as [key, meta]} - {#if !meta.autocolumn && meta.type !== FORMULA_TYPE} -
- -
- {/if} - {/each} -
+ + { + dispatch("deleteRows", row) + }} + > + {#each tableSchema as [key, meta]} + {#if !meta.autocolumn && meta.type !== FORMULA_TYPE} +
+ +
+ {/if} + {/each} +
+
From 4f474b8b27fabd1d8cf3638b360ae5ab30b0a3b5 Mon Sep 17 00:00:00 2001 From: Jonny Date: Thu, 1 Dec 2022 14:09:40 +0000 Subject: [PATCH 2/6] Add env var for tls-reject-unauthorised to helm chart --- charts/budibase/templates/app-service-deployment.yaml | 4 ++++ charts/budibase/templates/minio-service-deployment.yaml | 5 +++++ charts/budibase/templates/proxy-service-deployment.yaml | 5 +++++ charts/budibase/templates/redis-service-deployment.yaml | 5 +++++ charts/budibase/templates/worker-service-deployment.yaml | 4 ++++ charts/budibase/values.yaml | 1 + 6 files changed, 24 insertions(+) diff --git a/charts/budibase/templates/app-service-deployment.yaml b/charts/budibase/templates/app-service-deployment.yaml index 72d9fc93a9..2f8242a030 100644 --- a/charts/budibase/templates/app-service-deployment.yaml +++ b/charts/budibase/templates/app-service-deployment.yaml @@ -158,6 +158,10 @@ spec: {{ end }} - name: CDN_URL value: {{ .Values.globals.cdnUrl }} + {{ if .Values.services.tlsRejectUnauthorized }} + - name: NODE_TLS_REJECT_UNAUTHORIZED + value: {{ .Values.services.tlsRejectUnauthorized }} + {{ end }} image: budibase/apps:{{ .Values.globals.appVersion }} imagePullPolicy: Always diff --git a/charts/budibase/templates/minio-service-deployment.yaml b/charts/budibase/templates/minio-service-deployment.yaml index 144dbe539a..157378f23d 100644 --- a/charts/budibase/templates/minio-service-deployment.yaml +++ b/charts/budibase/templates/minio-service-deployment.yaml @@ -42,6 +42,11 @@ spec: secretKeyRef: name: {{ template "budibase.fullname" . }} key: objectStoreSecret + {{ if .Values.services.tlsRejectUnauthorized }} + - name: NODE_TLS_REJECT_UNAUTHORIZED + value: {{ .Values.services.tlsRejectUnauthorized }} + {{ end }} + image: minio/minio imagePullPolicy: "" livenessProbe: diff --git a/charts/budibase/templates/proxy-service-deployment.yaml b/charts/budibase/templates/proxy-service-deployment.yaml index 5588022032..4216d387c2 100644 --- a/charts/budibase/templates/proxy-service-deployment.yaml +++ b/charts/budibase/templates/proxy-service-deployment.yaml @@ -50,4 +50,9 @@ spec: restartPolicy: Always serviceAccountName: "" volumes: + env: + {{ if .Values.services.tlsRejectUnauthorized }} + - name: NODE_TLS_REJECT_UNAUTHORIZED + value: {{ .Values.services.tlsRejectUnauthorized }} + {{ end }} status: {} diff --git a/charts/budibase/templates/redis-service-deployment.yaml b/charts/budibase/templates/redis-service-deployment.yaml index d94e4d70f8..7961c96abf 100644 --- a/charts/budibase/templates/redis-service-deployment.yaml +++ b/charts/budibase/templates/redis-service-deployment.yaml @@ -60,5 +60,10 @@ spec: - name: redis-data persistentVolumeClaim: claimName: redis-data + env: + {{ if .Values.services.tlsRejectUnauthorized }} + - name: NODE_TLS_REJECT_UNAUTHORIZED + value: {{ .Values.services.tlsRejectUnauthorized }} + {{ end }} status: {} {{- end }} diff --git a/charts/budibase/templates/worker-service-deployment.yaml b/charts/budibase/templates/worker-service-deployment.yaml index df692a0723..5e8578212d 100644 --- a/charts/budibase/templates/worker-service-deployment.yaml +++ b/charts/budibase/templates/worker-service-deployment.yaml @@ -149,6 +149,10 @@ spec: {{ end }} - name: CDN_URL value: {{ .Values.globals.cdnUrl }} + {{ if .Values.services.tlsRejectUnauthorized }} + - name: NODE_TLS_REJECT_UNAUTHORIZED + value: {{ .Values.services.tlsRejectUnauthorized }} + {{ end }} image: budibase/worker:{{ .Values.globals.appVersion }} imagePullPolicy: Always diff --git a/charts/budibase/values.yaml b/charts/budibase/values.yaml index a2a761aa86..2cf2767f12 100644 --- a/charts/budibase/values.yaml +++ b/charts/budibase/values.yaml @@ -110,6 +110,7 @@ globals: services: budibaseVersion: latest dns: cluster.local + # tlsRejectUnauthorized: 0 proxy: port: 10000 From 680061382a18e46a064bccbab0b67bae7423c7fd Mon Sep 17 00:00:00 2001 From: Jonny Date: Thu, 1 Dec 2022 14:50:27 +0000 Subject: [PATCH 3/6] not needed in redis/minio --- charts/budibase/templates/minio-service-deployment.yaml | 4 ---- charts/budibase/templates/redis-service-deployment.yaml | 6 +----- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/charts/budibase/templates/minio-service-deployment.yaml b/charts/budibase/templates/minio-service-deployment.yaml index 157378f23d..d0a367653d 100644 --- a/charts/budibase/templates/minio-service-deployment.yaml +++ b/charts/budibase/templates/minio-service-deployment.yaml @@ -42,10 +42,6 @@ spec: secretKeyRef: name: {{ template "budibase.fullname" . }} key: objectStoreSecret - {{ if .Values.services.tlsRejectUnauthorized }} - - name: NODE_TLS_REJECT_UNAUTHORIZED - value: {{ .Values.services.tlsRejectUnauthorized }} - {{ end }} image: minio/minio imagePullPolicy: "" diff --git a/charts/budibase/templates/redis-service-deployment.yaml b/charts/budibase/templates/redis-service-deployment.yaml index 7961c96abf..5916c6d3f9 100644 --- a/charts/budibase/templates/redis-service-deployment.yaml +++ b/charts/budibase/templates/redis-service-deployment.yaml @@ -60,10 +60,6 @@ spec: - name: redis-data persistentVolumeClaim: claimName: redis-data - env: - {{ if .Values.services.tlsRejectUnauthorized }} - - name: NODE_TLS_REJECT_UNAUTHORIZED - value: {{ .Values.services.tlsRejectUnauthorized }} - {{ end }} + status: {} {{- end }} From 66a00a677a041ad3638c96932514fba5a8dccb50 Mon Sep 17 00:00:00 2001 From: Gerard Burns Date: Fri, 2 Dec 2022 09:24:05 +0000 Subject: [PATCH 4/6] Skeleton Fixes (#8845) --- .../client/src/components/Component.svelte | 1 + .../components/app/blocks/CardsBlock.svelte | 232 ++++++++------- .../components/app/blocks/TableBlock.svelte | 272 +++++++++--------- .../src/components/app/forms/Form.svelte | 38 ++- 4 files changed, 265 insertions(+), 278 deletions(-) diff --git a/packages/client/src/components/Component.svelte b/packages/client/src/components/Component.svelte index e5fe100372..aa03b3ce8a 100644 --- a/packages/client/src/components/Component.svelte +++ b/packages/client/src/components/Component.svelte @@ -479,6 +479,7 @@ definition.name !== "Screenslot" && children.length === 0 && !instance._blockElementHasChildren && + !definition.block && definition.skeleton !== false diff --git a/packages/client/src/components/app/blocks/CardsBlock.svelte b/packages/client/src/components/app/blocks/CardsBlock.svelte index 9c110d7097..5098a3acf4 100644 --- a/packages/client/src/components/app/blocks/CardsBlock.svelte +++ b/packages/client/src/components/app/blocks/CardsBlock.svelte @@ -36,7 +36,6 @@ let dataProviderId let repeaterId let schema - let schemaLoaded = false $: fetchSchema(dataSource) $: enrichedSearchColumns = enrichSearchColumns(searchColumns, schema) @@ -75,138 +74,135 @@ enrichRelationships: true, }) } - schemaLoaded = true } -{#if schemaLoaded} - - - {#if title || enrichedSearchColumns?.length || showTitleButton} + + + {#if title || enrichedSearchColumns?.length || showTitleButton} + + + {#if enrichedSearchColumns?.length} + {#each enrichedSearchColumns as column, idx} + + {/each} + {/if} + {#if showTitleButton} + + {/if} + + + {/if} + + + - - - {#if enrichedSearchColumns?.length} - {#each enrichedSearchColumns as column, idx} - - {/each} - {/if} - {#if showTitleButton} - - {/if} - - - {/if} - - - - + /> - -{/if} + + diff --git a/packages/client/src/components/app/blocks/TableBlock.svelte b/packages/client/src/components/app/blocks/TableBlock.svelte index 9df81635db..40f0eebebb 100644 --- a/packages/client/src/components/app/blocks/TableBlock.svelte +++ b/packages/client/src/components/app/blocks/TableBlock.svelte @@ -36,7 +36,6 @@ let newRowSidePanelId let schema let primaryDisplay - let schemaLoaded = false $: fetchSchema(dataSource) $: enrichedSearchColumns = enrichSearchColumns(searchColumns, schema) @@ -89,7 +88,6 @@ enrichRelationships: true, }) } - schemaLoaded = true } const getNormalFields = schema => { @@ -113,162 +111,160 @@ } -{#if schemaLoaded} - - - {#if title || enrichedSearchColumns?.length || showTitleButton} + + + {#if title || enrichedSearchColumns?.length || showTitleButton} + + - - - {#if enrichedSearchColumns?.length} - {#each enrichedSearchColumns as column, idx} - - {/each} - {/if} - {#if showTitleButton} + {#if enrichedSearchColumns?.length} + {#each enrichedSearchColumns as column, idx} - {/if} - + {/each} + {/if} + {#if showTitleButton} + + {/if} - {/if} + + {/if} + + + {#if clickBehaviour === "details"} + - {#if clickBehaviour === "details"} + {/if} + {#if showTitleButton && titleButtonClickBehaviour === "new"} + - - - {/if} - {#if showTitleButton && titleButtonClickBehaviour === "new"} - - - - {/if} - - -{/if} + name="New row form block" + type="formblock" + props={{ + dataSource, + showSaveButton: true, + showDeleteButton: false, + actionType: "Create", + fields: normalFields, + title: "Create Row", + labelPosition: "left", + }} + /> + + {/if} + + diff --git a/packages/client/src/components/app/forms/Form.svelte b/packages/client/src/components/app/forms/Form.svelte index 8950661bd8..e2a6dcf7c5 100644 --- a/packages/client/src/components/app/forms/Form.svelte +++ b/packages/client/src/components/app/forms/Form.svelte @@ -20,7 +20,6 @@ const context = getContext("context") const { API, fetchDatasourceSchema } = getContext("sdk") - let loaded = false let schema let table @@ -49,9 +48,6 @@ // Fetches the form schema from this form's dataSource const fetchSchema = async dataSource => { schema = (await fetchDatasourceSchema(dataSource)) || {} - if (!loaded) { - loaded = true - } } const fetchTable = async dataSource => { @@ -70,21 +66,19 @@ ) -{#if loaded} - {#key resetKey} - - - - {/key} -{/if} +{#key resetKey} + + + +{/key} From 63239a819dc10c8a6dc60d951f5f2c1cd61fc07c Mon Sep 17 00:00:00 2001 From: Gerard Burns Date: Fri, 2 Dec 2022 09:24:20 +0000 Subject: [PATCH 5/6] Public App Missing Nav Menu (#8870) * Public App Missing Nav Menu * PR Feedback --- packages/client/src/stores/derived/currentRole.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/client/src/stores/derived/currentRole.js b/packages/client/src/stores/derived/currentRole.js index 28287e1ea4..a56b26050c 100644 --- a/packages/client/src/stores/derived/currentRole.js +++ b/packages/client/src/stores/derived/currentRole.js @@ -1,4 +1,5 @@ import { derived } from "svelte/store" +import { Constants } from "@budibase/frontend-core" import { devToolsStore } from "../devTools.js" import { authStore } from "../auth.js" @@ -6,6 +7,10 @@ import { authStore } from "../auth.js" export const currentRole = derived( [devToolsStore, authStore], ([$devToolsStore, $authStore]) => { - return ($devToolsStore.enabled && $devToolsStore.role) || $authStore?.roleId + return ( + ($devToolsStore.enabled && $devToolsStore.role) || + $authStore?.roleId || + Constants.Roles.PUBLIC + ) } ) From 44380d2bc0611b4a9946fd905a51ec31273e3c17 Mon Sep 17 00:00:00 2001 From: Jonny Date: Fri, 2 Dec 2022 10:00:34 +0000 Subject: [PATCH 6/6] not needed in proxy --- charts/budibase/templates/proxy-service-deployment.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/charts/budibase/templates/proxy-service-deployment.yaml b/charts/budibase/templates/proxy-service-deployment.yaml index 4216d387c2..5588022032 100644 --- a/charts/budibase/templates/proxy-service-deployment.yaml +++ b/charts/budibase/templates/proxy-service-deployment.yaml @@ -50,9 +50,4 @@ spec: restartPolicy: Always serviceAccountName: "" volumes: - env: - {{ if .Values.services.tlsRejectUnauthorized }} - - name: NODE_TLS_REJECT_UNAUTHORIZED - value: {{ .Values.services.tlsRejectUnauthorized }} - {{ end }} status: {}