From 72e392608d2471030515eab6c202951a2ccf4bb5 Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Sun, 25 Jul 2021 11:46:40 +0100 Subject: [PATCH 1/2] Adding checks around the edit roles modal. --- .../backend/DataTable/modals/EditRoles.svelte | 12 +- packages/worker/yarn.lock | 612 +----------------- 2 files changed, 26 insertions(+), 598 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/modals/EditRoles.svelte b/packages/builder/src/components/backend/DataTable/modals/EditRoles.svelte index 8b7417c41f..580b3af532 100644 --- a/packages/builder/src/components/backend/DataTable/modals/EditRoles.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/EditRoles.svelte @@ -6,8 +6,10 @@ import ErrorsBox from "components/common/ErrorsBox.svelte" import { roles } from "stores/backend" + const BASE_ROLE = { _id: "", inherits: "BASIC", permissionId: "Read/Write" } + let basePermissions = [] - let selectedRole = {} + let selectedRole = BASE_ROLE let errors = [] let builtInRoles = ["Admin", "Power", "Basic", "Public"] // Don't allow editing of public role @@ -15,6 +17,7 @@ $: selectedRoleId = selectedRole._id $: otherRoles = editableRoles.filter(role => role._id !== selectedRoleId) $: isCreating = selectedRoleId == null || selectedRoleId === "" + $: valid = selectedRole.name && selectedRole.inherits && selectedRole.permissionId && !builtInRoles.includes(selectedRole.name) const fetchBasePermissions = async () => { const permissionsResponse = await api.get("/api/permission/builtin") @@ -32,7 +35,7 @@ permissionId: role.permissionId ?? "", } } else { - selectedRole = { _id: "", inherits: "", permissionId: "" } + selectedRole = BASE_ROLE } errors = [] } @@ -88,6 +91,7 @@ title="Edit Roles" confirmText={isCreating ? "Create" : "Save"} onConfirm={saveRole} + disabled={!valid} > {#if errors.length} @@ -115,7 +119,7 @@ options={otherRoles} getOptionValue={role => role._id} getOptionLabel={role => role.name} - placeholder="None" + disabled={builtInRoles.includes(selectedRole.name)} />