Skip to content

Commit eec9cb7

Browse files
authored
Fixes index pattern wizard when there are remote clusters but no local indices (#24339) (#25613)
* don't hide wizard if clusters exist * catch errors * add toast notifs if unable to load data
1 parent 2cd965e commit eec9cb7

File tree

13 files changed

+402
-118
lines changed

13 files changed

+402
-118
lines changed

src/core_plugins/kibana/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { managementApi } from './server/routes/api/management';
3030
import { scriptsApi } from './server/routes/api/scripts';
3131
import { registerSuggestionsApi } from './server/routes/api/suggestions';
3232
import { registerKqlTelemetryApi } from './server/routes/api/kql_telemetry';
33+
import { registerClustersRoute } from './server/routes/api/remote_info';
3334
import { registerFieldFormats } from './server/field_formats/register';
3435
import { registerTutorials } from './server/tutorials/register';
3536
import * as systemApi from './server/lib/system_api';
@@ -167,6 +168,7 @@ export default function (kibana) {
167168
registerFieldFormats(server);
168169
registerTutorials(server);
169170
makeKQLUsageCollector(server);
171+
registerClustersRoute(server);
170172
server.expose('systemApi', systemApi);
171173
server.expose('handleEsError', handleEsError);
172174
server.injectUiAppVars('kibana', () => injectVars(server));
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,205 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`CreateIndexPatternWizard defaults to the loading state 1`] = `
4-
<div>
5-
<Header
6-
indexPatternName="name"
7-
isBeta={false}
8-
isIncludingSystemIndices={false}
9-
onChangeIncludingSystemIndices={[Function]}
10-
showSystemIndices={false}
4+
<React.Fragment>
5+
<div>
6+
<Header
7+
indexPatternName="name"
8+
isBeta={false}
9+
isIncludingSystemIndices={false}
10+
onChangeIncludingSystemIndices={[Function]}
11+
showSystemIndices={false}
12+
/>
13+
<LoadingState />
14+
</div>
15+
<EuiGlobalToastList
16+
dismissToast={[Function]}
17+
toastLifeTimeMs={6000}
18+
toasts={Array []}
1119
/>
12-
<LoadingState />
13-
</div>
20+
</React.Fragment>
1421
`;
1522

1623
exports[`CreateIndexPatternWizard renders index pattern step when there are indices 1`] = `
17-
<div>
18-
<Header
19-
indexPatternName="name"
20-
isBeta={false}
21-
isIncludingSystemIndices={false}
22-
onChangeIncludingSystemIndices={[Function]}
23-
showSystemIndices={false}
24-
/>
25-
<StepIndexPattern
26-
allIndices={
27-
Array [
24+
<React.Fragment>
25+
<div>
26+
<Header
27+
indexPatternName="name"
28+
isBeta={false}
29+
isIncludingSystemIndices={false}
30+
onChangeIncludingSystemIndices={[Function]}
31+
showSystemIndices={false}
32+
/>
33+
<StepIndexPattern
34+
allIndices={
35+
Array [
36+
Object {
37+
"name": "myIndexPattern",
38+
},
39+
]
40+
}
41+
esService={Object {}}
42+
goToNextStep={[Function]}
43+
indexPatternCreationType={
2844
Object {
29-
"name": "myIndexPattern",
30-
},
31-
]
32-
}
33-
esService={Object {}}
34-
goToNextStep={[Function]}
35-
indexPatternCreationType={
36-
Object {
37-
"checkIndicesForErrors": [Function],
38-
"getIndexPatternMappings": [Function],
39-
"getIndexPatternName": [Function],
40-
"getIndexPatternType": [Function],
41-
"getIsBeta": [Function],
42-
"getShowSystemIndices": [Function],
43-
"renderPrompt": [Function],
45+
"checkIndicesForErrors": [Function],
46+
"getIndexPatternMappings": [Function],
47+
"getIndexPatternName": [Function],
48+
"getIndexPatternType": [Function],
49+
"getIsBeta": [Function],
50+
"getShowSystemIndices": [Function],
51+
"renderPrompt": [Function],
52+
}
4453
}
45-
}
46-
initialQuery=""
47-
isIncludingSystemIndices={false}
48-
savedObjectsClient={Object {}}
54+
initialQuery=""
55+
isIncludingSystemIndices={false}
56+
savedObjectsClient={Object {}}
57+
/>
58+
</div>
59+
<EuiGlobalToastList
60+
dismissToast={[Function]}
61+
toastLifeTimeMs={6000}
62+
toasts={Array []}
4963
/>
50-
</div>
64+
</React.Fragment>
5165
`;
5266

5367
exports[`CreateIndexPatternWizard renders the empty state when there are no indices 1`] = `
54-
<div>
55-
<Header
56-
indexPatternName="name"
57-
isBeta={false}
58-
isIncludingSystemIndices={false}
59-
onChangeIncludingSystemIndices={[Function]}
60-
showSystemIndices={false}
61-
/>
62-
<EmptyState
63-
onRefresh={[Function]}
68+
<React.Fragment>
69+
<div>
70+
<Header
71+
indexPatternName="name"
72+
isBeta={false}
73+
isIncludingSystemIndices={false}
74+
onChangeIncludingSystemIndices={[Function]}
75+
showSystemIndices={false}
76+
/>
77+
<EmptyState
78+
onRefresh={[Function]}
79+
/>
80+
</div>
81+
<EuiGlobalToastList
82+
dismissToast={[Function]}
83+
toastLifeTimeMs={6000}
84+
toasts={Array []}
6485
/>
65-
</div>
86+
</React.Fragment>
6687
`;
6788

6889
exports[`CreateIndexPatternWizard renders time field step when step is set to 2 1`] = `
69-
<div>
70-
<Header
71-
indexPatternName="name"
72-
isBeta={false}
73-
isIncludingSystemIndices={false}
74-
onChangeIncludingSystemIndices={[Function]}
75-
showSystemIndices={false}
90+
<React.Fragment>
91+
<div>
92+
<Header
93+
indexPatternName="name"
94+
isBeta={false}
95+
isIncludingSystemIndices={false}
96+
onChangeIncludingSystemIndices={[Function]}
97+
showSystemIndices={false}
98+
/>
99+
<StepTimeField
100+
createIndexPattern={[Function]}
101+
goToPreviousStep={[Function]}
102+
indexPattern=""
103+
indexPatternCreationType={
104+
Object {
105+
"checkIndicesForErrors": [Function],
106+
"getIndexPatternMappings": [Function],
107+
"getIndexPatternName": [Function],
108+
"getIndexPatternType": [Function],
109+
"getIsBeta": [Function],
110+
"getShowSystemIndices": [Function],
111+
"renderPrompt": [Function],
112+
}
113+
}
114+
indexPatternsService={Object {}}
115+
/>
116+
</div>
117+
<EuiGlobalToastList
118+
dismissToast={[Function]}
119+
toastLifeTimeMs={6000}
120+
toasts={Array []}
76121
/>
77-
<StepTimeField
78-
createIndexPattern={[Function]}
79-
goToPreviousStep={[Function]}
80-
indexPattern=""
81-
indexPatternCreationType={
82-
Object {
83-
"checkIndicesForErrors": [Function],
84-
"getIndexPatternMappings": [Function],
85-
"getIndexPatternName": [Function],
86-
"getIndexPatternType": [Function],
87-
"getIsBeta": [Function],
88-
"getShowSystemIndices": [Function],
89-
"renderPrompt": [Function],
122+
</React.Fragment>
123+
`;
124+
125+
exports[`CreateIndexPatternWizard renders when there are no indices but there are remote clusters 1`] = `
126+
<React.Fragment>
127+
<div>
128+
<Header
129+
indexPatternName="name"
130+
isBeta={false}
131+
isIncludingSystemIndices={false}
132+
onChangeIncludingSystemIndices={[Function]}
133+
showSystemIndices={false}
134+
/>
135+
<StepIndexPattern
136+
allIndices={Array []}
137+
esService={Object {}}
138+
goToNextStep={[Function]}
139+
indexPatternCreationType={
140+
Object {
141+
"checkIndicesForErrors": [Function],
142+
"getIndexPatternMappings": [Function],
143+
"getIndexPatternName": [Function],
144+
"getIndexPatternType": [Function],
145+
"getIsBeta": [Function],
146+
"getShowSystemIndices": [Function],
147+
"renderPrompt": [Function],
148+
}
90149
}
91-
}
92-
indexPatternsService={Object {}}
150+
initialQuery=""
151+
isIncludingSystemIndices={false}
152+
savedObjectsClient={Object {}}
153+
/>
154+
</div>
155+
<EuiGlobalToastList
156+
dismissToast={[Function]}
157+
toastLifeTimeMs={6000}
158+
toasts={Array []}
93159
/>
94-
</div>
160+
</React.Fragment>
95161
`;
96162

97163
exports[`CreateIndexPatternWizard shows system indices even if there are no other indices if the include system indices is toggled 1`] = `
98-
<div>
99-
<Header
100-
indexPatternName="name"
101-
isBeta={false}
102-
isIncludingSystemIndices={true}
103-
onChangeIncludingSystemIndices={[Function]}
104-
showSystemIndices={false}
105-
/>
106-
<StepIndexPattern
107-
allIndices={
108-
Array [
164+
<React.Fragment>
165+
<div>
166+
<Header
167+
indexPatternName="name"
168+
isBeta={false}
169+
isIncludingSystemIndices={true}
170+
onChangeIncludingSystemIndices={[Function]}
171+
showSystemIndices={false}
172+
/>
173+
<StepIndexPattern
174+
allIndices={
175+
Array [
176+
Object {
177+
"name": ".kibana ",
178+
},
179+
]
180+
}
181+
esService={Object {}}
182+
goToNextStep={[Function]}
183+
indexPatternCreationType={
109184
Object {
110-
"name": ".kibana ",
111-
},
112-
]
113-
}
114-
esService={Object {}}
115-
goToNextStep={[Function]}
116-
indexPatternCreationType={
117-
Object {
118-
"checkIndicesForErrors": [Function],
119-
"getIndexPatternMappings": [Function],
120-
"getIndexPatternName": [Function],
121-
"getIndexPatternType": [Function],
122-
"getIsBeta": [Function],
123-
"getShowSystemIndices": [Function],
124-
"renderPrompt": [Function],
185+
"checkIndicesForErrors": [Function],
186+
"getIndexPatternMappings": [Function],
187+
"getIndexPatternName": [Function],
188+
"getIndexPatternType": [Function],
189+
"getIsBeta": [Function],
190+
"getShowSystemIndices": [Function],
191+
"renderPrompt": [Function],
192+
}
125193
}
126-
}
127-
initialQuery=""
128-
isIncludingSystemIndices={true}
129-
savedObjectsClient={Object {}}
194+
initialQuery=""
195+
isIncludingSystemIndices={true}
196+
savedObjectsClient={Object {}}
197+
/>
198+
</div>
199+
<EuiGlobalToastList
200+
dismissToast={[Function]}
201+
toastLifeTimeMs={6000}
202+
toasts={Array []}
130203
/>
131-
</div>
204+
</React.Fragment>
132205
`;

src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/__tests__/create_index_pattern_wizard.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jest.mock('../lib/get_indices', () => ({
4242
];
4343
},
4444
}));
45+
jest.mock('ui/chrome', () => ({
46+
addBasePath: () => { },
47+
}));
4548

4649
const loadingDataDocUrl = '';
4750
const initialQuery = '';
@@ -80,6 +83,26 @@ describe('CreateIndexPatternWizard', () => {
8083
component.setState({
8184
isInitiallyLoadingIndices: false,
8285
allIndices: [],
86+
remoteClustersExist: false
87+
});
88+
89+
await component.update();
90+
expect(component).toMatchSnapshot();
91+
});
92+
93+
it('renders when there are no indices but there are remote clusters', async () => {
94+
const component = shallow(
95+
<CreateIndexPatternWizard
96+
loadingDataDocUrl={loadingDataDocUrl}
97+
initialQuery={initialQuery}
98+
services={services}
99+
/>
100+
);
101+
102+
component.setState({
103+
isInitiallyLoadingIndices: false,
104+
allIndices: [],
105+
remoteClustersExist: true
83106
});
84107

85108
await component.update();

src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/__tests__/render.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jest.mock('ui/chrome', () => ({
3232
getUiSettingsClient: () => ({
3333
get: () => '',
3434
}),
35+
addBasePath: () => { },
3536
}));
3637

3738
const { renderCreateIndexPatternWizard, destroyCreateIndexPatternWizard } = require('../render');

src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/__tests__/step_index_pattern.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jest.mock('ui/chrome', () => ({
4141
getUiSettingsClient: () => ({
4242
get: () => '',
4343
}),
44+
addBasePath: () => { },
4445
}));
4546

4647
jest.mock('../../../lib/get_indices', () => ({
@@ -62,7 +63,7 @@ const esService = {};
6263
const savedObjectsClient = {
6364
find: () => ({ savedObjects: [] })
6465
};
65-
const goToNextStep = () => {};
66+
const goToNextStep = () => { };
6667

6768
const createComponent = props => {
6869
return shallowWithIntl(

src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/__tests__/step_time_field.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jest.mock('../components/action_buttons', () => ({ ActionButtons: 'ActionButtons
2929
jest.mock('../../../lib/extract_time_fields', () => ({
3030
extractTimeFields: fields => fields,
3131
}));
32+
jest.mock('ui/chrome', () => ({
33+
addBasePath: () => { },
34+
}));
3235

3336
const mockIndexPatternCreationType = {
3437
getIndexPatternType: () => 'default',

0 commit comments

Comments
 (0)