Skip to content

Commit

Permalink
add execution per tab in SR + IM
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth committed Mar 28, 2022
1 parent a89c2c2 commit 5226a32
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -48,7 +49,10 @@ setUiMetricService(services.uiMetricService);

const appDependencies = {
services,
core: { getUrlForApp: () => {} },
core: {
getUrlForApp: () => {},
executionContext: executionContextServiceMock.createStartContract(),
},
plugins: {},
} as any;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
notificationServiceMock,
docLinksServiceMock,
applicationServiceMock,
executionContextServiceMock,
} from '../../../../../../../../../../src/core/public/mocks';

import { GlobalFlyout } from '../../../../../../../../../../src/plugins/es_ui_shared/public';
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -24,6 +26,13 @@ export const ComponentTemplateListContainer: React.FunctionComponent<
},
history,
}) => {
const { executionContext } = useComponentTemplatesContext();

useExecutionContext(executionContext, {
type: 'application',
page: 'indexManagementComponentTemplates',
});

return (
<ComponentTemplatesAuthProvider>
<ComponentTemplatesWithPrivileges>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -22,6 +28,7 @@ interface Props {
toasts: NotificationsSetup['toasts'];
setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs'];
getUrlForApp: CoreStart['application']['getUrlForApp'];
executionContext: ExecutionContextStart;
}

interface Context {
Expand All @@ -33,6 +40,7 @@ interface Context {
trackMetric: (type: UiCounterMetricType, eventName: string) => void;
toasts: NotificationsSetup['toasts'];
getUrlForApp: CoreStart['application']['getUrlForApp'];
executionContext: ExecutionContextStart;
}

export const ComponentTemplatesProvider = ({
Expand All @@ -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);
Expand All @@ -63,6 +79,7 @@ export const ComponentTemplatesProvider = ({
apiBasePath,
breadcrumbs,
getUrlForApp,
executionContext,
}}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
3 changes: 2 additions & 1 deletion x-pack/plugins/index_management/public/application/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -56,6 +56,7 @@ export const renderApp = (
toasts: notifications.toasts,
setBreadcrumbs,
getUrlForApp: application.getUrlForApp,
executionContext,
};

render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
extractQueryParams,
attemptToURIDecode,
APP_WRAPPER_CLASS,
useExecutionContext,
} from '../../../../shared_imports';
import { useAppContext } from '../../../app_context';
import { useLoadDataStreams } from '../../../services/api';
Expand All @@ -56,10 +57,15 @@ export const DataStreamList: React.FunctionComponent<RouteComponentProps<MatchPa
const decodedDataStreamName = attemptToURIDecode(dataStreamName);

const {
core: { getUrlForApp },
core: { getUrlForApp, executionContext },
plugins: { isFleetEnabled },
} = useAppContext();

useExecutionContext(executionContext, {
type: 'application',
page: 'indexManagementDataStreams',
});

const [isIncludeStatsChecked, setIsIncludeStatsChecked] = useState(false);
const {
error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@
import React from 'react';
import { RouteComponentProps } from 'react-router-dom';

import { APP_WRAPPER_CLASS } from '../../../../shared_imports';
import { APP_WRAPPER_CLASS, useExecutionContext } from '../../../../shared_imports';
import { useAppContext } from '../../../app_context';
import { DetailPanel } from './detail_panel';
import { IndexTable } from './index_table';

export const IndexList: React.FunctionComponent<RouteComponentProps> = ({ history }) => {
const {
core: { executionContext },
} = useAppContext();

useExecutionContext(executionContext, {
type: 'application',
page: 'indexManagementIndices',
});

return (
<div className={`${APP_WRAPPER_CLASS} im-snapshotTestSubject`} data-test-subj="indicesList">
<IndexTable history={history} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -68,8 +69,17 @@ export const TemplateList: React.FunctionComponent<RouteComponentProps<MatchPara
history,
}) => {
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<Filters<FilterName>>({
managed: {
name: i18n.translate('xpack.idxMgmt.indexTemplatesList.viewManagedTemplateLabel', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
Error,
WithPrivileges,
NotAuthorizedSection,
useExecutionContext,
} from '../../../../shared_imports';

import { SlmPolicy } from '../../../../../common/types';
Expand All @@ -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';
Expand All @@ -50,6 +51,7 @@ export const PolicyList: React.FunctionComponent<RouteComponentProps<MatchParams
} = useLoadPolicies();

const { uiMetricService } = useServices();
const { core } = useAppContext();

// Load retention cluster settings
const {
Expand Down Expand Up @@ -85,6 +87,11 @@ export const PolicyList: React.FunctionComponent<RouteComponentProps<MatchParams
uiMetricService.trackUiMetric(UIM_POLICY_LIST_LOAD);
}, [uiMetricService]);

useExecutionContext(core.executionContext, {
type: 'application',
page: 'snapshotRestorePolicies',
});

let content: JSX.Element;

if (isLoading) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { EuiPageContent, EuiButton, EuiEmptyPrompt } from '@elastic/eui';
import { reactRouterNavigate } from '../../../../../../../../src/plugins/kibana_react/public';

import { Repository } from '../../../../../common/types';
import { PageLoading, PageError, Error } from '../../../../shared_imports';
import { PageLoading, PageError, Error, useExecutionContext } from '../../../../shared_imports';
import { useDecodedParams } from '../../../lib';
import { BASE_PATH, UIM_REPOSITORY_LIST_LOAD } from '../../../constants';
import { useServices } from '../../../app_context';
import { useAppContext, useServices } from '../../../app_context';
import { useLoadRepositories } from '../../../services/http';
import { linkToAddRepository, linkToRepository } from '../../../services/navigation';

Expand Down Expand Up @@ -44,6 +44,7 @@ export const RepositoryList: React.FunctionComponent<RouteComponentProps<MatchPa
} = useLoadRepositories();

const { uiMetricService } = useServices();
const { core } = useAppContext();

const openRepositoryDetailsUrl = (newRepositoryName: Repository['name']): string => {
return linkToRepository(newRepositoryName);
Expand All @@ -67,6 +68,11 @@ export const RepositoryList: React.FunctionComponent<RouteComponentProps<MatchPa
uiMetricService.trackUiMetric(UIM_REPOSITORY_LIST_LOAD);
}, [uiMetricService]);

useExecutionContext(core.executionContext, {
type: 'application',
page: 'snapshotRestoreRepositories',
});

let content;

if (isLoading) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ import {
PageError,
PageLoading,
Error,
useExecutionContext,
} from '../../../../shared_imports';
import { UIM_RESTORE_LIST_LOAD } from '../../../constants';
import { useLoadRestores } from '../../../services/http';
import { linkToSnapshots } from '../../../services/navigation';
import { useServices } from '../../../app_context';
import { useAppContext, useServices } from '../../../app_context';
import { RestoreTable } from './restore_table';

import { reactRouterNavigate } from '../../../../../../../../src/plugins/kibana_react/public';
Expand Down Expand Up @@ -63,12 +64,18 @@ export const RestoreList: 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -52,6 +58,7 @@ export const SnapshotList: React.FunctionComponent<RouteComponentProps<MatchPara
} = useLoadSnapshots(listParams);

const { uiMetricService } = useServices();
const { core } = useAppContext();

const closeSnapshotDetails = () => {
history.push(`${BASE_PATH}/snapshots`);
Expand All @@ -74,6 +81,11 @@ export const SnapshotList: React.FunctionComponent<RouteComponentProps<MatchPara
}
};

useExecutionContext(core.executionContext, {
type: 'application',
page: 'snapshotRestoreSnapshots',
});

// Allow deeplinking to list pre-filtered by repository name or by policy name
useEffect(() => {
if (search) {
Expand Down

0 comments on commit 5226a32

Please sign in to comment.