Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
13fecc7
Move app to "application" folder
Feb 5, 2020
a566571
Remove legacy dependencies
Feb 6, 2020
f7b41a0
Refactor UiMetricService to follow np setup() pattern
Feb 6, 2020
e249d54
Add unmount() handler
Feb 6, 2020
6773b15
Provide UiMetricService through app context
Feb 6, 2020
78af8fc
Use uiMetricService instance from setup() in store reducer
Feb 6, 2020
0985aa3
Create class for IndexManagementExtensions
Feb 6, 2020
b0b2258
Refactor DetailPanel to functional component
Feb 7, 2020
77a2700
Provide extensions service to renderBadges()
Feb 7, 2020
b786f42
Refactor naming to ExtensionsService
Feb 7, 2020
9a0071b
Expose and consume ExtensionsService through app context
Feb 7, 2020
7d65680
Rename extensions service file name
Feb 7, 2020
9b9f740
Align on "setup()" name to initialize services
Feb 7, 2020
53c2fe3
Fix store dependencies
Feb 7, 2020
dc1ee41
Fix tests for index table
Feb 7, 2020
172bccb
Fix component integration tests
Feb 10, 2020
f1629fa
Refactor to use ExtensionsService from other plugins
Feb 10, 2020
98333eb
Remove unnecessary "register_routes" file
Feb 11, 2020
dd7ac26
Provide core and plugins deps to the app dependencies
Feb 11, 2020
d5ef537
Add "Service" suffix to app dependencies
Feb 11, 2020
91e3f83
Fix service dependency name
Feb 11, 2020
23a210c
Export "extensionsService" instead of "extensions"
Feb 11, 2020
0303cc5
Fix tests app dependencies
Feb 11, 2020
e6142ce
Fix tests app dependencies (2)
Feb 11, 2020
2896ee1
Fix TS issue
Feb 11, 2020
9bfdb03
Fix TS issue (2)
Feb 11, 2020
f649890
Fix test dependencies (3)
Feb 11, 2020
be6ce0a
Rename extensions.ts to extensions_service.ts
Feb 12, 2020
8d3715b
Export IndexManagementMock for tests
Feb 12, 2020
fc16a70
Expose ManagementAppMountParams from management plugin
Feb 12, 2020
ae32167
Use setBreadcrumbsHandler from management app
Feb 12, 2020
2f1110a
Merge remote-tracking branch 'upstream/master' into np-migration/inde…
Feb 12, 2020
0e9427d
Fix breadcrumbsService setup in tests
Feb 12, 2020
845a666
Merge branch 'master' into np-migration/index-management-public-2
elasticmachine Feb 12, 2020
c927cc1
Merge remote-tracking branch 'upstream/master' into np-migration/inde…
Feb 13, 2020
50836d6
Reenable commented tests
Feb 13, 2020
5ea0f5c
Address CR feedback
Feb 13, 2020
f495a31
Revert `UIM_EDIT_CLICK` import from common constants folder
Feb 13, 2020
eb306e1
Merge remote-tracking branch 'upstream/master' into np-migration/inde…
Feb 13, 2020
aed1ec3
Merge branch 'master' into np-migration/index-management-public-2
elasticmachine Feb 14, 2020
0cef518
Merge branch 'master' into np-migration/index-management-public-2
Feb 15, 2020
a32ac8d
Merge remote-tracking branch 'upstream/master' into np-migration/inde…
Feb 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/plugins/management/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export {
ManagementStart,
RegisterManagementApp,
RegisterManagementAppArgs,
ManagementAppMountParams,
} from './types';
export { ManagementApp } from './management_app';
export { ManagementSection } from './management_section';
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/management/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export type RegisterManagementApp = (managementApp: RegisterManagementAppArgs) =

export type Unmount = () => Promise<void> | void;

interface ManagementAppMountParams {
export interface ManagementAppMountParams {
basePath: string; // base path for setting up your router
element: HTMLElement; // element the section should render into
setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from '@kbn/i18n/react';
import { getIndexListUri } from '../../../../../../../../index_management/public/app/services/navigation';
import { getIndexListUri } from '../../../../../../../../index_management/public/application/services/navigation';

import {
EuiButtonEmpty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from '@kbn/i18n/react';
import { getIndexListUri } from '../../../../../../../../index_management/public/app/services/navigation';
import { getIndexListUri } from '../../../../../../../../index_management/public/application/services/navigation';

import {
EuiButton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { i18n } from '@kbn/i18n';
import { addBadgeExtension } from '../../../index_management/public/index_management_extensions';
import { extensionsService } from '../../../index_management/public';
import { get } from 'lodash';

const propertyPath = 'isFollowerIndex';
Expand All @@ -19,4 +19,4 @@ export const followerBadgeExtension = {
filterExpression: 'isFollowerIndex:true',
};

addBadgeExtension(followerBadgeExtension);
extensionsService.addBadge(followerBadgeExtension);
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import moment from 'moment-timezone';
import axios from 'axios';
import axiosXhrAdapter from 'axios/lib/adapters/xhr';

import { mountWithIntl } from '../../../../test_utils/enzyme_helpers';
import {
retryLifecycleActionExtension,
Expand All @@ -26,6 +27,10 @@ initHttp(axios.create({ adapter: axiosXhrAdapter }), path => path);
initUiMetric(() => () => {});

jest.mock('ui/new_platform');
jest.mock('../../index_management/public', async () => {
const { indexManagementMock } = await import('../../index_management/public/mocks.ts');
return indexManagementMock.createSetup();
});

const indexWithoutLifecyclePolicy = {
health: 'yellow',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {

import { RIGHT_ALIGNMENT } from '@elastic/eui/lib/services';

import { getIndexListUri } from '../../../../../../../../index_management/public/app/services/navigation';
import { getIndexListUri } from '../../../../../../../../index_management/public/application/services/navigation';
import { BASE_PATH } from '../../../../../../../common/constants';
import { UIM_EDIT_CLICK } from '../../../../constants';
import { getPolicyPath } from '../../../../services/navigation';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ import { get, every, any } from 'lodash';
import { i18n } from '@kbn/i18n';
import { EuiSearchBar } from '@elastic/eui';

import {
addSummaryExtension,
addBannerExtension,
addActionExtension,
addFilterExtension,
} from '../../../../index_management/public/index_management_extensions';

import { extensionsService } from '../../../../index_management/public';
import { init as initUiMetric } from '../application/services/ui_metric';
import { init as initNotification } from '../application/services/notification';
import { retryLifecycleForIndex } from '../application/services/api';
Expand All @@ -27,13 +21,17 @@ const stepPath = 'ilm.step';

export const retryLifecycleActionExtension = ({
indices,
createUiStatsReporter,
usageCollection,
toasts,
fatalErrors,
}) => {
// These are hacks that we can remove once the New Platform migration is done. They're needed here
// because API requests and API errors require them.
initUiMetric(createUiStatsReporter);
const getLegacyReporter = appName => (type, name) => {
usageCollection.reportUiStats(appName, type, name);
};

initUiMetric(getLegacyReporter);
initNotification(toasts, fatalErrors);

const allHaveErrors = every(indices, index => {
Expand Down Expand Up @@ -207,11 +205,11 @@ export const ilmFilterExtension = indices => {
};

export const addAllExtensions = () => {
addActionExtension(retryLifecycleActionExtension);
addActionExtension(removeLifecyclePolicyActionExtension);
addActionExtension(addLifecyclePolicyActionExtension);
extensionsService.addAction(retryLifecycleActionExtension);
extensionsService.addAction(removeLifecyclePolicyActionExtension);
extensionsService.addAction(addLifecyclePolicyActionExtension);

addBannerExtension(ilmBannerExtension);
addSummaryExtension(ilmSummaryExtension);
addFilterExtension(ilmFilterExtension);
extensionsService.addBanner(ilmBannerExtension);
extensionsService.addSummary(ilmSummaryExtension);
extensionsService.addFilter(ilmFilterExtension);
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@ import {
findTestSubject,
nextTick,
} from '../../../../../../test_utils';
import { IndexManagementHome } from '../../../public/app/sections/home';
import { IndexManagementHome } from '../../../public/application/sections/home';
import { BASE_PATH } from '../../../common/constants';
import { indexManagementStore } from '../../../public/app/store';
import { indexManagementStore } from '../../../public/application/store';
import { Template } from '../../../common/types';
import { WithAppDependencies, services } from './setup_environment';

const testBedConfig: TestBedConfig = {
store: indexManagementStore,
store: () => indexManagementStore(services as any),
memoryRouter: {
initialEntries: [`${BASE_PATH}indices`],
componentRoutePath: `${BASE_PATH}:section(indices|templates)`,
},
doMountAsync: true,
};

const initTestBed = registerTestBed(IndexManagementHome, testBedConfig);
const initTestBed = registerTestBed(WithAppDependencies(IndexManagementHome), testBedConfig);

export interface IdxMgmtHomeTestBed extends TestBed<IdxMgmtTestSubjects> {
findAction: (action: 'edit' | 'clone' | 'delete') => ReactWrapper;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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 axios from 'axios';
import axiosXhrAdapter from 'axios/lib/adapters/xhr';

import {
notificationServiceMock,
docLinksServiceMock,
} from '../../../../../../../src/core/public/mocks';
import { AppContextProvider } from '../../../public/application/app_context';
import { httpService } from '../../../public/application/services/http';
import { breadcrumbService } from '../../../public/application/services/breadcrumbs';
import { documentationService } from '../../../public/application/services/documentation';
import { notificationService } from '../../../public/application/services/notification';
import { ExtensionsService } from '../../../public/services';
import { UiMetricService } from '../../../public/application/services/ui_metric';
import { setUiMetricService } from '../../../public/application/services/api';
import { setExtensionsService } from '../../../public/application/store/selectors';
import { init as initHttpRequests } from './http_requests';

const mockHttpClient = axios.create({ adapter: axiosXhrAdapter });

export const services = {
extensionsService: new ExtensionsService(),
uiMetricService: new UiMetricService('index_management'),
};
services.uiMetricService.setup({ reportUiStats() {} } as any);
setExtensionsService(services.extensionsService);
setUiMetricService(services.uiMetricService);
const appDependencies = { services, core: {}, plugins: {} } as any;

export const setupEnvironment = () => {
// Mock initialization of services
// @ts-ignore
httpService.setup(mockHttpClient);
Copy link
Copy Markdown
Contributor

@alisonelizabeth alisonelizabeth Feb 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you import the HttpService and use it instead of axios? Something like this:

  const httpServiceSetupMock = new HttpService().setup({
    injectedMetadata: injectedMetadataServiceMock.createSetupContract(),
    fatalErrors: fatalErrorsServiceMock.createSetupContract(),
  });

  httpService.setup(httpServiceSetupMock);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I ended up trying with

// httpServiceMock.createSetupContract() returns an HttpSetupMock from core
httpService.setup(httpServiceMock.createSetupContract());

but this breaks our tests. Probably because our sinon.fakeServer() requires a real http client like axios`. Will need to be investigated and changed in all our apps later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I did get this working for remote_clusters (PR: #57365). I did have to adjust the timeouts though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Did you try by providing directly the httpServiceMock.createSetupContract()) from core?

breadcrumbService.setup(() => undefined);
documentationService.setup(docLinksServiceMock.createStartContract());
notificationService.setup(notificationServiceMock.createSetupContract());

const { server, httpRequestsMockHelpers } = initHttpRequests();

return {
server,
httpRequestsMockHelpers,
};
};

export const WithAppDependencies = (Comp: any) => (props: any) => (
<AppContextProvider value={appDependencies}>
<Comp {...props} />
</AppContextProvider>
);
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

import { registerTestBed, TestBedConfig } from '../../../../../../test_utils';
import { BASE_PATH } from '../../../common/constants';
import { TemplateClone } from '../../../public/app/sections/template_clone';
import { TemplateClone } from '../../../public/application/sections/template_clone';
import { formSetup } from './template_form.helpers';
import { TEMPLATE_NAME } from './constants';
import { WithAppDependencies } from './setup_environment';

const testBedConfig: TestBedConfig = {
memoryRouter: {
Expand All @@ -18,6 +19,6 @@ const testBedConfig: TestBedConfig = {
doMountAsync: true,
};

const initTestBed = registerTestBed(TemplateClone, testBedConfig);
const initTestBed = registerTestBed(WithAppDependencies(TemplateClone), testBedConfig);

export const setup = formSetup.bind(null, initTestBed);
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

import { registerTestBed, TestBedConfig } from '../../../../../../test_utils';
import { BASE_PATH } from '../../../common/constants';
import { TemplateCreate } from '../../../public/app/sections/template_create';
import { TemplateCreate } from '../../../public/application/sections/template_create';
import { formSetup, TestSubjects } from './template_form.helpers';
import { WithAppDependencies } from './setup_environment';

const testBedConfig: TestBedConfig = {
memoryRouter: {
Expand All @@ -17,6 +18,9 @@ const testBedConfig: TestBedConfig = {
doMountAsync: true,
};

const initTestBed = registerTestBed<TestSubjects>(TemplateCreate, testBedConfig);
const initTestBed = registerTestBed<TestSubjects>(
WithAppDependencies(TemplateCreate),
testBedConfig
);

export const setup = formSetup.bind(null, initTestBed);
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

import { registerTestBed, TestBedConfig } from '../../../../../../test_utils';
import { BASE_PATH } from '../../../common/constants';
import { TemplateEdit } from '../../../public/app/sections/template_edit';
import { TemplateEdit } from '../../../public/application/sections/template_edit';
import { formSetup, TestSubjects } from './template_form.helpers';
import { TEMPLATE_NAME } from './constants';
import { WithAppDependencies } from './setup_environment';

const testBedConfig: TestBedConfig = {
memoryRouter: {
Expand All @@ -18,6 +19,6 @@ const testBedConfig: TestBedConfig = {
doMountAsync: true,
};

const initTestBed = registerTestBed<TestSubjects>(TemplateEdit, testBedConfig);
const initTestBed = registerTestBed<TestSubjects>(WithAppDependencies(TemplateEdit), testBedConfig);

export const setup = formSetup.bind(null, initTestBed);
Loading