From 896c262c943ae0874fba548f398ffe6aa930f47b Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 30 May 2024 10:52:17 +0200 Subject: [PATCH 01/35] Add readonly option in view columns --- .../backend/DataTable/ViewV2DataTable.svelte | 1 + .../grid/controls/ColumnsSettingButton.svelte | 41 ++++++++++++++----- .../src/components/grid/layout/Grid.svelte | 3 +- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/ViewV2DataTable.svelte b/packages/builder/src/components/backend/DataTable/ViewV2DataTable.svelte index 3b628c7b53..9b0e45a1b2 100644 --- a/packages/builder/src/components/backend/DataTable/ViewV2DataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/ViewV2DataTable.svelte @@ -28,6 +28,7 @@ showAvatars={false} on:updatedatasource={handleGridViewUpdate} isCloud={$admin.cloud} + allowReadonlyColumns > diff --git a/packages/frontend-core/src/components/grid/controls/ColumnsSettingButton.svelte b/packages/frontend-core/src/components/grid/controls/ColumnsSettingButton.svelte index 0a85e41966..70655bd5a3 100644 --- a/packages/frontend-core/src/components/grid/controls/ColumnsSettingButton.svelte +++ b/packages/frontend-core/src/components/grid/controls/ColumnsSettingButton.svelte @@ -1,9 +1,11 @@
@@ -15,7 +14,7 @@ dispatch("click", option.value)} - {disabled} + disabled={option.disabled} size="S" icon={option.icon} quiet From 8e72f1f0facd831a62c385fb88754d0a36972710 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 30 May 2024 11:07:30 +0200 Subject: [PATCH 03/35] Lock readonly --- packages/builder/src/stores/portal/licensing.js | 6 ++++++ .../grid/controls/ColumnsSettingButton.svelte | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/stores/portal/licensing.js b/packages/builder/src/stores/portal/licensing.js index 179d0918bb..1378a734e8 100644 --- a/packages/builder/src/stores/portal/licensing.js +++ b/packages/builder/src/stores/portal/licensing.js @@ -138,6 +138,11 @@ export const createLicensingStore = () => { const isViewPermissionsEnabled = license.features.includes( Constants.Features.VIEW_PERMISSIONS ) + + const isViewReadonlyColumnsEnabled = license.features.includes( + Constants.Features.VIEW_READONLY_COLUMNS + ) + store.update(state => { return { ...state, @@ -157,6 +162,7 @@ export const createLicensingStore = () => { triggerAutomationRunEnabled, isViewPermissionsEnabled, perAppBuildersEnabled, + isViewReadonlyColumnsEnabled, } }) }, diff --git a/packages/frontend-core/src/components/grid/controls/ColumnsSettingButton.svelte b/packages/frontend-core/src/components/grid/controls/ColumnsSettingButton.svelte index 7e330b77e4..8faf603b80 100644 --- a/packages/frontend-core/src/components/grid/controls/ColumnsSettingButton.svelte +++ b/packages/frontend-core/src/components/grid/controls/ColumnsSettingButton.svelte @@ -1,6 +1,7 @@ diff --git a/packages/frontend-core/src/components/grid/stores/columns.js b/packages/frontend-core/src/components/grid/stores/columns.js index a3281be936..b76dcbfe0e 100644 --- a/packages/frontend-core/src/components/grid/stores/columns.js +++ b/packages/frontend-core/src/components/grid/stores/columns.js @@ -146,6 +146,7 @@ export const initialise = context => { schema: fieldSchema, width: fieldSchema.width || oldColumn?.width || DefaultColumnWidth, visible: fieldSchema.visible ?? true, + readonly: fieldSchema.readonly, order: fieldSchema.order ?? oldColumn?.order, primaryDisplay: field === primaryDisplay, } From fbfe85c903c5d0b95419e6f5071d594204e566a7 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 30 May 2024 11:43:28 +0200 Subject: [PATCH 05/35] Mark readonly as restricted --- .../components/grid/controls/ColumnsSettingButton.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/frontend-core/src/components/grid/controls/ColumnsSettingButton.svelte b/packages/frontend-core/src/components/grid/controls/ColumnsSettingButton.svelte index c07adf9fcb..fd0afd48f2 100644 --- a/packages/frontend-core/src/components/grid/controls/ColumnsSettingButton.svelte +++ b/packages/frontend-core/src/components/grid/controls/ColumnsSettingButton.svelte @@ -29,8 +29,10 @@ } const getText = columns => { - const hidden = columns.filter(col => !col.visible).length - return hidden ? `Columns (${hidden} restricted)` : "Columns" + const restricted = columns.filter( + col => !col.visible || col.readonly + ).length + return restricted ? `Columns (${restricted} restricted)` : "Columns" } $: isViewReadonlyColumnsEnabled = $licensing.isViewReadonlyColumnsEnabled From 6ce0b3c368356459ad4d683e2f28f7acec549d66 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 30 May 2024 11:46:57 +0200 Subject: [PATCH 06/35] Copy change --- packages/server/src/api/routes/tests/viewV2.spec.ts | 4 ++-- packages/server/src/sdk/app/views/index.ts | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/server/src/api/routes/tests/viewV2.spec.ts b/packages/server/src/api/routes/tests/viewV2.spec.ts index 8069fadf10..962d6e82a3 100644 --- a/packages/server/src/api/routes/tests/viewV2.spec.ts +++ b/packages/server/src/api/routes/tests/viewV2.spec.ts @@ -424,7 +424,7 @@ describe.each([ await config.api.viewV2.create(newView, { status: 400, body: { - message: "Readonly fields are not enabled for your tenant", + message: "Readonly fields are not enabled", status: 400, }, }) @@ -690,7 +690,7 @@ describe.each([ await config.api.viewV2.update(view, { status: 400, body: { - message: "Readonly fields are not enabled for your tenant", + message: "Readonly fields are not enabled", }, }) }) diff --git a/packages/server/src/sdk/app/views/index.ts b/packages/server/src/sdk/app/views/index.ts index ea05ecf512..18ab94be21 100644 --- a/packages/server/src/sdk/app/views/index.ts +++ b/packages/server/src/sdk/app/views/index.ts @@ -55,10 +55,7 @@ async function guardViewSchema( if (viewSchema[field].readonly) { if (!(await features.isViewReadonlyColumnsEnabled())) { - throw new HTTPError( - `Readonly fields are not enabled for your tenant`, - 400 - ) + throw new HTTPError(`Readonly fields are not enabled`, 400) } if (isRequired(tableSchemaField.constraints)) { From 4dbfa28febd21889e271af769a1619cd5d2c44db Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 30 May 2024 17:12:46 +0200 Subject: [PATCH 07/35] Move licence check out of frontend-core --- .../backend/DataTable/ViewV2DataTable.svelte | 5 +++-- .../grid/controls/ColumnsSettingButton.svelte | 12 +++++------- .../src/components/grid/layout/Grid.svelte | 8 ++++++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/ViewV2DataTable.svelte b/packages/builder/src/components/backend/DataTable/ViewV2DataTable.svelte index 9b0e45a1b2..45cdeeee07 100644 --- a/packages/builder/src/components/backend/DataTable/ViewV2DataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/ViewV2DataTable.svelte @@ -1,6 +1,6 @@