Prevent creating, deleting or editing global fields for user in the backend UI of the builder

This commit is contained in:
Andrew Kingston 2021-05-19 18:46:15 +01:00
parent d47c48352c
commit 441fbd37fb
4 changed files with 19 additions and 8 deletions

View File

@ -57,10 +57,12 @@
>
<CreateColumnButton />
{#if schema && Object.keys(schema).length > 0}
{#if !isUsersTable}
<CreateRowButton
title={isUsersTable ? "Create user" : "Create row"}
modalContentComponent={isUsersTable ? CreateEditUser : CreateEditRow}
title={"Create row"}
modalContentComponent={CreateEditRow}
/>
{/if}
<CreateViewButton />
<ManageAccessButton resourceId={$tables.selected?._id} />
{#if isUsersTable}

View File

@ -103,7 +103,7 @@
</div>
<div class="popovers">
<slot />
{#if selectedRows.length > 0}
{#if !isUsersTable && selectedRows.length > 0}
<DeleteRowsButton {selectedRows} {deleteRows} />
{/if}
</div>
@ -116,7 +116,7 @@
{customRenderers}
{rowCount}
bind:selectedRows
allowSelectRows={allowEditing}
allowSelectRows={allowEditing && !isUsersTable}
allowEditRows={allowEditing}
allowEditColumns={allowEditing}
showAutoColumns={!hideAutocolumns}

View File

@ -69,7 +69,7 @@
return false
}
notifications.success("User saved successfully.")
notifications.success("User saved successfully")
rows.save(rowResponse)
}
</script>
@ -88,10 +88,12 @@
<RowFieldControl
meta={{ ...tableSchema.firstName, name: "First Name" }}
bind:value={row.firstName}
readonly={!creating}
/>
<RowFieldControl
meta={{ ...tableSchema.lastName, name: "Last Name" }}
bind:value={row.lastName}
readonly={!creating}
/>
<!-- Defer rendering this select until roles load, otherwise the initial
selection is always undefined -->

View File

@ -15,7 +15,14 @@ export const AppStatus = {
}
// fields on the user table that cannot be edited
export const UNEDITABLE_USER_FIELDS = ["email", "password", "roleId", "status"]
export const UNEDITABLE_USER_FIELDS = [
"email",
"password",
"roleId",
"status",
"firstName",
"lastName",
]
export const LAYOUT_NAMES = {
MASTER: {