From ab307f0ccccbd1e4cb60c6de87dfe382362f1f7d Mon Sep 17 00:00:00 2001 From: Court Ewing Date: Tue, 17 Nov 2015 11:29:32 -0500 Subject: [PATCH] Use safeConfirm when overwriting index patterns The window.confirm() call used when attempting to overwrite an index pattern was causing a fatal error in firefox due to an already-running digest loop. The safeConfirm service exists specifically to avoid this issue. --- src/ui/public/index_patterns/_index_pattern.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ui/public/index_patterns/_index_pattern.js b/src/ui/public/index_patterns/_index_pattern.js index 829816d3a693..b7a3492c38e9 100644 --- a/src/ui/public/index_patterns/_index_pattern.js +++ b/src/ui/public/index_patterns/_index_pattern.js @@ -1,5 +1,5 @@ define(function (require) { - return function IndexPatternFactory(Private, timefilter, Notifier, config, kbnIndex, Promise, $rootScope) { + return function IndexPatternFactory(Private, timefilter, Notifier, config, kbnIndex, Promise, $rootScope, safeConfirm) { var _ = require('lodash'); var errors = require('ui/errors'); var angular = require('angular'); @@ -231,9 +231,15 @@ define(function (require) { return docSource.doCreate(body) .then(setId) .catch(function (err) { - var confirmMessage = 'Are you sure you want to overwrite this?'; - if (_.get(err, 'origError.status') === 409 && window.confirm(confirmMessage)) { // eslint-disable-line no-alert - return docSource.doIndex(body).then(setId); + if (_.get(err, 'origError.status') === 409) { + var confirmMessage = 'Are you sure you want to overwrite this?'; + + return safeConfirm(confirmMessage).then( + function () { + return docSource.doIndex(body).then(setId); + }, + _.constant(false) // if the user doesn't overwrite, resolve with false + ); } return Promise.resolve(false); });