mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* Update buildHierarchicalData test.
This commit is contained in:
parent
4fe840e823
commit
8ed3b1e60e
7 changed files with 30 additions and 26 deletions
|
@ -19,7 +19,7 @@
|
|||
|
||||
import _ from 'lodash';
|
||||
import chrome from 'ui/chrome';
|
||||
import { notify } from 'ui/notify';
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
|
||||
const baseUrl = chrome.addBasePath('/api/kibana/home/tutorials');
|
||||
const headers = new Headers();
|
||||
|
@ -44,7 +44,10 @@ async function loadTutorials() {
|
|||
tutorials = await response.json();
|
||||
tutorialsLoaded = true;
|
||||
} catch(err) {
|
||||
notify.error(`Unable to load tutorials, ${err}`);
|
||||
toastNotifications.addDanger({
|
||||
title: 'Unable to load tutorials',
|
||||
text: err.message,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import './index_header';
|
|||
import './create_edit_field';
|
||||
import { KbnUrlProvider } from 'ui/url';
|
||||
import { IndicesEditSectionsProvider } from './edit_sections';
|
||||
import { fatalError } from 'ui/notify';
|
||||
import { fatalError, toastNotifications } from 'ui/notify';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import template from './edit_index_pattern.html';
|
||||
|
@ -181,8 +181,7 @@ uiRoutes
|
|||
|
||||
uiModules.get('apps/management')
|
||||
.controller('managementIndicesEdit', function (
|
||||
$scope, $location, $route, config, indexPatterns, Notifier, Private, AppState, docTitle, confirmModal) {
|
||||
const notify = new Notifier();
|
||||
$scope, $location, $route, config, indexPatterns, Private, AppState, docTitle, confirmModal) {
|
||||
const $state = $scope.state = new AppState();
|
||||
const { fieldWildcardMatcher } = Private(FieldWildcardProvider);
|
||||
|
||||
|
@ -292,7 +291,7 @@ uiModules.get('apps/management')
|
|||
const errorMessage = i18n.translate('kbn.management.editIndexPattern.notDateErrorMessage', {
|
||||
defaultMessage: 'That field is a {fieldType} not a date.', values: { fieldType: field.type }
|
||||
});
|
||||
notify.error(errorMessage);
|
||||
toastNotifications.addDanger(errorMessage);
|
||||
return;
|
||||
}
|
||||
$scope.indexPattern.timeFieldName = field.name;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
import _ from 'lodash';
|
||||
|
||||
import chrome from 'ui/chrome';
|
||||
import { notify } from 'ui/notify';
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
// Module-level error returned by notify.error
|
||||
|
@ -130,7 +130,7 @@ async function loadStatus(fetchFn = fetchData) {
|
|||
},
|
||||
);
|
||||
|
||||
errorNotif = notify.error(serverIsDownErrorMessage);
|
||||
errorNotif = toastNotifications.addDanger(serverIsDownErrorMessage);
|
||||
return e;
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ async function loadStatus(fetchFn = fetchData) {
|
|||
},
|
||||
);
|
||||
|
||||
errorNotif = notify.error(serverStatusCodeErrorMessage);
|
||||
errorNotif = toastNotifications.addDanger(serverStatusCodeErrorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import fixtures from 'fixtures/fake_hierarchical_data';
|
|||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
import { VisProvider } from '../../../vis';
|
||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
import { BuildHierarchicalDataProvider } from '../build_hierarchical_data';
|
||||
|
@ -276,6 +277,9 @@ describe('buildHierarchicalData', function () {
|
|||
let results;
|
||||
|
||||
beforeEach(function () {
|
||||
// Clear existing toasts.
|
||||
toastNotifications.list.splice(0);
|
||||
|
||||
let id = 1;
|
||||
vis = new Vis(indexPattern, {
|
||||
type: 'pie',
|
||||
|
@ -299,10 +303,11 @@ describe('buildHierarchicalData', function () {
|
|||
});
|
||||
|
||||
it('should set the hits attribute for the results', function () {
|
||||
const errCall = Notifier.prototype.error.getCall(0);
|
||||
expect(errCall).to.be.ok();
|
||||
expect(errCall.args[0]).to.contain('not supported');
|
||||
|
||||
// Ideally, buildHierarchicalData shouldn't be tightly coupled to toastNotifications. Instead,
|
||||
// it should notify its consumer of this error and the consumer should be responsible for
|
||||
// notifying the user. This test verifies the side effect of the error until we can remove
|
||||
// this coupling.
|
||||
expect(toastNotifications.list).to.have.length(1);
|
||||
expect(results).to.have.property('slices');
|
||||
expect(results).to.have.property('names');
|
||||
expect(results.names).to.have.length(2);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
import { extractBuckets } from './_extract_buckets';
|
||||
import { createRawData } from './_create_raw_data';
|
||||
import { arrayToLinkedList } from './_array_to_linked_list';
|
||||
|
@ -25,15 +26,10 @@ import AggConfigResult from '../../vis/agg_config_result';
|
|||
import { AggResponseHierarchicalBuildSplitProvider } from './_build_split';
|
||||
import { HierarchicalTooltipFormatterProvider } from './_hierarchical_tooltip_formatter';
|
||||
|
||||
export function BuildHierarchicalDataProvider(Private, Notifier) {
|
||||
export function BuildHierarchicalDataProvider(Private) {
|
||||
const buildSplit = Private(AggResponseHierarchicalBuildSplitProvider);
|
||||
const tooltipFormatter = Private(HierarchicalTooltipFormatterProvider);
|
||||
|
||||
|
||||
const notify = new Notifier({
|
||||
location: 'Pie chart response converter'
|
||||
});
|
||||
|
||||
return function (vis, resp) {
|
||||
// Create a reference to the buckets
|
||||
let buckets = vis.getAggConfig().bySchemaGroup.buckets;
|
||||
|
@ -73,7 +69,10 @@ export function BuildHierarchicalDataProvider(Private, Notifier) {
|
|||
const aggData = resp.aggregations ? resp.aggregations[firstAgg.id] : null;
|
||||
|
||||
if (!firstAgg._next && firstAgg.schema.name === 'split') {
|
||||
notify.error('Splitting charts without splitting slices is not supported. Pretending that we are just splitting slices.');
|
||||
toastNotifications.addDanger({
|
||||
title: 'Splitting charts without splitting slices is not supported',
|
||||
text: 'Pretending that we are just splitting slices.'
|
||||
});
|
||||
}
|
||||
|
||||
// start with splitting slices
|
||||
|
|
|
@ -18,9 +18,7 @@
|
|||
*/
|
||||
|
||||
import chrome from '../chrome';
|
||||
import { Notifier } from '../notify';
|
||||
|
||||
const notify = new Notifier({ location: 'Scripting Language Service' });
|
||||
import { toastNotifications } from '../notify';
|
||||
|
||||
export function getSupportedScriptingLanguages() {
|
||||
return ['painless'];
|
||||
|
@ -35,7 +33,7 @@ export function GetEnabledScriptingLanguagesProvider($http) {
|
|||
return $http.get(chrome.addBasePath('/api/kibana/scripts/languages'))
|
||||
.then((res) => res.data)
|
||||
.catch(() => {
|
||||
notify.error('Error getting available scripting languages from Elasticsearch');
|
||||
toastNotifications.addDanger('Error getting available scripting languages from Elasticsearch');
|
||||
return [];
|
||||
});
|
||||
};
|
||||
|
|
|
@ -101,7 +101,7 @@ uiRoutes
|
|||
return savedGraphWorkspaces.get($route.current.params.id)
|
||||
.catch(
|
||||
function () {
|
||||
notify.error('Missing workspace');
|
||||
toastNotifications.addDanger('Missing workspace');
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -830,7 +830,7 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU
|
|||
}
|
||||
});
|
||||
if(!savedObjectIndexPattern) {
|
||||
notify.error('Missing index pattern:' + wsObj.indexPattern);
|
||||
toastNotifications.addDanger(`'Missing index pattern ${wsObj.indexPattern}`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue