mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-13 21:14:24 +01:00
WIP: pre-granular-permissions commit
feat: Add category and support contact fields to Agent schema and UI components
Revert "feat: Add category and support contact fields to Agent schema and UI components"
This reverts commit c43a52b4c9.
Fix: Update import for renderHook in useAgentCategories.spec.tsx
fix: Update icon rendering in AgentCategoryDisplay tests to use empty spans
refactor: Improve category synchronization logic and clean up AgentConfig component
refactor: Remove unused UI flow translations from translation.json
feat: agent marketplace features
🔐 feat: Granular Role-based Permissions + Entra ID Group Discovery (#7804)
62 lines
1.7 KiB
TypeScript
62 lines
1.7 KiB
TypeScript
import React from 'react';
|
|
import { useAgentCategories } from '~/hooks/Agents';
|
|
import { cn } from '~/utils';
|
|
|
|
interface AgentCategoryDisplayProps {
|
|
category?: string;
|
|
className?: string;
|
|
showIcon?: boolean;
|
|
iconClassName?: string;
|
|
showEmptyFallback?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Component to display an agent category with proper translation
|
|
*
|
|
* @param category - The category value (e.g., "general", "hr", etc.)
|
|
* @param className - Optional className for the container
|
|
* @param showIcon - Whether to show the category icon
|
|
* @param iconClassName - Optional className for the icon
|
|
* @param showEmptyFallback - Whether to show a fallback for empty categories
|
|
*/
|
|
const AgentCategoryDisplay: React.FC<AgentCategoryDisplayProps> = ({
|
|
category,
|
|
className = '',
|
|
showIcon = true,
|
|
iconClassName = 'h-4 w-4 mr-2',
|
|
showEmptyFallback = false,
|
|
}) => {
|
|
const { categories, emptyCategory } = useAgentCategories();
|
|
|
|
// Find the category in our processed categories list
|
|
const categoryItem = categories.find((c) => c.value === category);
|
|
|
|
// Handle empty string case differently than undefined/null
|
|
if (category === '') {
|
|
if (!showEmptyFallback) {
|
|
return null;
|
|
}
|
|
// Show the empty category placeholder
|
|
return (
|
|
<div className={cn('flex items-center text-gray-400', className)}>
|
|
<span>{emptyCategory.label}</span>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
// No category or unknown category
|
|
if (!category || !categoryItem) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div className={cn('flex items-center', className)}>
|
|
{showIcon && categoryItem.icon && (
|
|
<span className={cn('flex-shrink-0', iconClassName)}>{categoryItem.icon}</span>
|
|
)}
|
|
<span>{categoryItem.label}</span>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default AgentCategoryDisplay;
|