diff --git a/public/pages/Main/Main.tsx b/public/pages/Main/Main.tsx index 9cfb6c89..fc56a0fd 100644 --- a/public/pages/Main/Main.tsx +++ b/public/pages/Main/Main.tsx @@ -25,6 +25,7 @@ import { DATE_TIME_FILTER_KEY, ROUTES, dataSourceObservable, + OS_NOTIFICATION_PLUGIN, } from '../../utils/constants'; import { CoreServicesConsumer } from '../../components/core_services'; import Findings from '../Findings'; @@ -66,9 +67,15 @@ import { ThreatIntelOverview } from '../ThreatIntel/containers/Overview/ThreatIn import { AddThreatIntelSource } from '../ThreatIntel/containers/AddThreatIntelSource/AddThreatIntelSource'; import { ThreatIntelScanConfigForm } from '../ThreatIntel/containers/ScanConfiguration/ThreatIntelScanConfigForm'; import { ThreatIntelSource } from '../ThreatIntel/containers/ThreatIntelSource/ThreatIntelSource'; -import queryString from 'query-string'; -import { dataSourceFilterFn } from '../../utils/helpers'; +import { parse } from 'query-string'; +import { + dataSourceFilterFn, + getPlugins, + setIsNotificationPluginInstalled, +} from '../../utils/helpers'; import { GettingStartedContent } from '../Overview/components/GettingStarted/GettingStartedContent'; +import { BrowserServices } from '../../models/interfaces'; +import { CHANNEL_TYPES } from '../CreateDetector/components/ConfigureAlerts/utils/constants'; enum Navigation { SecurityAnalytics = 'Security Analytics', @@ -108,6 +115,7 @@ interface MainProps extends RouteComponentProps { setActionMenu: AppMountParameters['setHeaderActionMenu']; multiDataSourceEnabled: boolean; dataSourceManagement?: DataSourceManagementPluginSetup; + services: BrowserServices; } interface MainState { @@ -150,7 +158,7 @@ export default class Main extends Component { const { dataSourceId: parsedDataSourceId, dataSourceLabel: parsedDataSourceLabel, - } = queryString.parse(this.props.location.search) as { + } = parse(this.props.location.search, { decode: false }) as { dataSourceId: string; dataSourceLabel: string; }; @@ -263,6 +271,7 @@ export default class Main extends Component { onDataSourceSelected = (sources: DataSourceOption[]) => { const { selectedDataSource: dataSource, dataSourceLoading } = this.state; + const { services } = this.props; if ( sources[0] && (dataSource?.id !== sources[0].id || dataSource?.label !== sources[0].label) @@ -271,9 +280,19 @@ export default class Main extends Component { this.setState({ selectedDataSource: { ...sources[0] }, }); - dataSourceObservable.next( - dataSourceInfo.activeDataSource - ); + dataSourceObservable.next(dataSourceInfo.activeDataSource); + + services.notificationsService.getServerFeatures().then((response) => { + if (response.ok) { + CHANNEL_TYPES.splice(0, CHANNEL_TYPES.length, ...response.response); + } + }); + + getPlugins(services.opensearchService).then((plugins): void => { + setIsNotificationPluginInstalled(plugins.includes(OS_NOTIFICATION_PLUGIN)); + }); + + DataStore.logTypes.getLogTypes(); } if (dataSourceLoading) { @@ -281,7 +300,6 @@ export default class Main extends Component { } }; - setDataSourceMenuReadOnly = (readOnly: boolean) => { this.setState({ dataSourceMenuReadOnly: readOnly }); }; diff --git a/public/security_analytics_app.tsx b/public/security_analytics_app.tsx index a084f5b8..883b82ef 100644 --- a/public/security_analytics_app.tsx +++ b/public/security_analytics_app.tsx @@ -87,6 +87,7 @@ export function renderApp(