From 3d1b78623e6e2582e7105321a089e51a47e5292d Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 18 Oct 2024 11:56:00 +0100 Subject: [PATCH] Remove frontend role prefixing hacks and fix 409s on role deletion --- packages/builder/src/stores/builder/roles.js | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/packages/builder/src/stores/builder/roles.js b/packages/builder/src/stores/builder/roles.js index 994f87a8d3..fd3581f1d4 100644 --- a/packages/builder/src/stores/builder/roles.js +++ b/packages/builder/src/stores/builder/roles.js @@ -47,28 +47,14 @@ export function createRolesStore() { roleId: role?._id, roleRev: role?._rev, }) - store.update(state => state.filter(existing => existing._id !== role._id)) + await actions.fetch() }, save: async role => { const savedRole = await API.saveRole(role) await actions.fetch() - - // When saving a role we get back an _id prefixed by role_, but the API does not want this - // in future requests - return { - ...savedRole, - _id: savedRole._id.replace("role_", ""), - } + return savedRole }, replace: (roleId, role) => { - // Remove role_ prefix - if (roleId?.startsWith("role_")) { - roleId = roleId.replace("role_", "") - } - if (role?._id.startsWith("role_")) { - role._id = role._id.replace("role_", "") - } - // Handles external updates of roles if (!roleId) { return