Fix jwt-token
This commit is contained in:
@@ -372,7 +372,11 @@ const Alerts = () => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{(alertRules || []).map((rule) => (
|
{(alertRules || []).map((rule) => {
|
||||||
|
// DEBUG: Aggressive debugging for this specific rule
|
||||||
|
console.log('🔍 Rendering rule:', rule.id, 'alert_channels:', rule.alert_channels, 'type:', typeof rule.alert_channels);
|
||||||
|
|
||||||
|
return (
|
||||||
<tr key={rule.id} className="hover:bg-gray-50">
|
<tr key={rule.id} className="hover:bg-gray-50">
|
||||||
<td>
|
<td>
|
||||||
<div>
|
<div>
|
||||||
@@ -403,40 +407,54 @@ const Alerts = () => {
|
|||||||
<td>
|
<td>
|
||||||
<div className="flex space-x-1">
|
<div className="flex space-x-1">
|
||||||
{(() => {
|
{(() => {
|
||||||
// Normalize alert_channels - ensure it's always an array
|
try {
|
||||||
let alertChannels = rule.alert_channels || [];
|
// Normalize alert_channels - ensure it's always an array
|
||||||
|
let alertChannels = rule.alert_channels || [];
|
||||||
// DEBUG: Add debugging to catch object rendering
|
|
||||||
if (typeof alertChannels === 'object' && alertChannels !== null) {
|
// DEBUG: Add debugging to catch object rendering
|
||||||
const hasKeys = Object.keys(alertChannels).some(key => ['sms', 'webhook', 'email'].includes(key));
|
console.log('🔍 Processing alert_channels for rule', rule.id, ':', alertChannels, 'type:', typeof alertChannels);
|
||||||
if (hasKeys) {
|
|
||||||
console.log('DEBUG: Found problematic alert_channels object:', alertChannels, 'for rule:', rule.id);
|
// Convert object to array if needed
|
||||||
|
if (typeof alertChannels === 'object' && alertChannels !== null && !Array.isArray(alertChannels)) {
|
||||||
|
console.log('🔧 Converting object to array:', alertChannels);
|
||||||
|
alertChannels = Object.keys(alertChannels).filter(key => alertChannels[key] === true);
|
||||||
|
console.log('🔧 Converted to array:', alertChannels);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// Ensure it's an array
|
||||||
if (typeof alertChannels === 'object' && !Array.isArray(alertChannels)) {
|
if (!Array.isArray(alertChannels)) {
|
||||||
// Convert object like {sms: true, webhook: false, email: true} to array
|
console.warn('⚠️ alert_channels is not an array, setting to empty array:', alertChannels);
|
||||||
alertChannels = Object.keys(alertChannels).filter(key => alertChannels[key]);
|
alertChannels = [];
|
||||||
}
|
|
||||||
if (!Array.isArray(alertChannels)) {
|
|
||||||
alertChannels = []; // fallback to empty array
|
|
||||||
}
|
|
||||||
|
|
||||||
// DEBUG: Ensure we're only rendering strings
|
|
||||||
return alertChannels.map((channel, index) => {
|
|
||||||
if (typeof channel !== 'string') {
|
|
||||||
console.error('DEBUG: Non-string channel detected:', channel, typeof channel);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
return (
|
|
||||||
|
// Validate all elements are strings
|
||||||
|
const validChannels = alertChannels.filter(channel => {
|
||||||
|
const isString = typeof channel === 'string';
|
||||||
|
if (!isString) {
|
||||||
|
console.error('❌ Non-string channel detected:', channel, typeof channel);
|
||||||
|
}
|
||||||
|
return isString;
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('✅ Final channels to render:', validChannels);
|
||||||
|
|
||||||
|
// Render the channels
|
||||||
|
const elements = validChannels.map((channel, index) => (
|
||||||
<span
|
<span
|
||||||
key={index}
|
key={index}
|
||||||
className="px-2 py-1 bg-blue-100 text-blue-800 rounded text-xs"
|
className="px-2 py-1 bg-blue-100 text-blue-800 rounded text-xs"
|
||||||
>
|
>
|
||||||
{channel}
|
{channel}
|
||||||
</span>
|
</span>
|
||||||
);
|
));
|
||||||
}).filter(Boolean);
|
|
||||||
|
console.log('✅ Rendered elements:', elements);
|
||||||
|
return elements;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('💥 Error in alert_channels rendering:', error);
|
||||||
|
return <span className="text-red-500 text-xs">Error rendering channels</span>;
|
||||||
|
}
|
||||||
})()}
|
})()}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -512,7 +530,8 @@ const Alerts = () => {
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
);
|
||||||
|
})}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user