From a4e3cd72cc45bce271893ee676c73351a02da775 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 9 Oct 2023 15:01:16 +0100 Subject: [PATCH 1/3] Add new app feature flag to allow disable user metadata columns in new apps, but allow them in old apps --- .../src/builderStore/store/frontend.js | 1 + .../backend/DataTable/TableDataTable.svelte | 24 ++++++++++--------- .../server/src/api/controllers/application.ts | 1 + packages/types/src/documents/app/app.ts | 1 + 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 6c029ddff3..a567caf87f 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -64,6 +64,7 @@ const INITIAL_FRONTEND_STATE = { }, features: { componentValidation: false, + disableUserMetadata: false, }, errors: [], hasAppPackage: false, diff --git a/packages/builder/src/components/backend/DataTable/TableDataTable.svelte b/packages/builder/src/components/backend/DataTable/TableDataTable.svelte index 2b7cde9201..c3b1fea51d 100644 --- a/packages/builder/src/components/backend/DataTable/TableDataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/TableDataTable.svelte @@ -4,6 +4,7 @@ import { TableNames } from "constants" import { Grid } from "@budibase/frontend-core" import { API } from "api" + import { store } from "builderStore" import GridAddColumnModal from "components/backend/DataTable/modals/grid/GridCreateColumnModal.svelte" import GridCreateEditRowModal from "components/backend/DataTable/modals/grid/GridCreateEditRowModal.svelte" import GridEditUserModal from "components/backend/DataTable/modals/grid/GridEditUserModal.svelte" @@ -17,11 +18,11 @@ import GridUsersTableButton from "components/backend/DataTable/modals/grid/GridUsersTableButton.svelte" const userSchemaOverrides = { - firstName: { displayName: "First name" }, - lastName: { displayName: "Last name" }, - email: { displayName: "Email" }, - roleId: { displayName: "Role" }, - status: { displayName: "Status" }, + firstName: { displayName: "First name", disabled: true }, + lastName: { displayName: "Last name", disabled: true }, + email: { displayName: "Email", disabled: true }, + roleId: { displayName: "Role", disabled: true }, + status: { displayName: "Status", disabled: true }, } $: id = $tables.selected?._id @@ -35,6 +36,7 @@ return datasource._id === $tables.selected?.sourceId }) $: relationshipsEnabled = relationshipSupport(tableDatasource) + $: editable = !(isUsersTable && $store.features.disableUserMetadata) const relationshipSupport = datasource => { const integration = $integrations[datasource?.source] @@ -58,22 +60,22 @@ - {#if isUsersTable} + {#if !editable} {/if} - {#if !isUsersTable} + {#if editable} {/if} diff --git a/packages/server/src/api/controllers/application.ts b/packages/server/src/api/controllers/application.ts index 11f6e6c249..3797d1e966 100644 --- a/packages/server/src/api/controllers/application.ts +++ b/packages/server/src/api/controllers/application.ts @@ -289,6 +289,7 @@ async function performAppCreate(ctx: UserCtx) { }, features: { componentValidation: true, + disableUserMetadata: true, }, } diff --git a/packages/types/src/documents/app/app.ts b/packages/types/src/documents/app/app.ts index f42422b557..5bbdd86515 100644 --- a/packages/types/src/documents/app/app.ts +++ b/packages/types/src/documents/app/app.ts @@ -66,4 +66,5 @@ export interface AppIcon { export interface AppFeatures { componentValidation?: boolean + disableUserMetadata?: boolean } From 73e208292f048f6d88814907cc7b14ad429db8b7 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 9 Oct 2023 15:05:57 +0100 Subject: [PATCH 2/3] Simplify logic to be more readable --- .../backend/DataTable/TableDataTable.svelte | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/TableDataTable.svelte b/packages/builder/src/components/backend/DataTable/TableDataTable.svelte index c3b1fea51d..5fee849afb 100644 --- a/packages/builder/src/components/backend/DataTable/TableDataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/TableDataTable.svelte @@ -36,7 +36,6 @@ return datasource._id === $tables.selected?.sourceId }) $: relationshipsEnabled = relationshipSupport(tableDatasource) - $: editable = !(isUsersTable && $store.features.disableUserMetadata) const relationshipSupport = datasource => { const integration = $integrations[datasource?.source] @@ -60,22 +59,22 @@ - {#if !editable} + {#if isUsersTable && $store.features.disableUserMetadata} {/if} - {#if editable} + {#if !isUsersTable} {/if} From b17ec630c1e85519a6fce46d575d66f9237ce685 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 9 Oct 2023 15:09:11 +0100 Subject: [PATCH 3/3] Ensure user table editing is still allowed for old apps that are imported --- packages/server/src/api/controllers/application.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/application.ts b/packages/server/src/api/controllers/application.ts index 3797d1e966..4afd7b23f9 100644 --- a/packages/server/src/api/controllers/application.ts +++ b/packages/server/src/api/controllers/application.ts @@ -311,10 +311,13 @@ async function performAppCreate(ctx: UserCtx) { } }) - // Keep existing validation setting + // Keep existing feature flags if (!existing.features?.componentValidation) { newApplication.features!.componentValidation = false } + if (!existing.features?.disableUserMetadata) { + newApplication.features!.disableUserMetadata = false + } // Migrate navigation settings and screens if required if (existing) {