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.
This commit is contained in:
@@ -17,6 +17,9 @@ interface RegionalAgentCardProps {
|
|||||||
export const RegionalAgentCard: React.FC<RegionalAgentCardProps> = ({ agent, onDelete }) => {
|
export const RegionalAgentCard: React.FC<RegionalAgentCardProps> = ({ agent, onDelete }) => {
|
||||||
const { toast } = useToast();
|
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 () => {
|
const copyAgentId = async () => {
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(agent.agent_id);
|
await navigator.clipboard.writeText(agent.agent_id);
|
||||||
@@ -60,7 +63,14 @@ export const RegionalAgentCard: React.FC<RegionalAgentCardProps> = ({ agent, onD
|
|||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<MapPin className="h-5 w-5 text-blue-600" />
|
<MapPin className="h-5 w-5 text-blue-600" />
|
||||||
<div>
|
<div>
|
||||||
<CardTitle className="text-lg">{agent.region_name}</CardTitle>
|
<CardTitle className="text-lg flex items-center gap-2">
|
||||||
|
{agent.region_name}
|
||||||
|
{isDefaultAgent && (
|
||||||
|
<Badge variant="outline" className="text-xs bg-blue-50 text-blue-700 border-blue-200">
|
||||||
|
Default
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
</CardTitle>
|
||||||
<CardDescription className="flex items-center gap-1 text-sm">
|
<CardDescription className="flex items-center gap-1 text-sm">
|
||||||
{agent.agent_ip_address}
|
{agent.agent_ip_address}
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
@@ -78,10 +88,12 @@ export const RegionalAgentCard: React.FC<RegionalAgentCardProps> = ({ agent, onD
|
|||||||
<Copy className="mr-2 h-4 w-4" />
|
<Copy className="mr-2 h-4 w-4" />
|
||||||
Copy Agent ID
|
Copy Agent ID
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
{!isDefaultAgent && (
|
||||||
<DropdownMenuItem onClick={onDelete} className="text-red-600">
|
<DropdownMenuItem onClick={onDelete} className="text-red-600">
|
||||||
<Trash2 className="mr-2 h-4 w-4" />
|
<Trash2 className="mr-2 h-4 w-4" />
|
||||||
Remove Agent
|
Remove Agent
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
)}
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user