From a8acfb89aae9ba431bf9a19514ff9c59ee0dfa96 Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Wed, 23 Mar 2022 15:07:33 -0400 Subject: [PATCH 1/9] add execution context support to: SR, ILM, IM, IP --- .../public/application/app.tsx | 11 +++++++++++ .../public/application/index.tsx | 12 ++++++++++-- .../index_lifecycle_management/public/plugin.tsx | 2 ++ .../index_management/public/application/app.tsx | 15 ++++++++++++--- .../public/application/app_context.tsx | 2 ++ .../application/mount_management_section.ts | 2 ++ .../index_management/public/shared_imports.ts | 1 + .../ingest_pipelines/public/application/app.tsx | 9 +++++++-- .../application/mount_management_section.ts | 2 ++ .../ingest_pipelines/public/shared_imports.ts | 1 + .../snapshot_restore/public/application/app.tsx | 9 ++++++++- 11 files changed, 58 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/index_lifecycle_management/public/application/app.tsx b/x-pack/plugins/index_lifecycle_management/public/application/app.tsx index 89d19bb7edad5..3b1bc76a7167b 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/app.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/app.tsx @@ -9,7 +9,9 @@ import React, { useEffect } from 'react'; import { Router, Switch, Route, Redirect } from 'react-router-dom'; import { ScopedHistory } from 'kibana/public'; import { METRIC_TYPE } from '@kbn/analytics'; +import { useExecutionContext } from 'src/plugins/kibana_react/public'; +import { useKibana } from '../shared_imports'; import { UIM_APP_LOAD } from './constants'; import { EditPolicy } from './sections/edit_policy'; import { PolicyList } from './sections/policy_list'; @@ -17,8 +19,17 @@ import { trackUiMetric } from './services/ui_metric'; import { ROUTES } from './services/navigation'; export const App = ({ history }: { history: ScopedHistory }) => { + const { + services: { executionContext }, + } = useKibana(); + useEffect(() => trackUiMetric(METRIC_TYPE.LOADED, UIM_APP_LOAD), []); + useExecutionContext(executionContext!, { + type: 'application', + page: 'indexLifecycleManagement', + }); + return ( diff --git a/x-pack/plugins/index_lifecycle_management/public/application/index.tsx b/x-pack/plugins/index_lifecycle_management/public/application/index.tsx index 5dd0ca5f1c409..b9323a56529a3 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/index.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/index.tsx @@ -15,7 +15,7 @@ import { UnmountCallback, CoreTheme, } from 'src/core/public'; -import { DocLinksStart } from 'kibana/public'; +import { DocLinksStart, ExecutionContextStart } from 'kibana/public'; import { CloudSetup, @@ -37,6 +37,7 @@ export const renderApp = ( license: ILicense, theme$: Observable, docLinks: DocLinksStart, + executionContext: ExecutionContextStart, cloud?: CloudSetup ): UnmountCallback => { const { getUrlForApp } = application; @@ -45,7 +46,14 @@ export const renderApp = ( diff --git a/x-pack/plugins/index_lifecycle_management/public/plugin.tsx b/x-pack/plugins/index_lifecycle_management/public/plugin.tsx index 7700518506cea..3ab758c05b6e9 100644 --- a/x-pack/plugins/index_lifecycle_management/public/plugin.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/plugin.tsx @@ -56,6 +56,7 @@ export class IndexLifecycleManagementPlugin i18n: { Context: I18nContext }, application, docLinks, + executionContext, } = coreStart; const license = await licensing.license$.pipe(first()).toPromise(); @@ -74,6 +75,7 @@ export class IndexLifecycleManagementPlugin license, theme$, docLinks, + executionContext, cloud ); diff --git a/x-pack/plugins/index_management/public/application/app.tsx b/x-pack/plugins/index_management/public/application/app.tsx index eeeba390c09db..f52479f41708b 100644 --- a/x-pack/plugins/index_management/public/application/app.tsx +++ b/x-pack/plugins/index_management/public/application/app.tsx @@ -12,11 +12,12 @@ import { Router, Switch, Route, Redirect } from 'react-router-dom'; import { ScopedHistory } from 'kibana/public'; import { UIM_APP_LOAD } from '../../common/constants'; +import { useExecutionContext } from '../shared_imports'; import { IndexManagementHome, homeSections } from './sections/home'; import { TemplateCreate } from './sections/template_create'; import { TemplateClone } from './sections/template_clone'; import { TemplateEdit } from './sections/template_edit'; -import { useServices } from './app_context'; +import { useAppContext } from './app_context'; import { ComponentTemplateCreate, ComponentTemplateEdit, @@ -24,8 +25,16 @@ import { } from './components'; export const App = ({ history }: { history: ScopedHistory }) => { - const { uiMetricService } = useServices(); - useEffect(() => uiMetricService.trackMetric(METRIC_TYPE.LOADED, UIM_APP_LOAD), [uiMetricService]); + const { core, services } = useAppContext(); + useEffect( + () => services.uiMetricService.trackMetric(METRIC_TYPE.LOADED, UIM_APP_LOAD), + [services.uiMetricService] + ); + + useExecutionContext(core.executionContext, { + type: 'application', + page: 'indexManagement', + }); return ( diff --git a/x-pack/plugins/index_management/public/application/app_context.tsx b/x-pack/plugins/index_management/public/application/app_context.tsx index b41e37a5f441c..e5120fff11627 100644 --- a/x-pack/plugins/index_management/public/application/app_context.tsx +++ b/x-pack/plugins/index_management/public/application/app_context.tsx @@ -17,6 +17,7 @@ import { ScopedHistory, DocLinksStart, IUiSettingsClient, + ExecutionContextStart, } from 'src/core/public'; import { SharePluginStart } from 'src/plugins/share/public'; @@ -29,6 +30,7 @@ export interface AppDependencies { core: { fatalErrors: FatalErrorsStart; getUrlForApp: ApplicationStart['getUrlForApp']; + executionContext: ExecutionContextStart; }; plugins: { usageCollection: UsageCollectionSetup; diff --git a/x-pack/plugins/index_management/public/application/mount_management_section.ts b/x-pack/plugins/index_management/public/application/mount_management_section.ts index cd9d2de55ff0e..7562f5e410750 100644 --- a/x-pack/plugins/index_management/public/application/mount_management_section.ts +++ b/x-pack/plugins/index_management/public/application/mount_management_section.ts @@ -62,6 +62,7 @@ export async function mountManagementSection( application, chrome: { docTitle }, uiSettings, + executionContext, } = core; const { url } = startDependencies.share; @@ -79,6 +80,7 @@ export async function mountManagementSection( core: { fatalErrors, getUrlForApp: application.getUrlForApp, + executionContext, }, plugins: { usageCollection, diff --git a/x-pack/plugins/index_management/public/shared_imports.ts b/x-pack/plugins/index_management/public/shared_imports.ts index c2d76a50fa1ac..210eb30cc82da 100644 --- a/x-pack/plugins/index_management/public/shared_imports.ts +++ b/x-pack/plugins/index_management/public/shared_imports.ts @@ -64,4 +64,5 @@ export { reactRouterNavigate, useKibana, KibanaThemeProvider, + useExecutionContext, } from '../../../../src/plugins/kibana_react/public'; diff --git a/x-pack/plugins/ingest_pipelines/public/application/app.tsx b/x-pack/plugins/ingest_pipelines/public/application/app.tsx index 99624cbcf9967..19ad3b2e1dd75 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/app.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/app.tsx @@ -10,7 +10,7 @@ import { EuiPageContent, EuiEmptyPrompt } from '@elastic/eui'; import React, { FunctionComponent } from 'react'; import { Router, Switch, Route } from 'react-router-dom'; -import { useKibana } from '../shared_imports'; +import { useKibana, useExecutionContext } from '../shared_imports'; import { APP_CLUSTER_REQUIRED_PRIVILEGES } from '../../common/constants'; @@ -44,7 +44,12 @@ export const AppWithoutRouter = () => ( export const App: FunctionComponent = () => { const { apiError } = useAuthorizationContext(); - const { history } = useKibana().services; + const { history, executionContext } = useKibana().services; + + useExecutionContext(executionContext!, { + type: 'application', + page: 'ingestPipelines', + }); if (apiError) { return ( diff --git a/x-pack/plugins/ingest_pipelines/public/application/mount_management_section.ts b/x-pack/plugins/ingest_pipelines/public/application/mount_management_section.ts index 81f7be35074d8..a032b3a66347b 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/mount_management_section.ts +++ b/x-pack/plugins/ingest_pipelines/public/application/mount_management_section.ts @@ -28,6 +28,7 @@ export async function mountManagementSection( docLinks, application, i18n: { Context: I18nContext }, + executionContext, } = coreStart; documentationService.setup(docLinks); @@ -45,6 +46,7 @@ export async function mountManagementSection( share: depsStart.share, fileUpload: depsStart.fileUpload, application, + executionContext, }; return renderApp(element, I18nContext, services, { http }, { theme$ }); diff --git a/x-pack/plugins/ingest_pipelines/public/shared_imports.ts b/x-pack/plugins/ingest_pipelines/public/shared_imports.ts index 90ccf78355f1a..1fde3a1930ba9 100644 --- a/x-pack/plugins/ingest_pipelines/public/shared_imports.ts +++ b/x-pack/plugins/ingest_pipelines/public/shared_imports.ts @@ -90,6 +90,7 @@ export { export { KibanaContextProvider, KibanaThemeProvider, + useExecutionContext, } from '../../../../src/plugins/kibana_react/public'; export const useKibana = () => _useKibana(); diff --git a/x-pack/plugins/snapshot_restore/public/application/app.tsx b/x-pack/plugins/snapshot_restore/public/application/app.tsx index f7056a673cfbb..0c5f7f9d4bed3 100644 --- a/x-pack/plugins/snapshot_restore/public/application/app.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/app.tsx @@ -10,6 +10,7 @@ import { Redirect, Route, Switch } from 'react-router-dom'; import { EuiPageContent } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; +import { useExecutionContext } from 'src/plugins/kibana_react/public'; import { APP_WRAPPER_CLASS } from '../../../../../src/core/public'; import { APP_REQUIRED_CLUSTER_PRIVILEGES } from '../../common'; @@ -29,11 +30,12 @@ import { PolicyAdd, PolicyEdit, } from './sections'; -import { useConfig } from './app_context'; +import { useAppContext, useConfig } from './app_context'; export const App: React.FunctionComponent = () => { const { slm_ui: slmUi } = useConfig(); const { apiError } = useAuthorizationContext(); + const { core } = useAppContext(); const sections: Section[] = ['repositories', 'snapshots', 'restore_status']; @@ -43,6 +45,11 @@ export const App: React.FunctionComponent = () => { const sectionsRegex = sections.join('|'); + useExecutionContext(core.executionContext, { + type: 'application', + page: 'snapshotRestore', + }); + return apiError ? ( Date: Thu, 24 Mar 2022 09:54:21 -0400 Subject: [PATCH 2/9] add execution context support to: license management, watcher --- .../public/application/app.tsx | 3 +- .../public/shared_imports.ts | 1 + .../public/application/app.js | 161 +++++++++--------- .../public/application/index.tsx | 1 + .../public/shared_imports.ts | 5 +- .../remote_clusters/public/shared_imports.ts | 5 +- .../public/application/app.tsx | 2 +- .../snapshot_restore/public/shared_imports.ts | 1 + .../watcher/public/application/app.tsx | 10 +- .../public/application/shared_imports.ts | 5 +- x-pack/plugins/watcher/public/plugin.ts | 2 + 11 files changed, 112 insertions(+), 84 deletions(-) diff --git a/x-pack/plugins/index_lifecycle_management/public/application/app.tsx b/x-pack/plugins/index_lifecycle_management/public/application/app.tsx index 3b1bc76a7167b..0e41b2043e8e0 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/app.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/app.tsx @@ -9,9 +9,8 @@ import React, { useEffect } from 'react'; import { Router, Switch, Route, Redirect } from 'react-router-dom'; import { ScopedHistory } from 'kibana/public'; import { METRIC_TYPE } from '@kbn/analytics'; -import { useExecutionContext } from 'src/plugins/kibana_react/public'; -import { useKibana } from '../shared_imports'; +import { useKibana, useExecutionContext } from '../shared_imports'; import { UIM_APP_LOAD } from './constants'; import { EditPolicy } from './sections/edit_policy'; import { PolicyList } from './sections/policy_list'; diff --git a/x-pack/plugins/index_lifecycle_management/public/shared_imports.ts b/x-pack/plugins/index_lifecycle_management/public/shared_imports.ts index e94f09e138693..f5a4356b9323e 100644 --- a/x-pack/plugins/index_lifecycle_management/public/shared_imports.ts +++ b/x-pack/plugins/index_lifecycle_management/public/shared_imports.ts @@ -48,6 +48,7 @@ export { KibanaContextProvider, KibanaThemeProvider, RedirectAppLinks, + useExecutionContext, } from '../../../../src/plugins/kibana_react/public'; export { APP_WRAPPER_CLASS } from '../../../../src/core/public'; diff --git a/x-pack/plugins/license_management/public/application/app.js b/x-pack/plugins/license_management/public/application/app.js index b260c4ebfb7a8..f02725bbaf875 100644 --- a/x-pack/plugins/license_management/public/application/app.js +++ b/x-pack/plugins/license_management/public/application/app.js @@ -5,94 +5,101 @@ * 2.0. */ -import React, { Component } from 'react'; +import React, { useEffect } from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; import { LicenseDashboard, UploadLicense } from './sections'; import { Switch, Route } from 'react-router-dom'; import { APP_PERMISSION } from '../../common/constants'; -import { SectionLoading } from '../shared_imports'; +import { SectionLoading, useExecutionContext } from '../shared_imports'; import { EuiPageContent, EuiPageBody, EuiEmptyPrompt } from '@elastic/eui'; -export class App extends Component { - componentDidMount() { - const { loadPermissions } = this.props; - loadPermissions(); - } - - render() { - const { hasPermission, permissionsLoading, permissionsError, telemetry } = this.props; - - if (permissionsLoading) { - return ( - - - - - - ); - } +export const App = ({ + hasPermission, + permissionsLoading, + permissionsError, + telemetry, + loadPermissions, + executionContext, +}) => { + useExecutionContext(executionContext, { + type: 'application', + page: 'licenseManagement', + }); - if (permissionsError) { - const error = permissionsError?.data?.message; + useEffect(() => { + loadPermissions(); + }, [loadPermissions]); - return ( - - - - - } - body={error ?

{error}

: null} + if (permissionsLoading) { + return ( + + + - - ); - } + +
+ ); + } - if (!hasPermission) { - return ( - - - - - } - body={ -

- {APP_PERMISSION}, - }} - /> -

- } - /> -
- ); - } + if (permissionsError) { + const error = permissionsError?.data?.message; - const withTelemetry = (Component) => (props) => ; return ( - - - - - - + + + + + } + body={error ?

{error}

: null} + /> +
); } -} + + if (!hasPermission) { + return ( + + + + + } + body={ +

+ {APP_PERMISSION}, + }} + /> +

+ } + /> +
+ ); + } + + const withTelemetry = (Component) => (props) => ; + return ( + + + + + + + ); +}; diff --git a/x-pack/plugins/license_management/public/application/index.tsx b/x-pack/plugins/license_management/public/application/index.tsx index 16b6ebb1afdf9..dd70e15646fc7 100644 --- a/x-pack/plugins/license_management/public/application/index.tsx +++ b/x-pack/plugins/license_management/public/application/index.tsx @@ -26,6 +26,7 @@ export const renderApp = (element: Element, dependencies: AppDependencies) => { , element diff --git a/x-pack/plugins/license_management/public/shared_imports.ts b/x-pack/plugins/license_management/public/shared_imports.ts index 878655c82c557..ad4d91b1473f6 100644 --- a/x-pack/plugins/license_management/public/shared_imports.ts +++ b/x-pack/plugins/license_management/public/shared_imports.ts @@ -7,4 +7,7 @@ export { SectionLoading } from '../../../../src/plugins/es_ui_shared/public/'; -export { KibanaThemeProvider } from '../../../../src/plugins/kibana_react/public'; +export { + KibanaThemeProvider, + useExecutionContext, +} from '../../../../src/plugins/kibana_react/public'; diff --git a/x-pack/plugins/remote_clusters/public/shared_imports.ts b/x-pack/plugins/remote_clusters/public/shared_imports.ts index 55d963e2a29b7..2cf69938d5464 100644 --- a/x-pack/plugins/remote_clusters/public/shared_imports.ts +++ b/x-pack/plugins/remote_clusters/public/shared_imports.ts @@ -11,4 +11,7 @@ export { SectionLoading, } from '../../../../src/plugins/es_ui_shared/public'; -export { KibanaThemeProvider } from '../../../../src/plugins/kibana_react/public'; +export { + KibanaThemeProvider, + useExecutionContext, +} from '../../../../src/plugins/kibana_react/public'; diff --git a/x-pack/plugins/snapshot_restore/public/application/app.tsx b/x-pack/plugins/snapshot_restore/public/application/app.tsx index 0c5f7f9d4bed3..d2de3dba3d25f 100644 --- a/x-pack/plugins/snapshot_restore/public/application/app.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/app.tsx @@ -10,7 +10,6 @@ import { Redirect, Route, Switch } from 'react-router-dom'; import { EuiPageContent } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; -import { useExecutionContext } from 'src/plugins/kibana_react/public'; import { APP_WRAPPER_CLASS } from '../../../../../src/core/public'; import { APP_REQUIRED_CLUSTER_PRIVILEGES } from '../../common'; @@ -19,6 +18,7 @@ import { PageError, WithPrivileges, NotAuthorizedSection, + useExecutionContext, } from '../shared_imports'; import { PageLoading } from './components'; import { DEFAULT_SECTION, Section } from './constants'; diff --git a/x-pack/plugins/snapshot_restore/public/shared_imports.ts b/x-pack/plugins/snapshot_restore/public/shared_imports.ts index 65c2bc7dc0f77..21792338caece 100644 --- a/x-pack/plugins/snapshot_restore/public/shared_imports.ts +++ b/x-pack/plugins/snapshot_restore/public/shared_imports.ts @@ -33,4 +33,5 @@ export { APP_WRAPPER_CLASS } from '../../../../src/core/public'; export { reactRouterNavigate, KibanaThemeProvider, + useExecutionContext, } from '../../../../src/plugins/kibana_react/public'; diff --git a/x-pack/plugins/watcher/public/application/app.tsx b/x-pack/plugins/watcher/public/application/app.tsx index 2f8ca489a5787..7f93d5d8cf798 100644 --- a/x-pack/plugins/watcher/public/application/app.tsx +++ b/x-pack/plugins/watcher/public/application/app.tsx @@ -13,6 +13,7 @@ import { ToastsSetup, IUiSettingsClient, ApplicationStart, + ExecutionContextStart, } from 'kibana/public'; import { Router, Switch, Route, Redirect, withRouter, RouteComponentProps } from 'react-router-dom'; @@ -26,13 +27,14 @@ import { ManagementAppMountParams, } from '../../../../../src/plugins/management/public'; +import { ChartsPluginSetup } from '../../../../../src/plugins/charts/public'; import { LicenseStatus } from '../../common/types/license_status'; import { WatchStatus } from './sections/watch_status/components/watch_status'; import { WatchEdit } from './sections/watch_edit/components/watch_edit'; import { WatchList } from './sections/watch_list/components/watch_list'; import { registerRouter } from './lib/navigation'; import { AppContextProvider } from './app_context'; -import { ChartsPluginSetup } from '../../../../../src/plugins/charts/public'; +import { useExecutionContext } from './shared_imports'; const ShareRouter = withRouter(({ children, history }: RouteComponentProps & { children: any }) => { registerRouter({ history }); @@ -50,6 +52,7 @@ export interface AppDeps { setBreadcrumbs: Parameters[0]['setBreadcrumbs']; history: ManagementAppMountParams['history']; getUrlForApp: ApplicationStart['getUrlForApp']; + executionContext: ExecutionContextStart; } export const App = (deps: AppDeps) => { @@ -60,6 +63,11 @@ export const App = (deps: AppDeps) => { return () => s.unsubscribe(); }, [deps.licenseStatus$]); + useExecutionContext(deps.executionContext, { + type: 'application', + page: 'watcher', + }); + if (!valid) { return ( diff --git a/x-pack/plugins/watcher/public/application/shared_imports.ts b/x-pack/plugins/watcher/public/application/shared_imports.ts index 0e11e0fdcf9be..4001b55bfdd2e 100644 --- a/x-pack/plugins/watcher/public/application/shared_imports.ts +++ b/x-pack/plugins/watcher/public/application/shared_imports.ts @@ -19,4 +19,7 @@ export { EuiCodeEditor, } from '../../../../../src/plugins/es_ui_shared/public'; -export { KibanaThemeProvider } from '../../../../../src/plugins/kibana_react/public'; +export { + KibanaThemeProvider, + useExecutionContext, +} from '../../../../../src/plugins/kibana_react/public'; diff --git a/x-pack/plugins/watcher/public/plugin.ts b/x-pack/plugins/watcher/public/plugin.ts index dcc9d9fd56fdc..2da4415010d6c 100644 --- a/x-pack/plugins/watcher/public/plugin.ts +++ b/x-pack/plugins/watcher/public/plugin.ts @@ -50,6 +50,7 @@ export class WatcherUIPlugin implements Plugin { docLinks, savedObjects, application, + executionContext, } = coreStart; docTitle.change(pluginName); @@ -74,6 +75,7 @@ export class WatcherUIPlugin implements Plugin { history, getUrlForApp: application.getUrlForApp, theme$, + executionContext, }); return () => { From 22fa7a2d89679d0f444be46b6e683de362c947aa Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Thu, 24 Mar 2022 10:47:16 -0400 Subject: [PATCH 3/9] add execution context support to: CCR, remote clusters, rollups --- .../public/app/index.tsx | 33 ++++++++++++++++--- .../public/plugin.ts | 2 ++ .../public/shared_imports.ts | 5 ++- .../public/application/app_context.tsx | 2 ++ .../public/application/index.d.ts | 3 +- .../public/application/index.js | 16 +++++++-- .../plugins/remote_clusters/public/plugin.ts | 3 +- x-pack/plugins/rollup/public/application.tsx | 21 ++++++++++-- .../plugins/rollup/public/shared_imports.ts | 1 + 9 files changed, 74 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/cross_cluster_replication/public/app/index.tsx b/x-pack/plugins/cross_cluster_replication/public/app/index.tsx index d6dc16a55a99f..cee244c2de006 100644 --- a/x-pack/plugins/cross_cluster_replication/public/app/index.tsx +++ b/x-pack/plugins/cross_cluster_replication/public/app/index.tsx @@ -17,25 +17,48 @@ import { ApplicationStart, DocLinksStart, CoreTheme, + ExecutionContextStart, } from 'src/core/public'; -import { KibanaThemeProvider } from '../shared_imports'; +import { KibanaThemeProvider, useExecutionContext } from '../shared_imports'; import { init as initBreadcrumbs, SetBreadcrumbs } from './services/breadcrumbs'; import { init as initDocumentation } from './services/documentation_links'; import { App } from './app'; import { ccrStore } from './store'; +const AppWithExecutionContext = ({ + history, + executionContext, + getUrlForApp, +}: { + history: ScopedHistory; + getUrlForApp: ApplicationStart['getUrlForApp']; + executionContext: ExecutionContextStart; +}) => { + useExecutionContext(executionContext, { + type: 'application', + page: 'crossClusterReplication', + }); + + return ; +}; + const renderApp = ( element: Element, I18nContext: I18nStart['Context'], history: ScopedHistory, getUrlForApp: ApplicationStart['getUrlForApp'], - theme$: Observable + theme$: Observable, + executionContext: ExecutionContextStart ): UnmountCallback => { render( - + , @@ -53,6 +76,7 @@ export async function mountApp({ history, getUrlForApp, theme$, + executionContext, }: { element: Element; setBreadcrumbs: SetBreadcrumbs; @@ -61,11 +85,12 @@ export async function mountApp({ history: ScopedHistory; getUrlForApp: ApplicationStart['getUrlForApp']; theme$: Observable; + executionContext: ExecutionContextStart; }): Promise { // Import and initialize additional services here instead of in plugin.ts to reduce the size of the // initial bundle as much as possible. initBreadcrumbs(setBreadcrumbs); initDocumentation(docLinks); - return renderApp(element, I18nContext, history, getUrlForApp, theme$); + return renderApp(element, I18nContext, history, getUrlForApp, theme$, executionContext); } diff --git a/x-pack/plugins/cross_cluster_replication/public/plugin.ts b/x-pack/plugins/cross_cluster_replication/public/plugin.ts index bc2546bdacb2a..87b8c93119624 100644 --- a/x-pack/plugins/cross_cluster_replication/public/plugin.ts +++ b/x-pack/plugins/cross_cluster_replication/public/plugin.ts @@ -50,6 +50,7 @@ export class CrossClusterReplicationPlugin implements Plugin { i18n: { Context: I18nContext }, docLinks, application: { getUrlForApp }, + executionContext, } = coreStart; docTitle.change(PLUGIN.TITLE); @@ -62,6 +63,7 @@ export class CrossClusterReplicationPlugin implements Plugin { history, getUrlForApp, theme$, + executionContext, }); return () => { diff --git a/x-pack/plugins/cross_cluster_replication/public/shared_imports.ts b/x-pack/plugins/cross_cluster_replication/public/shared_imports.ts index f850e054f9667..d9a0db5cd1a7d 100644 --- a/x-pack/plugins/cross_cluster_replication/public/shared_imports.ts +++ b/x-pack/plugins/cross_cluster_replication/public/shared_imports.ts @@ -13,6 +13,9 @@ export { PageLoading, } from '../../../../src/plugins/es_ui_shared/public'; -export { KibanaThemeProvider } from '../../../../src/plugins/kibana_react/public'; +export { + KibanaThemeProvider, + useExecutionContext, +} from '../../../../src/plugins/kibana_react/public'; export { APP_WRAPPER_CLASS } from '../../../../src/core/public'; diff --git a/x-pack/plugins/remote_clusters/public/application/app_context.tsx b/x-pack/plugins/remote_clusters/public/application/app_context.tsx index 528ec322f49e1..5f3bae6133dfd 100644 --- a/x-pack/plugins/remote_clusters/public/application/app_context.tsx +++ b/x-pack/plugins/remote_clusters/public/application/app_context.tsx @@ -6,10 +6,12 @@ */ import React, { createContext, useContext } from 'react'; +import { ExecutionContextStart } from 'kibana/public'; export interface Context { isCloudEnabled: boolean; cloudBaseUrl: string; + executionContext: ExecutionContextStart; } export const AppContext = createContext({} as any); diff --git a/x-pack/plugins/remote_clusters/public/application/index.d.ts b/x-pack/plugins/remote_clusters/public/application/index.d.ts index 588d18263df48..9f8f80d46a507 100644 --- a/x-pack/plugins/remote_clusters/public/application/index.d.ts +++ b/x-pack/plugins/remote_clusters/public/application/index.d.ts @@ -6,7 +6,7 @@ */ import { Observable } from 'rxjs'; -import { ScopedHistory, CoreTheme } from 'kibana/public'; +import { ScopedHistory, CoreTheme, ExecutionContextStart } from 'kibana/public'; import { RegisterManagementAppArgs, I18nStart } from '../types'; export declare const renderApp: ( @@ -15,6 +15,7 @@ export declare const renderApp: ( appDependencies: { isCloudEnabled: boolean; cloudBaseUrl: string; + executionContext: ExecutionContextStart; }, history: ScopedHistory, theme$: Observable diff --git a/x-pack/plugins/remote_clusters/public/application/index.js b/x-pack/plugins/remote_clusters/public/application/index.js index 01a6e20222210..39313b616acde 100644 --- a/x-pack/plugins/remote_clusters/public/application/index.js +++ b/x-pack/plugins/remote_clusters/public/application/index.js @@ -9,20 +9,32 @@ import React from 'react'; import { render, unmountComponentAtNode } from 'react-dom'; import { Provider } from 'react-redux'; -import { KibanaThemeProvider } from '../shared_imports'; +import { KibanaThemeProvider, useExecutionContext } from '../shared_imports'; import { App } from './app'; import { remoteClustersStore } from './store'; import { AppContextProvider } from './app_context'; import './_hacks.scss'; +const AppWithExecutionContext = ({ history, executionContext }) => { + useExecutionContext(executionContext, { + type: 'application', + page: 'remoteClusters', + }); + + return ; +}; + export const renderApp = (elem, I18nContext, appDependencies, history, theme$) => { render( - + diff --git a/x-pack/plugins/remote_clusters/public/plugin.ts b/x-pack/plugins/remote_clusters/public/plugin.ts index c6de539d1e6ed..c3d00bb0b2f48 100644 --- a/x-pack/plugins/remote_clusters/public/plugin.ts +++ b/x-pack/plugins/remote_clusters/public/plugin.ts @@ -51,6 +51,7 @@ export class RemoteClustersUIPlugin i18n: { Context: i18nContext }, docLinks, fatalErrors, + executionContext, } = core; docTitle.change(PLUGIN.getI18nName()); @@ -69,7 +70,7 @@ export class RemoteClustersUIPlugin const unmountAppCallback = await renderApp( element, i18nContext, - { isCloudEnabled, cloudBaseUrl }, + { isCloudEnabled, cloudBaseUrl, executionContext }, history, theme$ ); diff --git a/x-pack/plugins/rollup/public/application.tsx b/x-pack/plugins/rollup/public/application.tsx index 3bebe4597a08a..82a3bf215691f 100644 --- a/x-pack/plugins/rollup/public/application.tsx +++ b/x-pack/plugins/rollup/public/application.tsx @@ -9,8 +9,8 @@ import React from 'react'; import { render, unmountComponentAtNode } from 'react-dom'; import { Provider } from 'react-redux'; -import { CoreSetup } from 'kibana/public'; -import { KibanaContextProvider, KibanaThemeProvider } from './shared_imports'; +import { CoreSetup, ExecutionContextStart } from 'kibana/public'; +import { KibanaContextProvider, KibanaThemeProvider, useExecutionContext } from './shared_imports'; // @ts-ignore import { rollupJobsStore } from './crud_app/store'; // @ts-ignore @@ -20,6 +20,21 @@ import './index.scss'; import { ManagementAppMountParams } from '../../../../src/plugins/management/public'; +const AppWithExecutionContext = ({ + history, + executionContext, +}: { + history: ManagementAppMountParams['history']; + executionContext: ExecutionContextStart; +}) => { + useExecutionContext(executionContext, { + type: 'application', + page: 'remoteClusters', + }); + + return ; +}; + /** * This module will be loaded asynchronously to reduce the bundle size of your plugin's main bundle. */ @@ -40,7 +55,7 @@ export const renderApp = async ( - + diff --git a/x-pack/plugins/rollup/public/shared_imports.ts b/x-pack/plugins/rollup/public/shared_imports.ts index cb100f2df26f7..83182f2e05fe7 100644 --- a/x-pack/plugins/rollup/public/shared_imports.ts +++ b/x-pack/plugins/rollup/public/shared_imports.ts @@ -15,4 +15,5 @@ export { export { KibanaContextProvider, KibanaThemeProvider, + useExecutionContext, } from '../../../../src/plugins/kibana_react/public'; From 60019d81f12bd188913afe5714872a86440ba963 Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Thu, 24 Mar 2022 14:16:34 -0400 Subject: [PATCH 4/9] update tests --- src/core/public/mocks.ts | 1 + .../__jest__/client_integration/app/app.helpers.tsx | 3 ++- .../add/remote_clusters_add.helpers.tsx | 9 ++++++++- .../edit/remote_clusters_edit.helpers.tsx | 9 ++++++++- .../client_integration/helpers/app_context.mock.tsx | 2 ++ 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/core/public/mocks.ts b/src/core/public/mocks.ts index 6399b55c8a894..ef53e7ee0185e 100644 --- a/src/core/public/mocks.ts +++ b/src/core/public/mocks.ts @@ -30,6 +30,7 @@ import { themeServiceMock } from './theme/theme_service.mock'; export { chromeServiceMock } from './chrome/chrome_service.mock'; export { docLinksServiceMock } from './doc_links/doc_links_service.mock'; import { executionContextServiceMock } from './execution_context/execution_context_service.mock'; +export { executionContextServiceMock } from './execution_context/execution_context_service.mock'; export { fatalErrorsServiceMock } from './fatal_errors/fatal_errors_service.mock'; export { httpServiceMock } from './http/http_service.mock'; export { i18nServiceMock } from './i18n/i18n_service.mock'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx index 153f1c09c53a9..7c6d891042493 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test-jest-helpers'; -import { docLinksServiceMock } from 'src/core/public/mocks'; +import { docLinksServiceMock, executionContextServiceMock } from 'src/core/public/mocks'; import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; import { createBreadcrumbsMock } from '../../../public/application/services/breadcrumbs.mock'; import { licensingMock } from '../../../../licensing/public/mocks'; @@ -23,6 +23,7 @@ const AppWithContext = (props: any) => { breadcrumbService, license: licensingMock.createLicense(), docLinks: docLinksServiceMock.createStartContract(), + executionContext: executionContextServiceMock.createStartContract(), }} > diff --git a/x-pack/plugins/remote_clusters/__jest__/client_integration/add/remote_clusters_add.helpers.tsx b/x-pack/plugins/remote_clusters/__jest__/client_integration/add/remote_clusters_add.helpers.tsx index a4debdc6ae964..c5d421d6ea5e8 100644 --- a/x-pack/plugins/remote_clusters/__jest__/client_integration/add/remote_clusters_add.helpers.tsx +++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/add/remote_clusters_add.helpers.tsx @@ -8,6 +8,7 @@ import React from 'react'; import { registerTestBed } from '@kbn/test-jest-helpers'; +import { executionContextServiceMock } from '../../../../../../src/core/public/mocks'; import { RemoteClusterAdd } from '../../../public/application/sections'; import { createRemoteClustersStore } from '../../../public/application/store'; import { AppRouter, registerRouter } from '../../../public/application/services'; @@ -16,7 +17,13 @@ import { AppContextProvider } from '../../../public/application/app_context'; const ComponentWithContext = ({ isCloudEnabled }: { isCloudEnabled: boolean }) => { return ( - + ); diff --git a/x-pack/plugins/remote_clusters/__jest__/client_integration/edit/remote_clusters_edit.helpers.tsx b/x-pack/plugins/remote_clusters/__jest__/client_integration/edit/remote_clusters_edit.helpers.tsx index 86f75c12424e7..d1454388988d1 100644 --- a/x-pack/plugins/remote_clusters/__jest__/client_integration/edit/remote_clusters_edit.helpers.tsx +++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/edit/remote_clusters_edit.helpers.tsx @@ -8,6 +8,7 @@ import { registerTestBed, TestBedConfig } from '@kbn/test-jest-helpers'; import React from 'react'; +import { executionContextServiceMock } from '../../../../../../src/core/public/mocks'; import { RemoteClusterEdit } from '../../../public/application/sections'; import { createRemoteClustersStore } from '../../../public/application/store'; import { AppRouter, registerRouter } from '../../../public/application/services'; @@ -25,7 +26,13 @@ export const REMOTE_CLUSTER_EDIT = { const ComponentWithContext = (props: { isCloudEnabled: boolean }) => { const { isCloudEnabled, ...rest } = props; return ( - + ); diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx b/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx index 8176d3fcbbca2..586f4cf9648f7 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx @@ -16,6 +16,7 @@ import { notificationServiceMock, httpServiceMock, scopedHistoryMock, + executionContextServiceMock, } from '../../../../../../src/core/public/mocks'; import { AppContextProvider } from '../../../public/application/app_context'; import { AppDeps } from '../../../public/application/app'; @@ -51,6 +52,7 @@ export const mockContextValue: AppDeps = { http: httpServiceMock.createSetupContract(), history, getUrlForApp: jest.fn(), + executionContext: executionContextServiceMock.createStartContract(), }; export const withAppContext = (Component: ComponentType) => (props: any) => { From a89c2c2615f4ceb5364221904c12690637ef73de Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Mon, 28 Mar 2022 10:34:00 -0400 Subject: [PATCH 5/9] fix rollup page name --- x-pack/plugins/rollup/public/application.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/rollup/public/application.tsx b/x-pack/plugins/rollup/public/application.tsx index 82a3bf215691f..6e216f87ce6dc 100644 --- a/x-pack/plugins/rollup/public/application.tsx +++ b/x-pack/plugins/rollup/public/application.tsx @@ -29,7 +29,7 @@ const AppWithExecutionContext = ({ }) => { useExecutionContext(executionContext, { type: 'application', - page: 'remoteClusters', + page: 'rollup', }); return ; From 5226a32a7e4440d6be59ffece0047384c3255fdb Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Mon, 28 Mar 2022 15:25:12 -0400 Subject: [PATCH 6/9] add execution per tab in SR + IM --- .../helpers/setup_environment.tsx | 6 ++++- .../helpers/setup_environment.tsx | 2 ++ .../component_template_list_container.tsx | 9 ++++++++ .../component_templates_context.tsx | 23 ++++++++++++++++--- .../component_templates/shared_imports.ts | 5 +++- .../public/application/index.tsx | 3 ++- .../data_stream_list/data_stream_list.tsx | 8 ++++++- .../sections/home/index_list/index_list.tsx | 12 +++++++++- .../home/template_list/template_list.tsx | 12 +++++++++- .../sections/home/policy_list/policy_list.tsx | 9 +++++++- .../home/repository_list/repository_list.tsx | 10 ++++++-- .../home/restore_list/restore_list.tsx | 9 +++++++- .../home/snapshot_list/snapshot_list.tsx | 16 +++++++++++-- 13 files changed, 109 insertions(+), 15 deletions(-) diff --git a/x-pack/plugins/index_management/__jest__/client_integration/helpers/setup_environment.tsx b/x-pack/plugins/index_management/__jest__/client_integration/helpers/setup_environment.tsx index c5b077ef00333..b469b0293123d 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/helpers/setup_environment.tsx +++ b/x-pack/plugins/index_management/__jest__/client_integration/helpers/setup_environment.tsx @@ -14,6 +14,7 @@ import { notificationServiceMock, docLinksServiceMock, uiSettingsServiceMock, + executionContextServiceMock, } from '../../../../../../src/core/public/mocks'; import { GlobalFlyout } from '../../../../../../src/plugins/es_ui_shared/public'; import { createKibanaReactContext } from '../../../../../../src/plugins/kibana_react/public'; @@ -48,7 +49,10 @@ setUiMetricService(services.uiMetricService); const appDependencies = { services, - core: { getUrlForApp: () => {} }, + core: { + getUrlForApp: () => {}, + executionContext: executionContextServiceMock.createStartContract(), + }, plugins: {}, } as any; diff --git a/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/setup_environment.tsx b/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/setup_environment.tsx index 9c2017ad651f1..b3da9622ce984 100644 --- a/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/setup_environment.tsx +++ b/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/setup_environment.tsx @@ -12,6 +12,7 @@ import { notificationServiceMock, docLinksServiceMock, applicationServiceMock, + executionContextServiceMock, } from '../../../../../../../../../../src/core/public/mocks'; import { GlobalFlyout } from '../../../../../../../../../../src/plugins/es_ui_shared/public'; @@ -37,6 +38,7 @@ export const componentTemplatesDependencies = (httpSetup: HttpSetup) => ({ toasts: notificationServiceMock.createSetupContract().toasts, setBreadcrumbs: () => {}, getUrlForApp: applicationServiceMock.createStartContract().getUrlForApp, + executionContext: executionContextServiceMock.createInternalStartContract(), }); export const setupEnvironment = initHttpRequests; diff --git a/x-pack/plugins/index_management/public/application/components/component_templates/component_template_list/component_template_list_container.tsx b/x-pack/plugins/index_management/public/application/components/component_templates/component_template_list/component_template_list_container.tsx index 3124258d036e9..556face8f0986 100644 --- a/x-pack/plugins/index_management/public/application/components/component_templates/component_template_list/component_template_list_container.tsx +++ b/x-pack/plugins/index_management/public/application/components/component_templates/component_template_list/component_template_list_container.tsx @@ -8,6 +8,8 @@ import React from 'react'; import { RouteComponentProps } from 'react-router-dom'; +import { useExecutionContext } from '../shared_imports'; +import { useComponentTemplatesContext } from '../component_templates_context'; import { ComponentTemplatesAuthProvider } from './auth_provider'; import { ComponentTemplatesWithPrivileges } from './with_privileges'; import { ComponentTemplateList } from './component_template_list'; @@ -24,6 +26,13 @@ export const ComponentTemplateListContainer: React.FunctionComponent< }, history, }) => { + const { executionContext } = useComponentTemplatesContext(); + + useExecutionContext(executionContext, { + type: 'application', + page: 'indexManagementComponentTemplates', + }); + return ( diff --git a/x-pack/plugins/index_management/public/application/components/component_templates/component_templates_context.tsx b/x-pack/plugins/index_management/public/application/components/component_templates/component_templates_context.tsx index 89b4e90741410..d652cca47e1d1 100644 --- a/x-pack/plugins/index_management/public/application/components/component_templates/component_templates_context.tsx +++ b/x-pack/plugins/index_management/public/application/components/component_templates/component_templates_context.tsx @@ -8,7 +8,13 @@ import React, { createContext, useContext } from 'react'; import { UiCounterMetricType } from '@kbn/analytics'; -import { HttpSetup, DocLinksStart, NotificationsSetup, CoreStart } from 'src/core/public'; +import { + HttpSetup, + DocLinksStart, + NotificationsSetup, + CoreStart, + ExecutionContextStart, +} from 'src/core/public'; import { ManagementAppMountParams } from 'src/plugins/management/public'; import { getApi, getUseRequest, getSendRequest, getDocumentation, getBreadcrumbs } from './lib'; @@ -22,6 +28,7 @@ interface Props { toasts: NotificationsSetup['toasts']; setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs']; getUrlForApp: CoreStart['application']['getUrlForApp']; + executionContext: ExecutionContextStart; } interface Context { @@ -33,6 +40,7 @@ interface Context { trackMetric: (type: UiCounterMetricType, eventName: string) => void; toasts: NotificationsSetup['toasts']; getUrlForApp: CoreStart['application']['getUrlForApp']; + executionContext: ExecutionContextStart; } export const ComponentTemplatesProvider = ({ @@ -42,8 +50,16 @@ export const ComponentTemplatesProvider = ({ value: Props; children: React.ReactNode; }) => { - const { httpClient, apiBasePath, trackMetric, docLinks, toasts, setBreadcrumbs, getUrlForApp } = - value; + const { + httpClient, + apiBasePath, + trackMetric, + docLinks, + toasts, + setBreadcrumbs, + getUrlForApp, + executionContext, + } = value; const useRequest = getUseRequest(httpClient); const sendRequest = getSendRequest(httpClient); @@ -63,6 +79,7 @@ export const ComponentTemplatesProvider = ({ apiBasePath, breadcrumbs, getUrlForApp, + executionContext, }} > {children} diff --git a/x-pack/plugins/index_management/public/application/components/component_templates/shared_imports.ts b/x-pack/plugins/index_management/public/application/components/component_templates/shared_imports.ts index 2f5b98e59bb22..d205a7436d00e 100644 --- a/x-pack/plugins/index_management/public/application/components/component_templates/shared_imports.ts +++ b/x-pack/plugins/index_management/public/application/components/component_templates/shared_imports.ts @@ -72,4 +72,7 @@ export type { export { serializeComponentTemplate } from '../../../../common/lib'; -export { reactRouterNavigate } from '../../../../../../../src/plugins/kibana_react/public'; +export { + reactRouterNavigate, + useExecutionContext, +} from '../../../../../../../src/plugins/kibana_react/public'; diff --git a/x-pack/plugins/index_management/public/application/index.tsx b/x-pack/plugins/index_management/public/application/index.tsx index 409bd7443532d..5477e7702ef6f 100644 --- a/x-pack/plugins/index_management/public/application/index.tsx +++ b/x-pack/plugins/index_management/public/application/index.tsx @@ -35,7 +35,7 @@ export const renderApp = ( return () => undefined; } - const { i18n, docLinks, notifications, application } = core; + const { i18n, docLinks, notifications, application, executionContext } = core; const { Context: I18nContext } = i18n; const { services, history, setBreadcrumbs, uiSettings, kibanaVersion, theme$ } = dependencies; @@ -56,6 +56,7 @@ export const renderApp = ( toasts: notifications.toasts, setBreadcrumbs, getUrlForApp: application.getUrlForApp, + executionContext, }; render( diff --git a/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/data_stream_list.tsx b/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/data_stream_list.tsx index f483a37a42d1b..744c8c455718c 100644 --- a/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/data_stream_list.tsx +++ b/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/data_stream_list.tsx @@ -30,6 +30,7 @@ import { extractQueryParams, attemptToURIDecode, APP_WRAPPER_CLASS, + useExecutionContext, } from '../../../../shared_imports'; import { useAppContext } from '../../../app_context'; import { useLoadDataStreams } from '../../../services/api'; @@ -56,10 +57,15 @@ export const DataStreamList: React.FunctionComponent = ({ history }) => { + const { + core: { executionContext }, + } = useAppContext(); + + useExecutionContext(executionContext, { + type: 'application', + page: 'indexManagementIndices', + }); + return (
diff --git a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_list.tsx b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_list.tsx index 8c4828da5f04a..437888b993674 100644 --- a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_list.tsx +++ b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_list.tsx @@ -30,11 +30,12 @@ import { PageError, attemptToURIDecode, reactRouterNavigate, + useExecutionContext, } from '../../../../shared_imports'; import { LegacyIndexTemplatesDeprecation } from '../../../components'; import { useLoadIndexTemplates } from '../../../services/api'; import { documentationService } from '../../../services/documentation'; -import { useServices } from '../../../app_context'; +import { useAppContext, useServices } from '../../../app_context'; import { getTemplateEditLink, getTemplateListLink, @@ -68,8 +69,17 @@ export const TemplateList: React.FunctionComponent { const { uiMetricService } = useServices(); + const { + core: { executionContext }, + } = useAppContext(); + const { error, isLoading, data: allTemplates, resendRequest: reload } = useLoadIndexTemplates(); + useExecutionContext(executionContext, { + type: 'application', + page: 'indexManagementIndexTemplates', + }); + const [filters, setFilters] = useState>({ managed: { name: i18n.translate('xpack.idxMgmt.indexTemplatesList.viewManagedTemplateLabel', { diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_list.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_list.tsx index 569acec2041ba..7adb69ada4da6 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_list.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_list.tsx @@ -18,6 +18,7 @@ import { Error, WithPrivileges, NotAuthorizedSection, + useExecutionContext, } from '../../../../shared_imports'; import { SlmPolicy } from '../../../../../common/types'; @@ -26,7 +27,7 @@ import { BASE_PATH, UIM_POLICY_LIST_LOAD } from '../../../constants'; import { useDecodedParams } from '../../../lib'; import { useLoadPolicies, useLoadRetentionSettings } from '../../../services/http'; import { linkToAddPolicy, linkToPolicy } from '../../../services/navigation'; -import { useServices } from '../../../app_context'; +import { useAppContext, useServices } from '../../../app_context'; import { PolicyDetails } from './policy_details'; import { PolicyTable } from './policy_table'; @@ -50,6 +51,7 @@ export const PolicyList: React.FunctionComponent { return linkToRepository(newRepositoryName); @@ -67,6 +68,11 @@ export const RepositoryList: React.FunctionComponent { } = useLoadRestores(currentInterval); const { uiMetricService, history } = useServices(); + const { core } = useAppContext(); // Track component loaded useEffect(() => { uiMetricService.trackUiMetric(UIM_RESTORE_LIST_LOAD); }, [uiMetricService]); + useExecutionContext(core.executionContext, { + type: 'application', + page: 'snapshotRestoreRestores', + }); + let content: JSX.Element; if (isInitialRequest) { diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_list.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_list.tsx index 0245f14addd42..794d74130fd67 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_list.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_list.tsx @@ -11,11 +11,17 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { RouteComponentProps } from 'react-router-dom'; import { EuiCallOut, EuiLink, EuiSpacer } from '@elastic/eui'; -import { PageLoading, PageError, Error, reactRouterNavigate } from '../../../../shared_imports'; +import { + PageLoading, + PageError, + Error, + reactRouterNavigate, + useExecutionContext, +} from '../../../../shared_imports'; import { BASE_PATH, UIM_SNAPSHOT_LIST_LOAD } from '../../../constants'; import { useLoadSnapshots } from '../../../services/http'; import { linkToRepositories } from '../../../services/navigation'; -import { useServices } from '../../../app_context'; +import { useAppContext, useServices } from '../../../app_context'; import { useDecodedParams, SnapshotListParams, DEFAULT_SNAPSHOT_LIST_PARAMS } from '../../../lib'; import { SnapshotDetails } from './snapshot_details'; @@ -52,6 +58,7 @@ export const SnapshotList: React.FunctionComponent { history.push(`${BASE_PATH}/snapshots`); @@ -74,6 +81,11 @@ export const SnapshotList: React.FunctionComponent { if (search) { From 8d909c674ec6f9aa6c46c9e8e476219bfb9bbc6c Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Mon, 28 Mar 2022 17:16:55 -0400 Subject: [PATCH 7/9] fix tests --- .../__jest__/components/index_table.test.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/index_management/__jest__/components/index_table.test.js b/x-pack/plugins/index_management/__jest__/components/index_table.test.js index f98c891e5f4f5..bf5ab6541bad8 100644 --- a/x-pack/plugins/index_management/__jest__/components/index_table.test.js +++ b/x-pack/plugins/index_management/__jest__/components/index_table.test.js @@ -35,8 +35,10 @@ import { setExtensionsService } from '../../public/application/store/selectors/e import { ExtensionsService } from '../../public/services'; import { kibanaVersion } from '../client_integration/helpers'; -/* eslint-disable @kbn/eslint/no-restricted-paths */ -import { notificationServiceMock } from '../../../../../src/core/public/notifications/notifications_service.mock'; +import { + notificationServiceMock, + executionContextServiceMock, +} from '../../../../../src/core/public/mocks'; const mockHttpClient = axios.create({ adapter: axiosXhrAdapter }); @@ -164,7 +166,14 @@ describe('index table', () => { store = indexManagementStore(services); - const appDependencies = { services, core: {}, plugins: {} }; + const appDependencies = { + services, + core: { + getUrlForApp: () => {}, + executionContext: executionContextServiceMock.createStartContract(), + }, + plugins: {}, + }; component = ( From 0b7ee9c1dd50d53bce6ba6d1218fb6704d1e03f8 Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Tue, 29 Mar 2022 08:09:32 -0400 Subject: [PATCH 8/9] address review feedback --- src/core/public/mocks.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/public/mocks.ts b/src/core/public/mocks.ts index ef53e7ee0185e..855e3e6c18345 100644 --- a/src/core/public/mocks.ts +++ b/src/core/public/mocks.ts @@ -26,10 +26,10 @@ import { savedObjectsServiceMock } from './saved_objects/saved_objects_service.m import { injectedMetadataServiceMock } from './injected_metadata/injected_metadata_service.mock'; import { deprecationsServiceMock } from './deprecations/deprecations_service.mock'; import { themeServiceMock } from './theme/theme_service.mock'; +import { executionContextServiceMock } from './execution_context/execution_context_service.mock'; export { chromeServiceMock } from './chrome/chrome_service.mock'; export { docLinksServiceMock } from './doc_links/doc_links_service.mock'; -import { executionContextServiceMock } from './execution_context/execution_context_service.mock'; export { executionContextServiceMock } from './execution_context/execution_context_service.mock'; export { fatalErrorsServiceMock } from './fatal_errors/fatal_errors_service.mock'; export { httpServiceMock } from './http/http_service.mock'; From ddf44120aafec7046b00a05d05d493e9bef80b21 Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Tue, 29 Mar 2022 13:16:27 -0400 Subject: [PATCH 9/9] address review feedback --- .../component_template_list_container.tsx | 2 +- .../sections/home/data_stream_list/data_stream_list.tsx | 2 +- .../public/application/sections/home/index_list/index_list.tsx | 2 +- .../application/sections/home/template_list/template_list.tsx | 2 +- .../application/sections/home/policy_list/policy_list.tsx | 2 +- .../sections/home/repository_list/repository_list.tsx | 2 +- .../application/sections/home/restore_list/restore_list.tsx | 2 +- .../application/sections/home/snapshot_list/snapshot_list.tsx | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/index_management/public/application/components/component_templates/component_template_list/component_template_list_container.tsx b/x-pack/plugins/index_management/public/application/components/component_templates/component_template_list/component_template_list_container.tsx index 556face8f0986..fea0eb8545b76 100644 --- a/x-pack/plugins/index_management/public/application/components/component_templates/component_template_list/component_template_list_container.tsx +++ b/x-pack/plugins/index_management/public/application/components/component_templates/component_template_list/component_template_list_container.tsx @@ -30,7 +30,7 @@ export const ComponentTemplateListContainer: React.FunctionComponent< useExecutionContext(executionContext, { type: 'application', - page: 'indexManagementComponentTemplates', + page: 'indexManagementComponentTemplatesTab', }); return ( diff --git a/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/data_stream_list.tsx b/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/data_stream_list.tsx index 744c8c455718c..a9e21c4d28bbb 100644 --- a/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/data_stream_list.tsx +++ b/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/data_stream_list.tsx @@ -63,7 +63,7 @@ export const DataStreamList: React.FunctionComponent = ({ histor useExecutionContext(executionContext, { type: 'application', - page: 'indexManagementIndices', + page: 'indexManagementIndicesTab', }); return ( diff --git a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_list.tsx b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_list.tsx index 437888b993674..c29fbfde16f5d 100644 --- a/x-pack/plugins/index_management/public/application/sections/home/template_list/template_list.tsx +++ b/x-pack/plugins/index_management/public/application/sections/home/template_list/template_list.tsx @@ -77,7 +77,7 @@ export const TemplateList: React.FunctionComponent>({ diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_list.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_list.tsx index 7adb69ada4da6..c2a8449a2bc94 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_list.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_list.tsx @@ -89,7 +89,7 @@ export const PolicyList: React.FunctionComponent { useExecutionContext(core.executionContext, { type: 'application', - page: 'snapshotRestoreRestores', + page: 'snapshotRestoreRestoreTab', }); let content: JSX.Element; diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_list.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_list.tsx index 794d74130fd67..bfc276410ebc6 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_list.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_list.tsx @@ -83,7 +83,7 @@ export const SnapshotList: React.FunctionComponent