From d17ca85f5b0fb58a4ed8feea9955b66bad2ce6ea Mon Sep 17 00:00:00 2001 From: KesterTong Date: Sun, 13 Jul 2014 16:03:12 -0500 Subject: [PATCH] Adds dialog on new_notebook failure This logic doesn't really belong in ContentManager. It would be better to trigger an event, which is handled somewhere else. But there's no obvious place to put this event, so creating the error dialog inside the new_notebook method is ok for now. --- IPython/html/static/base/js/contentmanager.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/IPython/html/static/base/js/contentmanager.js b/IPython/html/static/base/js/contentmanager.js index 2972ef8a3..0448aa163 100644 --- a/IPython/html/static/base/js/contentmanager.js +++ b/IPython/html/static/base/js/contentmanager.js @@ -5,7 +5,8 @@ define([ 'base/js/namespace', 'jquery', 'base/js/utils', -], function(IPython, $, utils) { + 'base/js/dialog', +], function(IPython, $, utils, dialog) { var ContentManager = function(options) { // Constructor // @@ -50,7 +51,20 @@ define([ '_blank' ); }, - error : utils.log_ajax_error, + error : function(xhr, status, error) { + utils.log_ajax_error(xhr, status, error); + var msg; + if (xhr.responseJSON && xhr.responseJSON.message) { + msg = xhr.responseJSON.message; + } else { + msg = xhr.statusText; + } + dialog.modal({ + title : 'Creating Notebook Failed', + body : "The error was: " + msg, + buttons : {'OK' : {'class' : 'btn-primary'}} + }); + } }; var url = utils.url_join_encode( base_url,