The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/alerting/unified/enterprise-components/AI/AIGenTriageButton/addAITriageButton.ts

34 lines
1.1 KiB

import { ComponentType, createElement } from 'react';
import { TimeRange } from '@grafana/data';
import { t } from '@grafana/i18n';
import { withErrorBoundary } from '@grafana/ui';
import { logError } from '../../../Analytics';
import { LogRecord } from '../../../components/rules/state-history/common';
export interface GenAITriageButtonProps {
logRecords: LogRecord[];
timeRange: TimeRange;
}
let InternalAITriageButtonComponent: ComponentType<GenAITriageButtonProps> | null = null;
export const AITriageButtonComponent: ComponentType<GenAITriageButtonProps> = (props) => {
if (!InternalAITriageButtonComponent) {
return null;
}
// Wrap the component with error boundary
const WrappedComponent = withErrorBoundary(InternalAITriageButtonComponent, {
title: t('alerting.ai.error-boundary.triage-button', 'AI Triage Button failed to load'),
style: 'alertbox',
errorLogger: logError,
});
return createElement(WrappedComponent, props);
};
export function addAITriageButton(component: ComponentType<GenAITriageButtonProps> | null) {
InternalAITriageButtonComponent = component;
}