diff --git a/x-pack/plugins/infra/public/apps/common_providers.tsx b/x-pack/plugins/infra/public/apps/common_providers.tsx index fc82f4bf6cb00..e66c54745ca51 100644 --- a/x-pack/plugins/infra/public/apps/common_providers.tsx +++ b/x-pack/plugins/infra/public/apps/common_providers.tsx @@ -5,7 +5,7 @@ */ import { ApolloClient } from 'apollo-client'; -import { CoreStart } from 'kibana/public'; +import { AppMountParameters, CoreStart } from 'kibana/public'; import React, { useMemo } from 'react'; import { useUiSetting$ } from '../../../../../src/plugins/kibana_react/public'; import { EuiThemeProvider } from '../../../observability/public'; @@ -13,20 +13,24 @@ import { TriggersAndActionsUIPublicPluginStart } from '../../../triggers_actions import { createKibanaContextForPlugin } from '../hooks/use_kibana'; import { InfraClientStartDeps } from '../types'; import { ApolloClientContext } from '../utils/apollo_context'; +import { HeaderActionMenuProvider } from '../utils/header_action_menu_provider'; import { NavigationWarningPromptProvider } from '../utils/navigation_warning_prompt'; import { TriggersActionsProvider } from '../utils/triggers_actions_context'; export const CommonInfraProviders: React.FC<{ apolloClient: ApolloClient<{}>; triggersActionsUI: TriggersAndActionsUIPublicPluginStart; -}> = ({ apolloClient, children, triggersActionsUI }) => { + setHeaderActionMenu: AppMountParameters['setHeaderActionMenu']; +}> = ({ apolloClient, children, triggersActionsUI, setHeaderActionMenu }) => { const [darkMode] = useUiSetting$('theme:darkMode'); return ( - {children} + + {children} + diff --git a/x-pack/plugins/infra/public/apps/logs_app.tsx b/x-pack/plugins/infra/public/apps/logs_app.tsx index b6b171fcb4727..666ea02693873 100644 --- a/x-pack/plugins/infra/public/apps/logs_app.tsx +++ b/x-pack/plugins/infra/public/apps/logs_app.tsx @@ -23,14 +23,20 @@ import { prepareMountElement } from './common_styles'; export const renderApp = ( core: CoreStart, plugins: InfraClientStartDeps, - { element, history }: AppMountParameters + { element, history, setHeaderActionMenu }: AppMountParameters ) => { const apolloClient = createApolloClient(core.http.fetch); prepareMountElement(element); ReactDOM.render( - , + , element ); @@ -44,7 +50,8 @@ const LogsApp: React.FC<{ core: CoreStart; history: History; plugins: InfraClientStartDeps; -}> = ({ apolloClient, core, history, plugins }) => { + setHeaderActionMenu: AppMountParameters['setHeaderActionMenu']; +}> = ({ apolloClient, core, history, plugins, setHeaderActionMenu }) => { const uiCapabilities = core.application.capabilities; return ( @@ -52,6 +59,7 @@ const LogsApp: React.FC<{ diff --git a/x-pack/plugins/infra/public/apps/metrics_app.tsx b/x-pack/plugins/infra/public/apps/metrics_app.tsx index d91c64de933e6..37ef29a2b0cd1 100644 --- a/x-pack/plugins/infra/public/apps/metrics_app.tsx +++ b/x-pack/plugins/infra/public/apps/metrics_app.tsx @@ -25,14 +25,20 @@ import { prepareMountElement } from './common_styles'; export const renderApp = ( core: CoreStart, plugins: InfraClientStartDeps, - { element, history }: AppMountParameters + { element, history, setHeaderActionMenu }: AppMountParameters ) => { const apolloClient = createApolloClient(core.http.fetch); prepareMountElement(element); ReactDOM.render( - , + , element ); @@ -46,7 +52,8 @@ const MetricsApp: React.FC<{ core: CoreStart; history: History; plugins: InfraClientStartDeps; -}> = ({ apolloClient, core, history, plugins }) => { + setHeaderActionMenu: AppMountParameters['setHeaderActionMenu']; +}> = ({ apolloClient, core, history, plugins, setHeaderActionMenu }) => { const uiCapabilities = core.application.capabilities; return ( @@ -54,6 +61,7 @@ const MetricsApp: React.FC<{ diff --git a/x-pack/plugins/infra/public/pages/logs/page_content.tsx b/x-pack/plugins/infra/public/pages/logs/page_content.tsx index 10189c0d8076c..d091f55956923 100644 --- a/x-pack/plugins/infra/public/pages/logs/page_content.tsx +++ b/x-pack/plugins/infra/public/pages/logs/page_content.tsx @@ -6,7 +6,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiButtonEmpty } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import React from 'react'; +import React, { useContext } from 'react'; import { Route, Switch } from 'react-router-dom'; import useMount from 'react-use/lib/useMount'; @@ -24,9 +24,12 @@ import { LogEntryCategoriesPage } from './log_entry_categories'; import { LogEntryRatePage } from './log_entry_rate'; import { LogsSettingsPage } from './settings'; import { StreamPage } from './stream'; +import { HeaderMenuPortal } from '../../../../observability/public'; +import { HeaderActionMenuContext } from '../../utils/header_action_menu_provider'; export const LogsPageContent: React.FunctionComponent = () => { const uiCapabilities = useKibana().services.application?.capabilities; + const { setHeaderActionMenu } = useContext(HeaderActionMenuContext); const { initialize } = useLogSourceContext(); @@ -66,6 +69,28 @@ export const LogsPageContent: React.FunctionComponent = () => { + {setHeaderActionMenu && ( + + + + + + + + {ADD_DATA_LABEL} + + + + + )} +
{ - - - - - - {ADD_DATA_LABEL} - - diff --git a/x-pack/plugins/infra/public/pages/metrics/index.tsx b/x-pack/plugins/infra/public/pages/metrics/index.tsx index 022c62b6bb06b..222278dde3314 100644 --- a/x-pack/plugins/infra/public/pages/metrics/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/index.tsx @@ -40,6 +40,8 @@ import { SourceConfigurationFields } from '../../graphql/types'; import { AlertPrefillProvider } from '../../alerting/use_alert_prefill'; import { InfraMLCapabilitiesProvider } from '../../containers/ml/infra_ml_capabilities'; import { AnomalyDetectionFlyout } from './inventory_view/components/ml/anomaly_detection/anomoly_detection_flyout'; +import { HeaderMenuPortal } from '../../../../observability/public'; +import { HeaderActionMenuContext } from '../../utils/header_action_menu_provider'; const ADD_DATA_LABEL = i18n.translate('xpack.infra.metricsHeaderAddDataButtonLabel', { defaultMessage: 'Add data', @@ -47,6 +49,7 @@ const ADD_DATA_LABEL = i18n.translate('xpack.infra.metricsHeaderAddDataButtonLab export const InfrastructurePage = ({ match }: RouteComponentProps) => { const uiCapabilities = useKibana().services.application?.capabilities; + const { setHeaderActionMenu } = useContext(HeaderActionMenuContext); const kibana = useKibana(); @@ -72,6 +75,32 @@ export const InfrastructurePage = ({ match }: RouteComponentProps) => { })} /> + {setHeaderActionMenu && ( + + + + + + + + + + + + {ADD_DATA_LABEL} + + + + + )} +
{ ]} /> - - - - - - - - - - - {ADD_DATA_LABEL} - - - diff --git a/x-pack/plugins/infra/public/utils/header_action_menu_provider.tsx b/x-pack/plugins/infra/public/utils/header_action_menu_provider.tsx new file mode 100644 index 0000000000000..141b3bcc9a162 --- /dev/null +++ b/x-pack/plugins/infra/public/utils/header_action_menu_provider.tsx @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { AppMountParameters } from 'kibana/public'; + +interface ContextProps { + setHeaderActionMenu?: AppMountParameters['setHeaderActionMenu']; +} + +export const HeaderActionMenuContext = React.createContext({}); + +export const HeaderActionMenuProvider: React.FC> = ({ + setHeaderActionMenu, + children, +}) => { + return ( + + {children} + + ); +};