Skip to content

Commit e7d48d1

Browse files
committed
Address Alison's feedback.
- Add link to Index Templates from Data Streams empty prompt and component integration test. - Extend legacy ES client with index templates API and unskip API integration test. - Add comment to unused detail panel file.
1 parent da3706f commit e7d48d1

File tree

7 files changed

+119
-22
lines changed

7 files changed

+119
-22
lines changed

x-pack/plugins/index_management/__jest__/client_integration/helpers/test_subjects.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type TestSubjects =
1111
| 'closeDetailsButton'
1212
| 'createLegacyTemplateButton'
1313
| 'createTemplateButton'
14+
| 'dataStreamsEmptyPromptTemplateLink'
1415
| 'dataStreamTable'
1516
| 'dataStreamTable'
1617
| 'deleteSystemTemplateCallOut'

x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.helpers.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const testBedConfig: TestBedConfig = {
2121
store: () => indexManagementStore(services as any),
2222
memoryRouter: {
2323
initialEntries: [`/indices`],
24-
componentRoutePath: `/:section(indices|data_streams)`,
24+
componentRoutePath: `/:section(indices|data_streams|templates)`,
2525
},
2626
doMountAsync: true,
2727
};
@@ -31,6 +31,7 @@ const initTestBed = registerTestBed(WithAppDependencies(IndexManagementHome), te
3131
export interface DataStreamsTabTestBed extends TestBed<TestSubjects> {
3232
actions: {
3333
goToDataStreamsList: () => void;
34+
clickEmptyPromptIndexTemplateLink: () => void;
3435
clickReloadButton: () => void;
3536
clickIndicesAt: (index: number) => void;
3637
};
@@ -47,6 +48,18 @@ export const setup = async (): Promise<DataStreamsTabTestBed> => {
4748
testBed.find('data_streamsTab').simulate('click');
4849
};
4950

51+
const clickEmptyPromptIndexTemplateLink = async () => {
52+
const { find, component, router } = testBed;
53+
54+
const templateLink = find('dataStreamsEmptyPromptTemplateLink');
55+
56+
await act(async () => {
57+
router.navigateTo(templateLink.props().href!);
58+
});
59+
60+
component.update();
61+
};
62+
5063
const clickReloadButton = () => {
5164
const { find } = testBed;
5265
find('reloadButton').simulate('click');
@@ -68,6 +81,7 @@ export const setup = async (): Promise<DataStreamsTabTestBed> => {
6881
...testBed,
6982
actions: {
7083
goToDataStreamsList,
84+
clickEmptyPromptIndexTemplateLink,
7185
clickReloadButton,
7286
clickIndicesAt,
7387
},

x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ describe('Data Streams tab', () => {
5656
const { actions, component } = testBed;
5757

5858
httpRequestsMockHelpers.setLoadDataStreamsResponse([]);
59+
httpRequestsMockHelpers.setLoadTemplatesResponse({ templates: [], legacyTemplates: [] });
5960

6061
await act(async () => {
6162
actions.goToDataStreamsList();
@@ -70,6 +71,16 @@ describe('Data Streams tab', () => {
7071
expect(exists('sectionLoading')).toBe(false);
7172
expect(exists('emptyPrompt')).toBe(true);
7273
});
74+
75+
test('goes to index templates tab when "Get started" link is clicked', async () => {
76+
const { actions, exists, component } = testBed;
77+
78+
await act(async () => {
79+
actions.clickEmptyPromptIndexTemplateLink();
80+
});
81+
82+
expect(exists('templateList')).toBe(true);
83+
});
7384
});
7485

7586
describe('when there are data streams', () => {

x-pack/plugins/index_management/public/application/sections/home/data_stream_list/data_stream_detail_panel/data_stream_detail_panel.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ interface Props {
2525
onClose: () => void;
2626
}
2727

28+
/**
29+
* NOTE: This currently isn't in use by data_stream_list.tsx because it doesn't contain any
30+
* information that doesn't already exist in the table. We'll use it once we add additional
31+
* info, e.g. storage size, docs count.
32+
*/
2833
export const DataStreamDetailPanel: React.FunctionComponent<Props> = ({
2934
dataStreamName,
3035
onClose,

x-pack/plugins/index_management/public/application/sections/home/data_stream_list/data_stream_list.tsx

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
import React from 'react';
88
import { RouteComponentProps } from 'react-router-dom';
99
import { FormattedMessage } from '@kbn/i18n/react';
10-
import { EuiTitle, EuiText, EuiSpacer, EuiEmptyPrompt } from '@elastic/eui';
10+
import { i18n } from '@kbn/i18n';
11+
import { EuiTitle, EuiText, EuiSpacer, EuiEmptyPrompt, EuiLink } from '@elastic/eui';
1112
import { ScopedHistory } from 'kibana/public';
1213

14+
import { reactRouterNavigate } from '../../../../shared_imports';
1315
import { SectionError, SectionLoading, Error } from '../../../components';
1416
import { useLoadDataStreams } from '../../../services/api';
1517
import { DataStreamTable } from './data_stream_table';
@@ -32,7 +34,7 @@ export const DataStreamList: React.FunctionComponent<RouteComponentProps<MatchPa
3234
content = (
3335
<SectionLoading>
3436
<FormattedMessage
35-
id="xpack.idxMgmt.dataStreamList.loadingIndexTemplatesDescription"
37+
id="xpack.idxMgmt.dataStreamList.loadingDataStreamsDescription"
3638
defaultMessage="Loading data streams…"
3739
/>
3840
</SectionLoading>
@@ -42,7 +44,7 @@ export const DataStreamList: React.FunctionComponent<RouteComponentProps<MatchPa
4244
<SectionError
4345
title={
4446
<FormattedMessage
45-
id="xpack.idxMgmt.dataStreamList.loadingIndexTemplatesErrorMessage"
47+
id="xpack.idxMgmt.dataStreamList.loadingDataStreamsErrorMessage"
4648
defaultMessage="Error loading data streams"
4749
/>
4850
}
@@ -56,11 +58,33 @@ export const DataStreamList: React.FunctionComponent<RouteComponentProps<MatchPa
5658
title={
5759
<h1 data-test-subj="title">
5860
<FormattedMessage
59-
id="xpack.idxMgmt.dataStreamList.emptyPrompt.noIndexTemplatesTitle"
61+
id="xpack.idxMgmt.dataStreamList.emptyPrompt.noDataStreamsTitle"
6062
defaultMessage="You don't have any data streams yet"
6163
/>
6264
</h1>
6365
}
66+
body={
67+
<p>
68+
<FormattedMessage
69+
id="xpack.idxMgmt.dataStreamList.emptyPrompt.noDataStreamsDescription"
70+
defaultMessage="Data streams represent the latest data in a rollover series. Get started with data streams by creating a {link}."
71+
values={{
72+
link: (
73+
<EuiLink
74+
data-test-subj="dataStreamsEmptyPromptTemplateLink"
75+
{...reactRouterNavigate(history, {
76+
pathname: '/templates',
77+
})}
78+
>
79+
{i18n.translate('xpack.idxMgmt.dataStreamList.emptyPrompt.getStartedLink', {
80+
defaultMessage: 'composable index template',
81+
})}
82+
</EuiLink>
83+
),
84+
}}
85+
/>
86+
</p>
87+
}
6488
data-test-subj="emptyPrompt"
6589
/>
6690
);

x-pack/plugins/index_management/server/client/elasticsearch.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,34 @@ export const elasticsearchJsPlugin = (Client: any, config: any, components: any)
9999
],
100100
method: 'DELETE',
101101
});
102+
103+
// Index templates v2
104+
dataManagement.saveComposableIndexTemplate = ca({
105+
urls: [
106+
{
107+
fmt: '/_index_template/<%=name%>',
108+
req: {
109+
name: {
110+
type: 'string',
111+
},
112+
},
113+
},
114+
],
115+
needBody: true,
116+
method: 'PUT',
117+
});
118+
119+
dataManagement.deleteComposableIndexTemplate = ca({
120+
urls: [
121+
{
122+
fmt: '/_index_template/<%=name%>',
123+
req: {
124+
name: {
125+
type: 'string',
126+
},
127+
},
128+
},
129+
],
130+
method: 'DELETE',
131+
});
102132
};

x-pack/test/api_integration/apis/management/index_management/data_streams.ts

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@ export default function ({ getService }: FtrProviderContext) {
2121

2222
const createDataStream = (name: string) => {
2323
// A data stream requires an index template before it can be created.
24-
return supertest
25-
.post(`${API_BASE_PATH}/index-templates`)
26-
.set('kbn-xsrf', 'xxx')
27-
.send({
24+
return es.dataManagement
25+
.saveComposableIndexTemplate({
2826
name,
29-
indexPatterns: ['*'],
30-
_kbnMeta: {
31-
isLegacy: false,
27+
body: {
28+
index_patterns: ['*'],
29+
template: {
30+
settings: {},
31+
},
32+
data_stream: {
33+
timestamp_field: '@timestamp',
34+
},
3235
},
3336
})
3437
.then(() =>
@@ -39,11 +42,9 @@ export default function ({ getService }: FtrProviderContext) {
3942
};
4043

4144
const deleteDataStream = (name: string) => {
42-
return supertest
43-
.post(`${API_BASE_PATH}/delete-index-templates`)
44-
.set('kbn-xsrf', 'xxx')
45-
.send({
46-
templates: [{ name, isLegacy: false }],
45+
return es.dataManagement
46+
.deleteComposableIndexTemplate({
47+
name,
4748
})
4849
.then(() =>
4950
es.dataManagement.deleteDataStream({
@@ -53,10 +54,11 @@ export default function ({ getService }: FtrProviderContext) {
5354
};
5455

5556
describe('Data streams', function () {
56-
// TODO: Implement this test once the API supports creating composable index templates.
57-
describe.skip('Get', () => {
58-
before(() => createDataStream('test-data-stream'));
59-
after(() => deleteDataStream('test-data-stream'));
57+
const testDataStreamName = 'test-data-stream';
58+
59+
describe('Get', () => {
60+
before(() => createDataStream(testDataStreamName));
61+
after(() => deleteDataStream(testDataStreamName));
6062

6163
describe('all data streams', () => {
6264
it('returns an array of data streams', async () => {
@@ -65,9 +67,19 @@ export default function ({ getService }: FtrProviderContext) {
6567
.set('kbn-xsrf', 'xxx')
6668
.expect(200);
6769

70+
// ES determines this value so we'll just echo it back.
71+
const { uuid } = dataStreams[0].indices[0];
6872
expect(dataStreams).to.eql([
6973
{
70-
name: 'test-data-stream',
74+
name: testDataStreamName,
75+
timeStampField: '@timestamp',
76+
indices: [
77+
{
78+
name: `${testDataStreamName}-000001`,
79+
uuid,
80+
},
81+
],
82+
generation: 1,
7183
},
7284
]);
7385
});

0 commit comments

Comments
 (0)