Merge pull request #12006 from Budibase/user-metadata-changes

Allow user table changes in existing apps again
This commit is contained in:
Andrew Kingston 2023-10-10 08:07:49 +01:00 committed by GitHub
commit 3ee5158345
4 changed files with 16 additions and 9 deletions

View File

@ -64,6 +64,7 @@ const INITIAL_FRONTEND_STATE = {
}, },
features: { features: {
componentValidation: false, componentValidation: false,
disableUserMetadata: false,
}, },
errors: [], errors: [],
hasAppPackage: false, hasAppPackage: false,

View File

@ -4,6 +4,7 @@
import { TableNames } from "constants" import { TableNames } from "constants"
import { Grid } from "@budibase/frontend-core" import { Grid } from "@budibase/frontend-core"
import { API } from "api" import { API } from "api"
import { store } from "builderStore"
import GridAddColumnModal from "components/backend/DataTable/modals/grid/GridCreateColumnModal.svelte" import GridAddColumnModal from "components/backend/DataTable/modals/grid/GridCreateColumnModal.svelte"
import GridCreateEditRowModal from "components/backend/DataTable/modals/grid/GridCreateEditRowModal.svelte" import GridCreateEditRowModal from "components/backend/DataTable/modals/grid/GridCreateEditRowModal.svelte"
import GridEditUserModal from "components/backend/DataTable/modals/grid/GridEditUserModal.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" import GridUsersTableButton from "components/backend/DataTable/modals/grid/GridUsersTableButton.svelte"
const userSchemaOverrides = { const userSchemaOverrides = {
firstName: { displayName: "First name" }, firstName: { displayName: "First name", disabled: true },
lastName: { displayName: "Last name" }, lastName: { displayName: "Last name", disabled: true },
email: { displayName: "Email" }, email: { displayName: "Email", disabled: true },
roleId: { displayName: "Role" }, roleId: { displayName: "Role", disabled: true },
status: { displayName: "Status" }, status: { displayName: "Status", disabled: true },
} }
$: id = $tables.selected?._id $: id = $tables.selected?._id
@ -60,14 +61,14 @@
datasource={gridDatasource} datasource={gridDatasource}
canAddRows={!isUsersTable} canAddRows={!isUsersTable}
canDeleteRows={!isUsersTable} canDeleteRows={!isUsersTable}
canEditRows={!isUsersTable} canEditRows={!isUsersTable || !$store.features.disableUserMetadata}
canEditColumns={!isUsersTable} canEditColumns={!isUsersTable || !$store.features.disableUserMetadata}
schemaOverrides={isUsersTable ? userSchemaOverrides : null} schemaOverrides={isUsersTable ? userSchemaOverrides : null}
showAvatars={false} showAvatars={false}
on:updatedatasource={handleGridTableUpdate} on:updatedatasource={handleGridTableUpdate}
> >
<svelte:fragment slot="filter"> <svelte:fragment slot="filter">
{#if isUsersTable} {#if isUsersTable && $store.features.disableUserMetadata}
<GridUsersTableButton /> <GridUsersTableButton />
{/if} {/if}
<GridFilterButton /> <GridFilterButton />

View File

@ -289,6 +289,7 @@ async function performAppCreate(ctx: UserCtx) {
}, },
features: { features: {
componentValidation: true, componentValidation: true,
disableUserMetadata: true,
}, },
} }
@ -310,10 +311,13 @@ async function performAppCreate(ctx: UserCtx) {
} }
}) })
// Keep existing validation setting // Keep existing feature flags
if (!existing.features?.componentValidation) { if (!existing.features?.componentValidation) {
newApplication.features!.componentValidation = false newApplication.features!.componentValidation = false
} }
if (!existing.features?.disableUserMetadata) {
newApplication.features!.disableUserMetadata = false
}
// Migrate navigation settings and screens if required // Migrate navigation settings and screens if required
if (existing) { if (existing) {

View File

@ -66,4 +66,5 @@ export interface AppIcon {
export interface AppFeatures { export interface AppFeatures {
componentValidation?: boolean componentValidation?: boolean
disableUserMetadata?: boolean
} }