From 14bcab60b3b9a16c4202e2a7d7334ec2f4dd4c77 Mon Sep 17 00:00:00 2001 From: Peter Nancarrow <37298202+pnancarrow@users.noreply.github.com> Date: Tue, 3 Mar 2026 19:45:02 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AC=20feat:=20Allow=20Agent=20Editors?= =?UTF-8?q?=20to=20Duplicate=20Agents=20(#12041)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: allow editors to duplicate agents * fix: Update permissions for duplicating agents and enhance visibility in AgentFooter - Changed required permission for duplicating agents from VIEW to EDIT in the API route. - Updated AgentFooter component to display the duplicate button for admins and users with EDIT permission, improving access control. - Added tests to ensure the duplicate button visibility logic works correctly based on user roles and permissions. * test: Update AgentFooter tests to reflect permission changes - Adjusted tests in AgentFooter.spec.tsx to verify UI behavior based on user permissions. - Updated expectations for the visibility of the grant access dialog and duplicate button, ensuring they align with the new permission logic. --------- Co-authored-by: Danny Avila --- api/server/routes/agents/v1.js | 2 +- .../SidePanel/Agents/AgentFooter.tsx | 4 +- .../SidePanel/Agents/DeleteButton.tsx | 1 + .../SidePanel/Agents/DuplicateAgent.tsx | 1 + .../Agents/__tests__/AgentFooter.spec.tsx | 89 ++++++++++++++++++- 5 files changed, 92 insertions(+), 5 deletions(-) diff --git a/api/server/routes/agents/v1.js b/api/server/routes/agents/v1.js index 682a9c795f..ed989bcf44 100644 --- a/api/server/routes/agents/v1.js +++ b/api/server/routes/agents/v1.js @@ -117,7 +117,7 @@ router.post( '/:id/duplicate', checkAgentCreate, canAccessAgentResource({ - requiredPermission: PermissionBits.VIEW, + requiredPermission: PermissionBits.EDIT, resourceIdParam: 'id', }), v1.duplicateAgent, diff --git a/client/src/components/SidePanel/Agents/AgentFooter.tsx b/client/src/components/SidePanel/Agents/AgentFooter.tsx index b2fa996596..ff98f7c48b 100644 --- a/client/src/components/SidePanel/Agents/AgentFooter.tsx +++ b/client/src/components/SidePanel/Agents/AgentFooter.tsx @@ -57,6 +57,7 @@ export default function AgentFooter({ useResourcePermissions(ResourceType.REMOTE_AGENT, agent?._id || ''); const canShareThisAgent = hasPermission(PermissionBits.SHARE); + const canEditThisAgent = hasPermission(PermissionBits.EDIT); const canDeleteThisAgent = hasPermission(PermissionBits.DELETE); const canShareRemoteAgent = hasRemoteAgentPermission(PermissionBits.SHARE); const isSaving = createMutation.isLoading || updateMutation.isLoading || isAvatarUploading; @@ -118,7 +119,8 @@ export default function AgentFooter({ )} - {agent && agent.author === user?.id && } + {(agent?.author === user?.id || user?.role === SystemRoles.ADMIN || canEditThisAgent) && + !permissionsLoading && } {/* Submit Button */}