diff --git a/src/plugins/newsfeed/public/index.ts b/src/plugins/newsfeed/public/index.ts index 1217de60d9638..b70606b09a34f 100644 --- a/src/plugins/newsfeed/public/index.ts +++ b/src/plugins/newsfeed/public/index.ts @@ -18,7 +18,9 @@ */ import { PluginInitializerContext } from 'src/core/public'; -import { NewsfeedPublicPlugin } from './plugin'; +import { Setup, Start, NewsfeedPublicPlugin } from './plugin'; + +export { Setup, Start }; export function plugin(initializerContext: PluginInitializerContext) { return new NewsfeedPublicPlugin(initializerContext); diff --git a/src/plugins/newsfeed/public/plugin.tsx b/src/plugins/newsfeed/public/plugin.tsx index 5ea5e5b324717..7d0358dddaef0 100644 --- a/src/plugins/newsfeed/public/plugin.tsx +++ b/src/plugins/newsfeed/public/plugin.tsx @@ -27,8 +27,8 @@ import { NewsfeedPluginInjectedConfig } from '../types'; import { NewsfeedNavButton, NewsfeedApiFetchResult } from './components/newsfeed_header_nav_button'; import { getApi } from './lib/api'; -export type Setup = void; -export type Start = void; +export type Setup = object; +export type Start = object; export class NewsfeedPublicPlugin implements Plugin { private readonly kibanaVersion: string; @@ -38,7 +38,9 @@ export class NewsfeedPublicPlugin implements Plugin { this.kibanaVersion = initializerContext.env.packageInfo.version; } - public setup(core: CoreSetup): Setup {} + public setup(core: CoreSetup): Setup { + return {}; + } public start(core: CoreStart): Start { const api$ = this.fetchNewsfeed(core); @@ -46,6 +48,8 @@ export class NewsfeedPublicPlugin implements Plugin { order: 1000, mount: target => this.mount(api$, target), }); + + return {}; } public stop() { diff --git a/x-pack/legacy/plugins/siem/public/components/news_feed/index.tsx b/x-pack/legacy/plugins/siem/public/components/news_feed/index.tsx index 95f12758d5e63..6a5e08b287f96 100644 --- a/x-pack/legacy/plugins/siem/public/components/news_feed/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/news_feed/index.tsx @@ -8,7 +8,7 @@ import React, { useEffect, useState } from 'react'; import chrome from 'ui/chrome'; import { fetchNews, getNewsFeedUrl, getNewsItemsFromApiResponse } from './helpers'; -import { useUiSetting$ } from '../../lib/kibana'; +import { useKibana, useUiSetting$ } from '../../lib/kibana'; import { NewsFeed } from './news_feed'; import { NewsItem } from './types'; @@ -16,10 +16,14 @@ export const StatefulNewsFeed = React.memo<{ enableNewsFeedSetting: string; newsFeedSetting: string; }>(({ enableNewsFeedSetting, newsFeedSetting }) => { + const kibanaNewsfeedEnabled = useKibana().services.newsfeed; const [enableNewsFeed] = useUiSetting$(enableNewsFeedSetting); const [newsFeedUrlSetting] = useUiSetting$(newsFeedSetting); const [news, setNews] = useState(null); + // respect kibana's global newsfeed.enabled setting + const newsfeedEnabled = kibanaNewsfeedEnabled && enableNewsFeed; + const newsFeedUrl = getNewsFeedUrl({ newsFeedUrlSetting, getKibanaVersion: chrome.getKibanaVersion, @@ -42,16 +46,16 @@ export const StatefulNewsFeed = React.memo<{ } }; - if (enableNewsFeed) { + if (newsfeedEnabled) { fetchData(); } return () => { canceled = true; }; - }, [enableNewsFeed, newsFeedUrl]); + }, [newsfeedEnabled, newsFeedUrl]); - return <>{enableNewsFeed ? : null}; + return <>{newsfeedEnabled ? : null}; }); StatefulNewsFeed.displayName = 'StatefulNewsFeed'; diff --git a/x-pack/legacy/plugins/siem/public/plugin.tsx b/x-pack/legacy/plugins/siem/public/plugin.tsx index 057ed3a91c3b9..7911b5eb9833b 100644 --- a/x-pack/legacy/plugins/siem/public/plugin.tsx +++ b/x-pack/legacy/plugins/siem/public/plugin.tsx @@ -14,6 +14,7 @@ import { import { HomePublicPluginSetup } from '../../../../../src/plugins/home/public'; import { DataPublicPluginStart } from '../../../../../src/plugins/data/public'; import { IEmbeddableStart } from '../../../../../src/plugins/embeddable/public'; +import { Start as NewsfeedStart } from '../../../../../src/plugins/newsfeed/public'; import { Start as InspectorStart } from '../../../../../src/plugins/inspector/public'; import { IUiActionsStart } from '../../../../../src/plugins/ui_actions/public'; import { UsageCollectionSetup } from '../../../../../src/plugins/usage_collection/public'; @@ -29,6 +30,7 @@ export interface StartPlugins { data: DataPublicPluginStart; embeddable: IEmbeddableStart; inspector: InspectorStart; + newsfeed?: NewsfeedStart; uiActions: IUiActionsStart; } export type StartServices = CoreStart & StartPlugins;