From d385f24c28d6de05021c12f98e3e955cdb848deb Mon Sep 17 00:00:00 2001 From: Tola Leng Date: Sat, 21 Jun 2025 19:52:46 +0700 Subject: [PATCH] Restrict removal of default agent Prevent removal of the default regional agent (agent_id: 1, region_name: Default) in the Regional Monitoring dashboard. This ensures the core service remains active. --- .../regional-monitoring/RegionalAgentCard.tsx | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/application/src/components/regional-monitoring/RegionalAgentCard.tsx b/application/src/components/regional-monitoring/RegionalAgentCard.tsx index 7e8cb30..d97d25b 100644 --- a/application/src/components/regional-monitoring/RegionalAgentCard.tsx +++ b/application/src/components/regional-monitoring/RegionalAgentCard.tsx @@ -17,6 +17,9 @@ interface RegionalAgentCardProps { export const RegionalAgentCard: React.FC = ({ agent, onDelete }) => { const { toast } = useToast(); + // Check if this is the default agent that cannot be removed + const isDefaultAgent = agent.agent_id === "1" || agent.region_name === "Default"; + const copyAgentId = async () => { try { await navigator.clipboard.writeText(agent.agent_id); @@ -60,7 +63,14 @@ export const RegionalAgentCard: React.FC = ({ agent, onD
- {agent.region_name} + + {agent.region_name} + {isDefaultAgent && ( + + Default + + )} + {agent.agent_ip_address} @@ -78,10 +88,12 @@ export const RegionalAgentCard: React.FC = ({ agent, onD Copy Agent ID - - - Remove Agent - + {!isDefaultAgent && ( + + + Remove Agent + + )}