Skip to content

Commit

Permalink
Fixes index pattern wizard when there are remote clusters but no loca…
Browse files Browse the repository at this point in the history
…l indices (#24339) (#25613)

* don't hide wizard if clusters exist

* catch errors

* add toast notifs if unable to load data
  • Loading branch information
mattkime authored Nov 14, 2018
1 parent 2cd965e commit eec9cb7
Show file tree
Hide file tree
Showing 13 changed files with 402 additions and 118 deletions.
2 changes: 2 additions & 0 deletions src/core_plugins/kibana/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { managementApi } from './server/routes/api/management';
import { scriptsApi } from './server/routes/api/scripts';
import { registerSuggestionsApi } from './server/routes/api/suggestions';
import { registerKqlTelemetryApi } from './server/routes/api/kql_telemetry';
import { registerClustersRoute } from './server/routes/api/remote_info';
import { registerFieldFormats } from './server/field_formats/register';
import { registerTutorials } from './server/tutorials/register';
import * as systemApi from './server/lib/system_api';
Expand Down Expand Up @@ -167,6 +168,7 @@ export default function (kibana) {
registerFieldFormats(server);
registerTutorials(server);
makeKQLUsageCollector(server);
registerClustersRoute(server);
server.expose('systemApi', systemApi);
server.expose('handleEsError', handleEsError);
server.injectUiAppVars('kibana', () => injectVars(server));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,132 +1,205 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`CreateIndexPatternWizard defaults to the loading state 1`] = `
<div>
<Header
indexPatternName="name"
isBeta={false}
isIncludingSystemIndices={false}
onChangeIncludingSystemIndices={[Function]}
showSystemIndices={false}
<React.Fragment>
<div>
<Header
indexPatternName="name"
isBeta={false}
isIncludingSystemIndices={false}
onChangeIncludingSystemIndices={[Function]}
showSystemIndices={false}
/>
<LoadingState />
</div>
<EuiGlobalToastList
dismissToast={[Function]}
toastLifeTimeMs={6000}
toasts={Array []}
/>
<LoadingState />
</div>
</React.Fragment>
`;

exports[`CreateIndexPatternWizard renders index pattern step when there are indices 1`] = `
<div>
<Header
indexPatternName="name"
isBeta={false}
isIncludingSystemIndices={false}
onChangeIncludingSystemIndices={[Function]}
showSystemIndices={false}
/>
<StepIndexPattern
allIndices={
Array [
<React.Fragment>
<div>
<Header
indexPatternName="name"
isBeta={false}
isIncludingSystemIndices={false}
onChangeIncludingSystemIndices={[Function]}
showSystemIndices={false}
/>
<StepIndexPattern
allIndices={
Array [
Object {
"name": "myIndexPattern",
},
]
}
esService={Object {}}
goToNextStep={[Function]}
indexPatternCreationType={
Object {
"name": "myIndexPattern",
},
]
}
esService={Object {}}
goToNextStep={[Function]}
indexPatternCreationType={
Object {
"checkIndicesForErrors": [Function],
"getIndexPatternMappings": [Function],
"getIndexPatternName": [Function],
"getIndexPatternType": [Function],
"getIsBeta": [Function],
"getShowSystemIndices": [Function],
"renderPrompt": [Function],
"checkIndicesForErrors": [Function],
"getIndexPatternMappings": [Function],
"getIndexPatternName": [Function],
"getIndexPatternType": [Function],
"getIsBeta": [Function],
"getShowSystemIndices": [Function],
"renderPrompt": [Function],
}
}
}
initialQuery=""
isIncludingSystemIndices={false}
savedObjectsClient={Object {}}
initialQuery=""
isIncludingSystemIndices={false}
savedObjectsClient={Object {}}
/>
</div>
<EuiGlobalToastList
dismissToast={[Function]}
toastLifeTimeMs={6000}
toasts={Array []}
/>
</div>
</React.Fragment>
`;

exports[`CreateIndexPatternWizard renders the empty state when there are no indices 1`] = `
<div>
<Header
indexPatternName="name"
isBeta={false}
isIncludingSystemIndices={false}
onChangeIncludingSystemIndices={[Function]}
showSystemIndices={false}
/>
<EmptyState
onRefresh={[Function]}
<React.Fragment>
<div>
<Header
indexPatternName="name"
isBeta={false}
isIncludingSystemIndices={false}
onChangeIncludingSystemIndices={[Function]}
showSystemIndices={false}
/>
<EmptyState
onRefresh={[Function]}
/>
</div>
<EuiGlobalToastList
dismissToast={[Function]}
toastLifeTimeMs={6000}
toasts={Array []}
/>
</div>
</React.Fragment>
`;

exports[`CreateIndexPatternWizard renders time field step when step is set to 2 1`] = `
<div>
<Header
indexPatternName="name"
isBeta={false}
isIncludingSystemIndices={false}
onChangeIncludingSystemIndices={[Function]}
showSystemIndices={false}
<React.Fragment>
<div>
<Header
indexPatternName="name"
isBeta={false}
isIncludingSystemIndices={false}
onChangeIncludingSystemIndices={[Function]}
showSystemIndices={false}
/>
<StepTimeField
createIndexPattern={[Function]}
goToPreviousStep={[Function]}
indexPattern=""
indexPatternCreationType={
Object {
"checkIndicesForErrors": [Function],
"getIndexPatternMappings": [Function],
"getIndexPatternName": [Function],
"getIndexPatternType": [Function],
"getIsBeta": [Function],
"getShowSystemIndices": [Function],
"renderPrompt": [Function],
}
}
indexPatternsService={Object {}}
/>
</div>
<EuiGlobalToastList
dismissToast={[Function]}
toastLifeTimeMs={6000}
toasts={Array []}
/>
<StepTimeField
createIndexPattern={[Function]}
goToPreviousStep={[Function]}
indexPattern=""
indexPatternCreationType={
Object {
"checkIndicesForErrors": [Function],
"getIndexPatternMappings": [Function],
"getIndexPatternName": [Function],
"getIndexPatternType": [Function],
"getIsBeta": [Function],
"getShowSystemIndices": [Function],
"renderPrompt": [Function],
</React.Fragment>
`;

exports[`CreateIndexPatternWizard renders when there are no indices but there are remote clusters 1`] = `
<React.Fragment>
<div>
<Header
indexPatternName="name"
isBeta={false}
isIncludingSystemIndices={false}
onChangeIncludingSystemIndices={[Function]}
showSystemIndices={false}
/>
<StepIndexPattern
allIndices={Array []}
esService={Object {}}
goToNextStep={[Function]}
indexPatternCreationType={
Object {
"checkIndicesForErrors": [Function],
"getIndexPatternMappings": [Function],
"getIndexPatternName": [Function],
"getIndexPatternType": [Function],
"getIsBeta": [Function],
"getShowSystemIndices": [Function],
"renderPrompt": [Function],
}
}
}
indexPatternsService={Object {}}
initialQuery=""
isIncludingSystemIndices={false}
savedObjectsClient={Object {}}
/>
</div>
<EuiGlobalToastList
dismissToast={[Function]}
toastLifeTimeMs={6000}
toasts={Array []}
/>
</div>
</React.Fragment>
`;

exports[`CreateIndexPatternWizard shows system indices even if there are no other indices if the include system indices is toggled 1`] = `
<div>
<Header
indexPatternName="name"
isBeta={false}
isIncludingSystemIndices={true}
onChangeIncludingSystemIndices={[Function]}
showSystemIndices={false}
/>
<StepIndexPattern
allIndices={
Array [
<React.Fragment>
<div>
<Header
indexPatternName="name"
isBeta={false}
isIncludingSystemIndices={true}
onChangeIncludingSystemIndices={[Function]}
showSystemIndices={false}
/>
<StepIndexPattern
allIndices={
Array [
Object {
"name": ".kibana ",
},
]
}
esService={Object {}}
goToNextStep={[Function]}
indexPatternCreationType={
Object {
"name": ".kibana ",
},
]
}
esService={Object {}}
goToNextStep={[Function]}
indexPatternCreationType={
Object {
"checkIndicesForErrors": [Function],
"getIndexPatternMappings": [Function],
"getIndexPatternName": [Function],
"getIndexPatternType": [Function],
"getIsBeta": [Function],
"getShowSystemIndices": [Function],
"renderPrompt": [Function],
"checkIndicesForErrors": [Function],
"getIndexPatternMappings": [Function],
"getIndexPatternName": [Function],
"getIndexPatternType": [Function],
"getIsBeta": [Function],
"getShowSystemIndices": [Function],
"renderPrompt": [Function],
}
}
}
initialQuery=""
isIncludingSystemIndices={true}
savedObjectsClient={Object {}}
initialQuery=""
isIncludingSystemIndices={true}
savedObjectsClient={Object {}}
/>
</div>
<EuiGlobalToastList
dismissToast={[Function]}
toastLifeTimeMs={6000}
toasts={Array []}
/>
</div>
</React.Fragment>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jest.mock('../lib/get_indices', () => ({
];
},
}));
jest.mock('ui/chrome', () => ({
addBasePath: () => { },
}));

const loadingDataDocUrl = '';
const initialQuery = '';
Expand Down Expand Up @@ -80,6 +83,26 @@ describe('CreateIndexPatternWizard', () => {
component.setState({
isInitiallyLoadingIndices: false,
allIndices: [],
remoteClustersExist: false
});

await component.update();
expect(component).toMatchSnapshot();
});

it('renders when there are no indices but there are remote clusters', async () => {
const component = shallow(
<CreateIndexPatternWizard
loadingDataDocUrl={loadingDataDocUrl}
initialQuery={initialQuery}
services={services}
/>
);

component.setState({
isInitiallyLoadingIndices: false,
allIndices: [],
remoteClustersExist: true
});

await component.update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jest.mock('ui/chrome', () => ({
getUiSettingsClient: () => ({
get: () => '',
}),
addBasePath: () => { },
}));

const { renderCreateIndexPatternWizard, destroyCreateIndexPatternWizard } = require('../render');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jest.mock('ui/chrome', () => ({
getUiSettingsClient: () => ({
get: () => '',
}),
addBasePath: () => { },
}));

jest.mock('../../../lib/get_indices', () => ({
Expand All @@ -62,7 +63,7 @@ const esService = {};
const savedObjectsClient = {
find: () => ({ savedObjects: [] })
};
const goToNextStep = () => {};
const goToNextStep = () => { };

const createComponent = props => {
return shallowWithIntl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jest.mock('../components/action_buttons', () => ({ ActionButtons: 'ActionButtons
jest.mock('../../../lib/extract_time_fields', () => ({
extractTimeFields: fields => fields,
}));
jest.mock('ui/chrome', () => ({
addBasePath: () => { },
}));

const mockIndexPatternCreationType = {
getIndexPatternType: () => 'default',
Expand Down
Loading

0 comments on commit eec9cb7

Please sign in to comment.