Skip to content

Commit 8727c9d

Browse files
Merge branch 'master' into fix-es-lint-exhaustive-deps-rule
2 parents c09a5be + 4a4d7ce commit 8727c9d

File tree

70 files changed

+1720
-1321
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1720
-1321
lines changed

x-pack/plugins/apm/public/components/shared/Stacktrace/CauseStacktrace.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import React from 'react';
88
import styled from 'styled-components';
99
import { i18n } from '@kbn/i18n';
1010
import { EuiAccordion, EuiTitle } from '@elastic/eui';
11-
import { px, unit } from '../../../style/variables';
11+
import { px, unit, units } from '../../../style/variables';
1212
import { Stacktrace } from '.';
1313
import { Stackframe } from '../../../../typings/es_schemas/raw/fields/stackframe';
1414

1515
// @ts-ignore Styled Components has trouble inferring the types of the default props here.
1616
const Accordion = styled(EuiAccordion)`
1717
border-top: ${({ theme }) => theme.eui.euiBorderThin};
18+
margin-top: ${px(units.half)};
1819
`;
1920

2021
const CausedByContainer = styled('h5')`

x-pack/plugins/apm/public/components/shared/Stacktrace/Stackframe.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const ContextContainer = styled.div<{ isLibraryFrame: boolean }>`
3535

3636
// Indent the non-context frames the same amount as the accordion control
3737
const NoContextFrameHeadingWrapper = styled.div`
38-
margin-left: ${px(units.unit + units.half + units.eighth)};
38+
margin-left: ${px(units.unit + units.half + units.quarter)};
3939
`;
4040

4141
interface Props {
Lines changed: 40 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugins/index_lifecycle_management/__jest__/components/policy_table.test.js renamed to x-pack/plugins/index_lifecycle_management/__jest__/components/policy_table.test.tsx

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,62 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66
import moment from 'moment-timezone';
7-
import React from 'react';
8-
import { Provider } from 'react-redux';
9-
// axios has a $http like interface so using it to simulate $http
10-
import axios from 'axios';
11-
import axiosXhrAdapter from 'axios/lib/adapters/xhr';
12-
import sinon from 'sinon';
7+
import React, { ReactElement } from 'react';
8+
import { ReactWrapper } from 'enzyme';
9+
import { mountWithIntl } from 'test_utils/enzyme_helpers';
1310
import { findTestSubject, takeMountedSnapshot } from '@elastic/eui/lib/test';
1411

15-
import { scopedHistoryMock } from '../../../../../src/core/public/mocks';
16-
import { mountWithIntl } from '../../../../test_utils/enzyme_helpers';
17-
import { fetchedPolicies } from '../../public/application/store/actions';
18-
import { indexLifecycleManagementStore } from '../../public/application/store';
19-
import { PolicyTable } from '../../public/application/sections/policy_table';
12+
import {
13+
fatalErrorsServiceMock,
14+
injectedMetadataServiceMock,
15+
scopedHistoryMock,
16+
} from '../../../../../src/core/public/mocks';
17+
import { HttpService } from '../../../../../src/core/public/http';
18+
import { usageCollectionPluginMock } from '../../../../../src/plugins/usage_collection/public/mocks';
19+
20+
import { PolicyTable } from '../../public/application/sections/policy_table/policy_table';
2021
import { init as initHttp } from '../../public/application/services/http';
2122
import { init as initUiMetric } from '../../public/application/services/ui_metric';
23+
import { PolicyFromES } from '../../public/application/services/policies/types';
2224

23-
initHttp(axios.create({ adapter: axiosXhrAdapter }), (path) => path);
24-
initUiMetric({ reportUiStats: () => {} });
25-
26-
let server = null;
25+
initHttp(
26+
new HttpService().setup({
27+
injectedMetadata: injectedMetadataServiceMock.createSetupContract(),
28+
fatalErrors: fatalErrorsServiceMock.createSetupContract(),
29+
})
30+
);
31+
initUiMetric(usageCollectionPluginMock.createSetupContract());
2732

28-
let store = null;
29-
const policies = [];
33+
const policies: PolicyFromES[] = [];
3034
for (let i = 0; i < 105; i++) {
3135
policies.push({
3236
version: i,
33-
modified_date: moment().subtract(i, 'days').valueOf(),
34-
linkedIndices: i % 2 === 0 ? [`index${i}`] : null,
37+
modified_date: moment().subtract(i, 'days').toISOString(),
38+
linkedIndices: i % 2 === 0 ? [`index${i}`] : undefined,
3539
name: `testy${i}`,
40+
policy: {
41+
name: `testy${i}`,
42+
phases: {},
43+
},
3644
});
3745
}
3846
jest.mock('');
39-
let component = null;
47+
let component: ReactElement;
4048

41-
const snapshot = (rendered) => {
49+
const snapshot = (rendered: string[]) => {
4250
expect(rendered).toMatchSnapshot();
4351
};
44-
const mountedSnapshot = (rendered) => {
52+
const mountedSnapshot = (rendered: ReactWrapper) => {
4553
expect(takeMountedSnapshot(rendered)).toMatchSnapshot();
4654
};
47-
const names = (rendered) => {
55+
const names = (rendered: ReactWrapper) => {
4856
return findTestSubject(rendered, 'policyTablePolicyNameLink');
4957
};
50-
const namesText = (rendered) => {
51-
return names(rendered).map((button) => button.text());
58+
const namesText = (rendered: ReactWrapper): string[] => {
59+
return (names(rendered) as ReactWrapper).map((button) => button.text());
5260
};
5361

54-
const testSort = (headerName) => {
62+
const testSort = (headerName: string) => {
5563
const rendered = mountWithIntl(component);
5664
const nameHeader = findTestSubject(rendered, `policyTableHeaderCell-${headerName}`).find(
5765
'button'
@@ -63,7 +71,7 @@ const testSort = (headerName) => {
6371
rendered.update();
6472
snapshot(namesText(rendered));
6573
};
66-
const openContextMenu = (buttonIndex) => {
74+
const openContextMenu = (buttonIndex: number) => {
6775
const rendered = mountWithIntl(component);
6876
const actionsButton = findTestSubject(rendered, 'policyActionsContextMenuButton');
6977
actionsButton.at(buttonIndex).simulate('click');
@@ -73,33 +81,26 @@ const openContextMenu = (buttonIndex) => {
7381

7482
describe('policy table', () => {
7583
beforeEach(() => {
76-
store = indexLifecycleManagementStore();
7784
component = (
78-
<Provider store={store}>
79-
<PolicyTable history={scopedHistoryMock.create()} navigateToApp={() => {}} />
80-
</Provider>
85+
<PolicyTable
86+
policies={policies}
87+
history={scopedHistoryMock.create()}
88+
navigateToApp={jest.fn()}
89+
updatePolicies={jest.fn()}
90+
/>
8191
);
82-
store.dispatch(fetchedPolicies(policies));
83-
server = sinon.fakeServer.create();
84-
server.respondWith('/api/index_lifecycle_management/policies', [
85-
200,
86-
{ 'Content-Type': 'application/json' },
87-
JSON.stringify(policies),
88-
]);
8992
});
90-
test('should show spinner when policies are loading', () => {
91-
store = indexLifecycleManagementStore();
93+
94+
test('should show empty state when there are not any policies', () => {
9295
component = (
93-
<Provider store={store}>
94-
<PolicyTable history={scopedHistoryMock.create()} navigateToApp={() => {}} />
95-
</Provider>
96+
<PolicyTable
97+
policies={[]}
98+
history={scopedHistoryMock.create()}
99+
navigateToApp={jest.fn()}
100+
updatePolicies={jest.fn()}
101+
/>
96102
);
97103
const rendered = mountWithIntl(component);
98-
expect(rendered.find('.euiLoadingSpinner').exists()).toBeTruthy();
99-
});
100-
test('should show empty state when there are not any policies', () => {
101-
store.dispatch(fetchedPolicies([]));
102-
const rendered = mountWithIntl(component);
103104
mountedSnapshot(rendered);
104105
});
105106
test('should change pages when a pagination link is clicked on', () => {
@@ -123,7 +124,7 @@ describe('policy table', () => {
123124
test('should filter based on content of search input', () => {
124125
const rendered = mountWithIntl(component);
125126
const searchInput = rendered.find('.euiFieldSearch').first();
126-
searchInput.instance().value = 'testy0';
127+
((searchInput.instance() as unknown) as HTMLInputElement).value = 'testy0';
127128
searchInput.simulate('keyup', { key: 'Enter', keyCode: 13, which: 13 });
128129
rendered.update();
129130
snapshot(namesText(rendered));
@@ -147,15 +148,15 @@ describe('policy table', () => {
147148
expect(buttons.at(0).text()).toBe('View indices linked to policy');
148149
expect(buttons.at(1).text()).toBe('Add policy to index template');
149150
expect(buttons.at(2).text()).toBe('Delete policy');
150-
expect(buttons.at(2).getDOMNode().disabled).toBeTruthy();
151+
expect((buttons.at(2).getDOMNode() as HTMLButtonElement).disabled).toBeTruthy();
151152
});
152153
test('should have proper actions in context menu when there are not linked indices', () => {
153154
const rendered = openContextMenu(1);
154155
const buttons = rendered.find('button.euiContextMenuItem');
155156
expect(buttons.length).toBe(2);
156157
expect(buttons.at(0).text()).toBe('Add policy to index template');
157158
expect(buttons.at(1).text()).toBe('Delete policy');
158-
expect(buttons.at(1).getDOMNode().disabled).toBeFalsy();
159+
expect((buttons.at(1).getDOMNode() as HTMLButtonElement).disabled).toBeFalsy();
159160
});
160161
test('confirmation modal should show when delete button is pressed', () => {
161162
const rendered = openContextMenu(1);

x-pack/plugins/index_lifecycle_management/public/application/index.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66

77
import React from 'react';
88
import { render, unmountComponentAtNode } from 'react-dom';
9-
import { Provider } from 'react-redux';
109
import { I18nStart, ScopedHistory, ApplicationStart } from 'kibana/public';
1110
import { UnmountCallback } from 'src/core/public';
1211

1312
import { App } from './app';
14-
import { indexLifecycleManagementStore } from './store';
1513

1614
export const renderApp = (
1715
element: Element,
@@ -22,9 +20,7 @@ export const renderApp = (
2220
): UnmountCallback => {
2321
render(
2422
<I18nContext>
25-
<Provider store={indexLifecycleManagementStore()}>
26-
<App history={history} navigateToApp={navigateToApp} getUrlForApp={getUrlForApp} />
27-
</Provider>
23+
<App history={history} navigateToApp={navigateToApp} getUrlForApp={getUrlForApp} />
2824
</I18nContext>,
2925
element
3026
);

x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.container.tsx

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import React from 'react';
88
import { RouteComponentProps } from 'react-router-dom';
9-
import { EuiButton, EuiCallOut, EuiEmptyPrompt, EuiLoadingSpinner } from '@elastic/eui';
9+
import { EuiButton, EuiEmptyPrompt, EuiLoadingSpinner } from '@elastic/eui';
1010
import { FormattedMessage } from '@kbn/i18n/react';
1111
import { useLoadPoliciesList } from '../../services/api';
1212

@@ -50,25 +50,29 @@ export const EditPolicy: React.FunctionComponent<Props & RouteComponentProps<Rou
5050
if (error || !policies) {
5151
const { statusCode, message } = error ? error : { statusCode: '', message: '' };
5252
return (
53-
<EuiCallOut
53+
<EuiEmptyPrompt
5454
title={
55-
<FormattedMessage
56-
id="xpack.indexLifecycleMgmt.editPolicy.lifecyclePoliciesLoadingFailedTitle"
57-
defaultMessage="Unable to load existing lifecycle policies"
58-
/>
55+
<h2>
56+
<FormattedMessage
57+
id="xpack.indexLifecycleMgmt.editPolicy.lifecyclePoliciesLoadingFailedTitle"
58+
defaultMessage="Unable to load existing lifecycle policies"
59+
/>
60+
</h2>
5961
}
60-
color="danger"
61-
>
62-
<p>
63-
{message} ({statusCode})
64-
</p>
65-
<EuiButton onClick={sendRequest} iconType="refresh" color="danger">
66-
<FormattedMessage
67-
id="xpack.indexLifecycleMgmt.editPolicy.lifecyclePoliciesReloadButton"
68-
defaultMessage="Try again"
69-
/>
70-
</EuiButton>
71-
</EuiCallOut>
62+
body={
63+
<p>
64+
{message} ({statusCode})
65+
</p>
66+
}
67+
actions={
68+
<EuiButton onClick={sendRequest} iconType="refresh" color="danger">
69+
<FormattedMessage
70+
id="xpack.indexLifecycleMgmt.editPolicy.lifecyclePoliciesReloadButton"
71+
defaultMessage="Try again"
72+
/>
73+
</EuiButton>
74+
}
75+
/>
7276
);
7377
}
7478

0 commit comments

Comments
 (0)