diff --git a/public/pages/Alerts/components/CorrelationAlertFlyout/CorrelationAlertFlyout.tsx b/public/pages/Alerts/components/CorrelationAlertFlyout/CorrelationAlertFlyout.tsx index 8217c8de..1845b43d 100644 --- a/public/pages/Alerts/components/CorrelationAlertFlyout/CorrelationAlertFlyout.tsx +++ b/public/pages/Alerts/components/CorrelationAlertFlyout/CorrelationAlertFlyout.tsx @@ -28,7 +28,6 @@ import { formatRuleType, renderTime, } from '../../../../utils/helpers'; - import { IndexPatternsService, OpenSearchService, DetectorsService } from '../../../../services'; import { parseAlertSeverityToOption } from '../../../CreateDetector/components/ConfigureAlerts/utils/helpers'; import { NotificationsStart } from 'opensearch-dashboards/public'; import { DataStore } from '../../../../store/DataStore'; diff --git a/public/pages/Alerts/containers/Alerts/Alerts.tsx b/public/pages/Alerts/containers/Alerts/Alerts.tsx index 1b0915b8..3f11b7d9 100644 --- a/public/pages/Alerts/containers/Alerts/Alerts.tsx +++ b/public/pages/Alerts/containers/Alerts/Alerts.tsx @@ -95,7 +95,7 @@ export interface AlertsState { dateFormat: string; widgetEmptyMessage: React.ReactNode | undefined; widgetEmptyCorrelationMessage: React.ReactNode | undefined; - tab: string; + tab: 'detector findings' | 'correlations'; // Union type for tab } const groupByOptions = [ @@ -107,7 +107,6 @@ export class Alerts extends Component { static contextType = CoreServicesContext; private abortControllers: AbortController[] = []; - constructor(props: AlertsProps) { super(props); @@ -134,7 +133,7 @@ export class Alerts extends Component { dateFormat: timeUnits.dateFormat, widgetEmptyMessage: undefined, widgetEmptyCorrelationMessage: undefined, - tab: 'findings' + tab: 'detector findings' }; } @@ -232,7 +231,7 @@ export class Alerts extends Component { }; private renderVisAsPerTab() { - if (this.state.tab === "findings") { + if (this.state.tab === "detector findings") { renderVisualization(this.generateVisualizationSpec(this.state.filteredAlerts), 'alerts-view'); } else { renderVisualization(this.generateCorrelationVisualizationSpec(this.state.filteredCorrelationAlerts), 'alerts-view'); @@ -240,7 +239,7 @@ export class Alerts extends Component { } private getAlertsAsPerTab() { - if (this.state.tab === "findings") { + if (this.state.tab === "detector findings") { this.abortPendingGetAlerts(); const abortController = new AbortController(); this.abortControllers.push(abortController); @@ -838,7 +837,6 @@ export class Alerts extends Component { alertItem={flyoutCorrelationData.alertItem} onClose={this.onCorrelationFlyoutClose} onAcknowledge={this.onAcknowledgeCorrelationAlert} - indexPatternService={this.props.indexPatternService} /> )} @@ -891,12 +889,12 @@ export class Alerts extends Component { - this.setState({ tab: 'findings' })} isSelected={this.state.tab === 'findings'}> + this.setState({ tab: 'detector findings' })} isSelected={this.state.tab === 'detector findings'}> Findings this.setState({ tab: 'correlations' })} isSelected={this.state.tab === 'correlations'}> @@ -908,7 +906,7 @@ export class Alerts extends Component { - {this.state.tab === 'findings' && ( + {this.state.tab === 'detector findings' && ( // Content for the "Findings" tab ['history']; notifications: NotificationsStart | null; - services: BrowserServices; + notificationsService: NotificationsService + opensearchService: OpenSearchService } export interface CorrelationOption { @@ -199,14 +197,13 @@ export const CreateCorrelationRule: React.FC = ( useEffect(() => { const setInitalNotificationValues = async () => { - const { services } = props; - const plugins = await getPlugins(services.opensearchService); + const plugins = await getPlugins(props.opensearchService); if (plugins) { setHasNotificationPlugin(plugins.includes(OS_NOTIFICATION_PLUGIN)); } }; const setNotificationChannelValues = async () => { - const channels = await getNotificationChannels(props.services.notificationsService); + const channels = await getNotificationChannels(props.notificationsService); const parsedChannels = parseNotificationChannelsToOptions(channels); setNotificationChannels(parsedChannels); setLoadingNotifications(false); diff --git a/public/pages/Main/Main.tsx b/public/pages/Main/Main.tsx index d35dca77..80eeb49c 100644 --- a/public/pages/Main/Main.tsx +++ b/public/pages/Main/Main.tsx @@ -650,7 +650,8 @@ export default class Main extends Component { fieldMappingService={services?.fieldMappingService} notifications={core?.notifications} dataSource={selectedDataSource} - services={services} + notificationsService={services?.notificationsService} + opensearchService={services?.opensearchService} /> )} /> @@ -663,7 +664,8 @@ export default class Main extends Component { fieldMappingService={services?.fieldMappingService} notifications={core?.notifications} dataSource={selectedDataSource} - services={services} + notificationsService={services?.notificationsService} + opensearchService={services?.opensearchService} /> )} />