From fb368b5605bd6f6e7982ba7ba03a67ca495d8f7e 2015-01-28 20:01:30 From: Min RK Date: 2015-01-28 20:01:30 Subject: [PATCH] add missing error dialogs to tree actions - new file/folder, copy were not catching errors - made error messages more consistent --- diff --git a/IPython/html/static/tree/js/newnotebook.js b/IPython/html/static/tree/js/newnotebook.js index 40e9d5b..c4183a3 100644 --- a/IPython/html/static/tree/js/newnotebook.js +++ b/IPython/html/static/tree/js/newnotebook.js @@ -85,16 +85,20 @@ define([ url += "?kernel_name=" + kernel_name; } w.location = url; - }, - function (error) { - w.close(); - dialog.modal({ - title : 'Creating Notebook Failed', - body : "The error was: " + error.message, - buttons : {'OK' : {'class' : 'btn-primary'}} - }); - } - ); + }).catch(function (e) { + w.close(); + dialog.modal({ + title : 'Creating Notebook Failed', + body : $('
') + .text("An error occurred while creating a new notebook.") + .append($('
') + .addClass('alert alert-danger') + .text(e.message || e)), + buttons: { + OK: {'class' : 'btn-primary'} + } + }); + }); }; return {'NewNotebookWidget': NewNotebookWidget}; diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js index 2b6e98b..3ab39a1 100644 --- a/IPython/html/static/tree/js/notebooklist.js +++ b/IPython/html/static/tree/js/notebooklist.js @@ -78,6 +78,19 @@ define([ that.base_url, 'edit', data.path ); w.location = url; + }).catch(function (e) { + w.close(); + dialog.modal({ + title: 'Creating File Failed', + body: $('
') + .text("An error occurred while creating a new file.") + .append($('
') + .addClass('alert alert-danger') + .text(e.message || e)), + buttons: { + OK: {'class': 'btn-primary'} + } + }); }); that.load_sessions(); }); @@ -85,7 +98,20 @@ define([ that.contents.new_untitled(that.notebook_path || '', {type: 'directory'}) .then(function(){ that.load_list(); + }).catch(function (e) { + dialog.modal({ + title: 'Creating Folder Failed', + body: $('
') + .text("An error occurred while creating a new folder.") + .append($('
') + .addClass('alert alert-danger') + .text(e.message || e)), + buttons: { + OK: {'class': 'btn-primary'} + } + }); }); + that.load_sessions(); }); $('.rename-button').click($.proxy(this.rename_selected, this)); @@ -462,7 +488,7 @@ define([ ); $.ajax(url, settings); } - } + }; NotebookList.prototype.rename_selected = function() { if (this.selected.length != 1) return; @@ -488,12 +514,14 @@ define([ that.load_list(); }).catch(function(e) { dialog.modal({ - title : "Error", - body : $('
') + title: "Rename Failed", + body: $('
') .text("An error occurred while renaming \"" + path + "\" to \"" + input.val() + "\".") - .append($('
').addClass('alert alert-danger').text(String(e))), - buttons : { - OK : {} + .append($('
') + .addClass('alert alert-danger') + .text(e.message || e)), + buttons: { + OK: {'class': 'btn-primary'} } }); }); @@ -539,12 +567,14 @@ define([ that.notebook_deleted(item.path); }).catch(function(e) { dialog.modal({ - title : "Error", - body : $('
') + title: "Delete Failed", + body: $('
') .text("An error occurred while deleting \"" + item.path + "\".") - .append($('
').addClass('alert alert-danger').text(String(e))), - buttons : { - OK : {} + .append($('
') + .addClass('alert alert-danger') + .text(e.message || e)), + buttons: { + OK: {'class': 'btn-primary'} } }); }); @@ -576,12 +606,14 @@ define([ that.load_list(); }).catch(function(e) { dialog.modal({ - title : "Error", - body : $('
') - .text("An error occurred while copying \"" + item.path + "\".") - .append($('
').addClass('alert alert-danger').text(String(e))), - buttons : { - OK : {} + title: "Delete Failed", + body: $('
') + .text("An error occurred while deleting \"" + item.path + "\".") + .append($('
') + .addClass('alert alert-danger') + .text(e.message || e)), + buttons: { + OK: {'class': 'btn-primary'} } }); });