diff --git a/packages-answers/ui/src/Admin/Chatflows/index.tsx b/packages-answers/ui/src/Admin/Chatflows/index.tsx index aff5d85e52b..ae51c2e2c24 100644 --- a/packages-answers/ui/src/Admin/Chatflows/index.tsx +++ b/packages-answers/ui/src/Admin/Chatflows/index.tsx @@ -93,6 +93,18 @@ const AdminChatflows = () => { const [bulkUpdateIncludeName, setBulkUpdateIncludeName] = useState(false) const [bulkUpdateInProgress, setBulkUpdateInProgress] = useState(false) + // Template banner collapse — smart default: open when outdated, closed when all current + const [templateBannerExpanded, setTemplateBannerExpanded] = useState( + localStorage.getItem('adminTemplateBannerExpanded') !== null + ? localStorage.getItem('adminTemplateBannerExpanded') !== 'false' + : true + ) + const toggleTemplateBanner = () => { + const next = !templateBannerExpanded + setTemplateBannerExpanded(next) + localStorage.setItem('adminTemplateBannerExpanded', String(next)) + } + // Versioning state const [versionModalOpen, setVersionModalOpen] = useState(false) const [selectedChatflowForVersions, setSelectedChatflowForVersions] = useState('') @@ -479,7 +491,10 @@ const AdminChatflows = () => { badgeBg: isDarkMode ? 'rgba(255, 193, 7, 0.3)' : 'rgba(184, 134, 11, 0.15)', badgeBorder: isDarkMode ? '1px solid rgba(255, 193, 7, 0.5)' : '1px solid #b8860b', chipBg: isDarkMode ? 'rgba(255, 193, 7, 0.2)' : 'rgba(184, 134, 11, 0.15)', - chipBorder: isDarkMode ? '1px solid rgba(255, 193, 7, 0.4)' : '1px solid #b8860b' + chipBorder: isDarkMode ? '1px solid rgba(255, 193, 7, 0.4)' : '1px solid #b8860b', + countBg: isDarkMode ? 'rgba(255, 193, 7, 0.2)' : 'rgba(184, 134, 11, 0.15)', + countBorder: isDarkMode ? '1px solid rgba(255, 193, 7, 0.4)' : '1px solid #b8860b', + countText: isDarkMode ? 'rgba(255, 193, 7, 0.9)' : '#8b6914' } : { bg: isDarkMode ? 'rgba(76, 175, 80, 0.1)' : 'rgba(76, 175, 80, 0.08)', @@ -495,9 +510,20 @@ const AdminChatflows = () => { badgeBg: isDarkMode ? 'rgba(76, 175, 80, 0.3)' : 'rgba(56, 142, 60, 0.15)', badgeBorder: isDarkMode ? '1px solid rgba(76, 175, 80, 0.5)' : '1px solid #388e3c', chipBg: isDarkMode ? 'rgba(76, 175, 80, 0.2)' : 'rgba(56, 142, 60, 0.15)', - chipBorder: isDarkMode ? '1px solid rgba(76, 175, 80, 0.4)' : '1px solid #388e3c' + chipBorder: isDarkMode ? '1px solid rgba(76, 175, 80, 0.4)' : '1px solid #388e3c', + countBg: isDarkMode ? 'rgba(76, 175, 80, 0.2)' : 'rgba(56, 142, 60, 0.15)', + countBorder: isDarkMode ? '1px solid rgba(76, 175, 80, 0.4)' : '1px solid #388e3c', + countText: isDarkMode ? 'rgba(76, 175, 80, 0.9)' : '#2e7d32' } + const outdatedCount = chatflowsData.filter((cf: any) => cf.templateStatus === 'outdated').length + const bannerOpen = localStorage.getItem('adminTemplateBannerExpanded') !== null ? templateBannerExpanded : hasOutdated + const greenBadge = { + bgcolor: isDarkMode ? 'rgba(76, 175, 80, 0.3)' : 'rgba(56, 142, 60, 0.15)', + color: isDarkMode ? 'rgba(76, 175, 80, 0.9)' : '#2e7d32', + border: isDarkMode ? '1px solid rgba(76, 175, 80, 0.5)' : '1px solid #388e3c' + } + return ( { backdropFilter: 'blur(20px)' }} > - {/* Header Section */} - + {/* Header — always visible, click to toggle */} + @@ -522,41 +557,79 @@ const AdminChatflows = () => { - + + + + + + {/* Collapsible details */} + + {/* Template Details Grid */} + + {/* Left Column */} + + {/* Name */} + + + NAME + + + {fullDefaultTemplate.name} + + - {/* Template Details Grid */} - - {/* Left Column */} - - {/* Name */} - - - NAME - - - {fullDefaultTemplate.name} - - + {/* Description */} + {fullDefaultTemplate.description && ( + + + DESCRIPTION + + + {fullDefaultTemplate.description} + + + )} - {/* Description */} - {fullDefaultTemplate.description && ( + {/* Category */} { mb: 0.5 }} > - DESCRIPTION - - - {fullDefaultTemplate.description} + CATEGORY + + {(fullDefaultTemplate.category || 'Uncategorized') + .split(';') + .map((category: string, index: number) => ( + + ))} + - )} - {/* Category */} - - - CATEGORY - - - {(fullDefaultTemplate.category || 'Uncategorized') - .split(';') - .map((category: string, index: number) => ( - - ))} + {/* Owner */} + + + OWNER + + + {fullDefaultTemplate.isOwner + ? 'Me' + : fullDefaultTemplate.user?.name || + fullDefaultTemplate.user?.email || + fullDefaultTemplate.userId} + - {/* Owner */} + {/* Right Column */} - - OWNER - - - {fullDefaultTemplate.isOwner - ? 'Me' - : fullDefaultTemplate.user?.name || - fullDefaultTemplate.user?.email || - fullDefaultTemplate.userId} - - - - - {/* Right Column */} - - {/* Created Date */} - - - CREATED - - - {fullDefaultTemplate.createdDate - ? format(new Date(fullDefaultTemplate.createdDate), 'MMM d, yyyy h:mm a') - : 'N/A'} - - + {/* Created Date */} + + + CREATED + + + {fullDefaultTemplate.createdDate + ? format(new Date(fullDefaultTemplate.createdDate), 'MMM d, yyyy h:mm a') + : 'N/A'} + + - {/* Updated Date */} - - - UPDATED - - - {fullDefaultTemplate.updatedDate - ? format(new Date(fullDefaultTemplate.updatedDate), 'MMM d, yyyy h:mm a') - : 'N/A'} - - + {/* Updated Date */} + + + UPDATED + + + {fullDefaultTemplate.updatedDate + ? format(new Date(fullDefaultTemplate.updatedDate), 'MMM d, yyyy h:mm a') + : 'N/A'} + + - {/* Version */} - - - VERSION - - - v{fullDefaultTemplate.currentVersion || 1} - - + {/* Version */} + + + VERSION + + + v{fullDefaultTemplate.currentVersion || 1} + + - {/* Actions */} - - - ACTIONS - - - - window.open(getCanvasFullUrl(fullDefaultTemplate), '_blank')} - sx={{ - color: bc.iconColor, - bgcolor: bc.iconBg, - border: bc.border, - '&:hover': { - color: bc.iconHoverColor, - bgcolor: bc.iconHoverBg, - borderColor: bc.iconHoverBorder - } - }} - > - - - - - handleOpenMetrics(fullDefaultTemplate.id)} - sx={{ - color: bc.iconColor, - bgcolor: bc.iconBg, - border: bc.border, - '&:hover': { - color: bc.iconHoverColor, - bgcolor: bc.iconHoverBg, - borderColor: bc.iconHoverBorder - } - }} - > - - - - - handleOpenVersions(fullDefaultTemplate.id)} - sx={{ - color: bc.iconColor, - bgcolor: bc.iconBg, - border: bc.border, - '&:hover': { - color: bc.iconHoverColor, - bgcolor: bc.iconHoverBg, - borderColor: bc.iconHoverBorder - } - }} - > - - - + {/* Actions */} + + + ACTIONS + + + + { + e.stopPropagation() + window.open(getCanvasFullUrl(fullDefaultTemplate), '_blank') + }} + sx={{ + color: bc.iconColor, + bgcolor: bc.iconBg, + border: bc.border, + '&:hover': { + color: bc.iconHoverColor, + bgcolor: bc.iconHoverBg, + borderColor: bc.iconHoverBorder + } + }} + > + + + + + { + e.stopPropagation() + handleOpenMetrics(fullDefaultTemplate.id) + }} + sx={{ + color: bc.iconColor, + bgcolor: bc.iconBg, + border: bc.border, + '&:hover': { + color: bc.iconHoverColor, + bgcolor: bc.iconHoverBg, + borderColor: bc.iconHoverBorder + } + }} + > + + + + + { + e.stopPropagation() + handleOpenVersions(fullDefaultTemplate.id) + }} + sx={{ + color: bc.iconColor, + bgcolor: bc.iconBg, + border: bc.border, + '&:hover': { + color: bc.iconHoverColor, + bgcolor: bc.iconHoverBg, + borderColor: bc.iconHoverBorder + } + }} + > + + + + - + {' '} + {/* end collapsible */} ) @@ -1348,9 +1414,13 @@ const AdminChatflows = () => { label='DEFAULT TEMPLATE' size='small' sx={{ - bgcolor: 'rgba(255, 193, 7, 0.2)', - color: 'rgba(255, 193, 7, 0.9)', - border: '1px solid rgba(255, 193, 7, 0.3)', + bgcolor: isDarkMode + ? 'rgba(76, 175, 80, 0.2)' + : 'rgba(56, 142, 60, 0.15)', + color: isDarkMode ? 'rgba(76, 175, 80, 0.9)' : '#2e7d32', + border: isDarkMode + ? '1px solid rgba(76, 175, 80, 0.3)' + : '1px solid #388e3c', fontSize: '0.65rem', height: '18px', fontWeight: 600