From 952c3a62812b322cd04068e1f08d868cdb04ee68 Mon Sep 17 00:00:00 2001 From: Raghuram Banda Date: Thu, 21 May 2026 11:54:24 -0400 Subject: [PATCH] fix: hide admin lifecycle buttons from non-admin users Non-admin users now see role-appropriate controls in AgentLifecycleDetail: - Draft stage: "Submit for Review" button (the only mutation they can do) - Review stage: read-only "Awaiting admin approval" chip - Other stages: read-only stage label chip - "Rebuild" button hidden for non-admins (requires admin/Kagenti access) Admins retain full access to all lifecycle transition buttons. The isAdmin prop is now passed through from ChatView and the admin KagentiAgentsPanel. Part of Epic #3208 --- .../KagentiPanels/AgentLifecycleDetail.tsx | 184 +++++++++++------- .../KagentiPanels/KagentiAgentsPanel.tsx | 1 + .../src/components/AugmentPage/ChatView.tsx | 1 + 3 files changed, 121 insertions(+), 65 deletions(-) diff --git a/workspaces/augment/plugins/augment/src/components/AdminPanels/KagentiPanels/AgentLifecycleDetail.tsx b/workspaces/augment/plugins/augment/src/components/AdminPanels/KagentiPanels/AgentLifecycleDetail.tsx index 7f41dcd2f0..909a605ada 100644 --- a/workspaces/augment/plugins/augment/src/components/AdminPanels/KagentiPanels/AgentLifecycleDetail.tsx +++ b/workspaces/augment/plugins/augment/src/components/AdminPanels/KagentiPanels/AgentLifecycleDetail.tsx @@ -38,6 +38,7 @@ import { getLifecycleStep, } from './lifecycleTransitions'; import PlayArrowIcon from '@mui/icons-material/PlayArrow'; +import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; import { useApi, configApiRef, fetchApiRef } from '@backstage/core-plugin-api'; import type { KagentiAgentSummary } from '@red-hat-developer-hub/backstage-plugin-augment-common'; import { normalizeLifecycleStage } from '@red-hat-developer-hub/backstage-plugin-augment-common'; @@ -71,6 +72,7 @@ export interface AgentLifecycleDetailProps { agent: KagentiAgentSummary; onBack: () => void; onChatWithAgent?: (agentId: string) => void; + isAdmin?: boolean; } /** @@ -81,6 +83,7 @@ export function AgentLifecycleDetail({ agent, onBack, onChatWithAgent, + isAdmin = false, }: AgentLifecycleDetailProps) { const theme = useTheme(); const isDark = theme.palette.mode === 'dark'; @@ -280,71 +283,122 @@ export function AgentLifecycleDetail({ flexShrink: 0, }} > - {lifecycleStage !== 'retired' && ( - - - - )} - {lifecycleStage === 'retired' && ( - - - - )} - {hasBuild && ( - - - + {isAdmin ? ( + <> + {lifecycleStage !== 'retired' && ( + + + + )} + {lifecycleStage === 'retired' && ( + + + + )} + {hasBuild && ( + + + + )} + + ) : ( + <> + {lifecycleStage === 'draft' && ( + + + + )} + {lifecycleStage !== 'draft' && ( + } + label={ + lifecycleStage === 'review' + ? 'Awaiting admin approval' + : lifecycleStage.charAt(0).toUpperCase() + + lifecycleStage.slice(1) + } + size="small" + variant="outlined" + color={lifecycleStage === 'review' ? 'info' : 'default'} + sx={{ fontWeight: 500, fontSize: '0.78rem' }} + /> + )} + )} {onChatWithAgent && (