Browse Source

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

pull/4023/head
Andrew Kingston 5 years ago
parent
commit
441fbd37fb
  1. 10
      packages/builder/src/components/backend/DataTable/DataTable.svelte
  2. 4
      packages/builder/src/components/backend/DataTable/Table.svelte
  3. 4
      packages/builder/src/components/backend/DataTable/modals/CreateEditUser.svelte
  4. 9
      packages/builder/src/constants/index.js

10
packages/builder/src/components/backend/DataTable/DataTable.svelte

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

4
packages/builder/src/components/backend/DataTable/Table.svelte

@ -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}

4
packages/builder/src/components/backend/DataTable/modals/CreateEditUser.svelte

@ -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 -->

9
packages/builder/src/constants/index.js

@ -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: {

Loading…
Cancel
Save