Skip to content

Commit

Permalink
Revert "Extract fatal notification into fatalError service, add suppo…
Browse files Browse the repository at this point in the history
…rt for EuiToast notifications (elastic#15749)"

This reverts commit 6e9fc73.
  • Loading branch information
cjcenizal committed Jan 28, 2018
1 parent 6e9fc73 commit d23341c
Show file tree
Hide file tree
Showing 96 changed files with 464 additions and 1,059 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ out an open PR:

- [CONTRIBUTING.md](CONTRIBUTING.md) will help you get Kibana up and running.
- If you would like to contribute code, please follow our [STYLEGUIDE.md](STYLEGUIDE.md).
- Learn more about our UI code with [UI_SYSTEMS.md](src/ui/public/UI_SYSTEMS.md).
- For all other questions, check out the [FAQ.md](FAQ.md) and
[wiki](https://github.com/elastic/kibana/wiki).

Expand Down
15 changes: 3 additions & 12 deletions src/core_plugins/kibana/public/dashboard/dashboard_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import angular from 'angular';
import { uiModules } from 'ui/modules';
import chrome from 'ui/chrome';
import { applyTheme } from 'ui/theme';
import { toastNotifications } from 'ui/notify';

import 'ui/query_bar';

Expand Down Expand Up @@ -184,18 +183,14 @@ app.directive('dashboardApp', function ($injector) {
$scope.addVis = function (hit, showToast = true) {
dashboardStateManager.addNewPanel(hit.id, 'visualization');
if (showToast) {
toastNotifications.addSuccess('Added visualization to your dashboard');
notify.info(`Visualization successfully added to your dashboard`);
}
};

$scope.addSearch = function (hit) {
dashboardStateManager.addNewPanel(hit.id, 'search');
toastNotifications.addSuccess({
title: 'Added saved search to your dashboard',
'data-test-subj': 'addSavedSearchToDashboardSuccess',
});
notify.info(`Search successfully added to your dashboard`);
};

$scope.$watch('model.hidePanelTitles', () => {
dashboardStateManager.setHidePanelTitles($scope.model.hidePanelTitles);
});
Expand Down Expand Up @@ -273,11 +268,7 @@ app.directive('dashboardApp', function ($injector) {
.then(function (id) {
$scope.kbnTopNav.close('save');
if (id) {
toastNotifications.addSuccess({
title: `Saved '${dash.title}'`,
'data-test-subj': 'saveDashboardSuccess',
});

notify.info(`Saved Dashboard as "${dash.title}"`);
if (dash.id !== $routeParams.id) {
kbnUrl.change(createDashboardEditUrl(dash.id));
} else {
Expand Down
5 changes: 3 additions & 2 deletions src/core_plugins/kibana/public/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'plugins/kibana/dashboard/saved_dashboard/saved_dashboards';
import 'plugins/kibana/dashboard/styles/index.less';
import 'plugins/kibana/dashboard/dashboard_config';
import uiRoutes from 'ui/routes';
import { toastNotifications } from 'ui/notify';
import { notify } from 'ui/notify';

import dashboardTemplate from 'plugins/kibana/dashboard/dashboard_app.html';
import dashboardListingTemplate from './listing/dashboard_listing.html';
Expand Down Expand Up @@ -71,7 +71,8 @@ uiRoutes
if (error instanceof SavedObjectNotFound && id === 'create') {
// Note "new AppState" is neccessary so the state in the url is preserved through the redirect.
kbnUrl.redirect(DashboardConstants.CREATE_NEW_DASHBOARD_URL, {}, new AppState());
toastNotifications.addWarning('The url "dashboard/create" was removed in 6.0. Please update your bookmarks.');
notify.error(
'The url "dashboard/create" is deprecated and will be removed in 6.0. Please update your bookmarks.');
} else {
throw error;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as filterActions from 'ui/doc_table/actions/filter';
import dateMath from '@elastic/datemath';
import 'ui/doc_table';
import 'ui/visualize';
import 'ui/notify';
import 'ui/fixed_scroll';
import 'ui/directives/validate_json';
import 'ui/filters/moment';
Expand All @@ -15,7 +16,6 @@ import 'ui/state_management/app_state';
import 'ui/timefilter';
import 'ui/share';
import 'ui/query_bar';
import { toastNotifications } from 'ui/notify';
import { VisProvider } from 'ui/vis';
import { BasicResponseHandlerProvider } from 'ui/vis/response_handlers/basic';
import { DocTitleProvider } from 'ui/doc_title';
Expand Down Expand Up @@ -416,11 +416,7 @@ function discoverController(
$scope.kbnTopNav.close('save');

if (id) {
toastNotifications.addSuccess({
title: `Saved '${savedSearch.title}'`,
'data-test-subj': 'saveSearchSuccess',
});

notify.info('Saved Data Source "' + savedSearch.title + '"');
if (savedSearch.id !== $route.current.params.id) {
kbnUrl.change('/discover/{{id}}', { id: savedSearch.id });
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/kibana/public/kibana.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'ui/vislib';
import 'ui/agg_response';
import 'ui/agg_types';
import 'ui/timepicker';
import { Notifier } from 'ui/notify';
import { Notifier } from 'ui/notify/notifier';
import 'leaflet';
import { KibanaRootController } from './kibana_root_controller';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import _ from 'lodash';
import { fatalError } from 'ui/notify';
import { IndexPatternMissingIndices } from 'ui/errors';
import 'ui/directives/validate_index_pattern';
import 'ui/directives/auto_select_if_only_one';
Expand Down Expand Up @@ -289,7 +288,7 @@ uiModules.get('apps/management')
return notify.error(`Couldn't locate any indices matching that pattern. Please add the index to Elasticsearch`);
}

fatalError(err);
notify.fatal(err);
}).finally(() => {
this.isCreatingIndexPattern = false;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import './scripted_field_editor';
import './source_filters_table';
import { KbnUrlProvider } from 'ui/url';
import { IndicesEditSectionsProvider } from './edit_sections';
import { fatalError } from 'ui/notify';
import uiRoutes from 'ui/routes';
import { uiModules } from 'ui/modules';
import template from './edit_index_pattern.html';
Expand Down Expand Up @@ -117,7 +116,7 @@ uiModules.get('apps/management')
.then(function () {
$location.url('/management/kibana/index');
})
.catch(fatalError);
.catch(notify.fatal);
}

const confirmModalOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'ui/field_editor';
import { IndexPatternsFieldProvider } from 'ui/index_patterns/_field';
import { KbnUrlProvider } from 'ui/url';
import uiRoutes from 'ui/routes';
import { toastNotifications } from 'ui/notify';
import template from './scripted_field_editor.html';

uiRoutes
Expand Down Expand Up @@ -30,8 +29,9 @@ uiRoutes
}
},
controllerAs: 'fieldSettings',
controller: function FieldEditorPageController($route, Private, docTitle) {
controller: function FieldEditorPageController($route, Private, Notifier, docTitle) {
const Field = Private(IndexPatternsFieldProvider);
const notify = new Notifier({ location: 'Field Editor' });
const kbnUrl = Private(KbnUrlProvider);

this.mode = $route.current.mode;
Expand All @@ -43,8 +43,7 @@ uiRoutes
this.field = this.indexPattern.fields.byName[fieldName];

if (!this.field) {
toastNotifications.add(`'${this.indexPattern.title}' index pattern doesn't have a scripted field called '${fieldName}'`);

notify.error(this.indexPattern + ' does not have a "' + fieldName + '" field.');
kbnUrl.redirectToRoute(this.indexPattern, 'edit');
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import 'ui/paginated_table';
import fieldControlsHtml from '../field_controls.html';
import { dateScripts } from './date_scripts';
import { uiModules } from 'ui/modules';
import { toastNotifications } from 'ui/notify';
import template from './scripted_fields_table.html';
import { getSupportedScriptingLanguages, getDeprecatedScriptingLanguages } from 'ui/scripting_languages';
import { documentationLinks } from 'ui/documentation_links/documentation_links';

uiModules.get('apps/management')
.directive('scriptedFieldsTable', function (kbnUrl, $filter, confirmModal) {
.directive('scriptedFieldsTable', function (kbnUrl, Notifier, $filter, confirmModal) {
const rowScopes = []; // track row scopes, so they can be destroyed as needed
const filter = $filter('filter');

const notify = new Notifier();

return {
restrict: 'E',
template,
Expand Down Expand Up @@ -81,17 +82,11 @@ uiModules.get('apps/management')
});

if (fieldsAdded > 0) {
toastNotifications.addSuccess({
title: 'Created script fields',
text: `Created ${fieldsAdded}`,
});
notify.info(fieldsAdded + ' script fields created');
}

if (conflictFields.length > 0) {
toastNotifications.addWarning({
title: `Didn't add duplicate fields`,
text: `${conflictFields.length} fields: ${conflictFields.join(', ')}`,
});
notify.info('Not adding ' + conflictFields.length + ' duplicate fields: ' + conflictFields.join(', '));
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { find, each, escape, invoke, size, without } from 'lodash';

import { uiModules } from 'ui/modules';
import { Notifier } from 'ui/notify';
import { Notifier } from 'ui/notify/notifier';
import { FieldWildcardProvider } from 'ui/field_wildcard';

import controlsHtml from './controls.html';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@ import { savedObjectManagementRegistry } from 'plugins/kibana/management/saved_o
import objectViewHTML from 'plugins/kibana/management/sections/objects/_view.html';
import uiRoutes from 'ui/routes';
import { uiModules } from 'ui/modules';
import { fatalError, toastNotifications } from 'ui/notify';
import 'ui/accessibility/kbn_ui_ace_keyboard_mode';
import { castEsToKbnFieldTypeName } from '../../../../../../utils';
import { SavedObjectsClientProvider } from 'ui/saved_objects';

const location = 'SavedObject view';

uiRoutes
.when('/management/kibana/objects/:service/:id', {
template: objectViewHTML
});

uiModules.get('apps/management')
.directive('kbnManagementObjectsView', function (kbnIndex, confirmModal) {
.directive('kbnManagementObjectsView', function (kbnIndex, Notifier, confirmModal) {
return {
restrict: 'E',
controller: function ($scope, $injector, $routeParams, $location, $window, $rootScope, Private) {
const notify = new Notifier({ location: 'SavedObject view' });
const serviceObj = savedObjectManagementRegistry.get($routeParams.service);
const service = $injector.get(serviceObj.service);
const savedObjectsClient = Private(SavedObjectsClientProvider);
Expand Down Expand Up @@ -124,7 +122,7 @@ uiModules.get('apps/management')
return (orderIndex > -1) ? orderIndex : Infinity;
});
})
.catch(error => fatalError(error, location));
.catch(notify.fatal);

// This handles the validation of the Ace Editor. Since we don't have any
// other hooks into the editors to tell us if the content is valid or not
Expand Down Expand Up @@ -175,7 +173,7 @@ uiModules.get('apps/management')
.then(function () {
return redirectHandler('deleted');
})
.catch(error => fatalError(error, location));
.catch(notify.fatal);
}
const confirmModalOptions = {
onConfirm: doDelete,
Expand Down Expand Up @@ -209,17 +207,18 @@ uiModules.get('apps/management')
.then(function () {
return redirectHandler('updated');
})
.catch(error => fatalError(error, location));
.catch(notify.fatal);
};

function redirectHandler(action) {
const msg = 'You successfully ' + action + ' the "' + $scope.obj.attributes.title + '" ' + $scope.title.toLowerCase() + ' object';

$location.path('/management/kibana/objects').search({
_a: rison.encode({
tab: serviceObj.title
})
});

toastNotifications.addSuccess(`${_.capitalize(action)} '${$scope.obj.attributes.title}' ${$scope.title.toLowerCase()} object`);
notify.info(msg);
}
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'ui/elastic_textarea';
import 'ui/filters/markdown';
import { uiModules } from 'ui/modules';
import { fatalError } from 'ui/notify';
import { keyCodes } from '@elastic/eui';
import advancedRowTemplate from 'plugins/kibana/management/sections/settings/advanced_row.html';

uiModules.get('apps/management')
.directive('advancedRow', function (config) {
.directive('advancedRow', function (config, Notifier) {
return {
restrict: 'A',
replace: true,
Expand All @@ -16,6 +15,8 @@ uiModules.get('apps/management')
configs: '='
},
link: function ($scope) {
const notify = new Notifier();

// To allow passing form validation state back
$scope.forms = {};

Expand All @@ -26,7 +27,7 @@ uiModules.get('apps/management')
.then(function () {
conf.loading = conf.editing = false;
})
.catch(fatalError);
.catch(notify.fatal);
};

$scope.maybeCancel = function ($event, conf) {
Expand Down
10 changes: 3 additions & 7 deletions src/core_plugins/kibana/public/visualize/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'ui/share';
import 'ui/query_bar';
import chrome from 'ui/chrome';
import angular from 'angular';
import { Notifier, toastNotifications } from 'ui/notify';
import { Notifier } from 'ui/notify/notifier';
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';
import { DocTitleProvider } from 'ui/doc_title';
import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter';
Expand Down Expand Up @@ -251,11 +251,7 @@ function VisEditor($scope, $route, timefilter, AppState, $window, kbnUrl, courie
$scope.kbnTopNav.close('save');

if (id) {
toastNotifications.addSuccess({
title: `Saved '${savedVis.title}'`,
'data-test-subj': 'saveVisualizationSuccess',
});

notify.info('Saved Visualization "' + savedVis.title + '"');
if ($scope.isAddToDashMode()) {
const savedVisualizationParsedUrl = new KibanaParsedUrl({
basePath: chrome.getBasePath(),
Expand Down Expand Up @@ -285,7 +281,7 @@ function VisEditor($scope, $route, timefilter, AppState, $window, kbnUrl, courie
$scope.unlink = function () {
if (!$state.linked) return;

toastNotifications.addSuccess(`Unlinked from saved search '${savedVis.savedSearch.title}'`);
notify.info(`Unlinked Visualization "${savedVis.title}" from Saved Search "${savedVis.savedSearch.title}"`);

$state.linked = false;
const parent = searchSource.getParent(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import labDisabledTemplate from './visualize_lab_disabled.html';
import chrome from 'ui/chrome';

export class VisualizeEmbeddableFactory extends EmbeddableFactory {
constructor(savedVisualizations, timefilter, Promise, Private, config) {
constructor(savedVisualizations, timefilter, Notifier, Promise, Private, config) {
super();
this._config = config;
this.savedVisualizations = savedVisualizations;
this.name = 'visualization';
this.Promise = Promise;
this.brushEvent = utilsBrushEventProvider(timefilter);
this.filterBarClickHandler = filterBarClickHandlerProvider(Private);
this.filterBarClickHandler = filterBarClickHandlerProvider(Notifier, Private);
}

getEditPath(panelId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ export function visualizeEmbeddableFactoryProvider(Private) {
const VisualizeEmbeddableFactoryProvider = (
savedVisualizations,
timefilter,
Notifier,
Promise,
Private,
config) => {
return new VisualizeEmbeddableFactory(savedVisualizations, timefilter, Promise, Private, config);
return new VisualizeEmbeddableFactory(savedVisualizations, timefilter, Notifier, Promise, Private, config);
};
return Private(VisualizeEmbeddableFactoryProvider);
}
Expand Down
Loading

0 comments on commit d23341c

Please sign in to comment.