##// END OF EJS Templates
Backport PR #8000: Fix rename issues in dashboard...
Min RK -
Show More
@@ -440,8 +440,8 b' define(['
440 });
440 });
441 this.selected = selected;
441 this.selected = selected;
442
442
443 // Rename is only visible when one item is selected.
443 // Rename is only visible when one item is selected, and it is not a running notebook
444 if (selected.length==1) {
444 if (selected.length==1 && !has_running_notebook) {
445 $('.rename-button').css('display', 'inline-block');
445 $('.rename-button').css('display', 'inline-block');
446 } else {
446 } else {
447 $('.rename-button').css('display', 'none');
447 $('.rename-button').css('display', 'none');
@@ -595,29 +595,31 b' define(['
595 if (this.selected.length != 1) return;
595 if (this.selected.length != 1) return;
596
596
597 var that = this;
597 var that = this;
598 var path = this.selected[0].path;
598 var item_path = this.selected[0].path;
599 var item_name = this.selected[0].name;
600 var item_type = this.selected[0].type;
599 var input = $('<input/>').attr('type','text').attr('size','25').addClass('form-control')
601 var input = $('<input/>').attr('type','text').attr('size','25').addClass('form-control')
600 .val(path);
602 .val(item_name);
601 var dialog_body = $('<div/>').append(
603 var dialog_body = $('<div/>').append(
602 $("<p/>").addClass("rename-message")
604 $("<p/>").addClass("rename-message")
603 .text('Enter a new directory name:')
605 .text('Enter a new '+ item_type + ' name:')
604 ).append(
606 ).append(
605 $("<br/>")
607 $("<br/>")
606 ).append(input);
608 ).append(input);
607 var d = dialog.modal({
609 var d = dialog.modal({
608 title : "Rename directory",
610 title : "Rename "+ item_type,
609 body : dialog_body,
611 body : dialog_body,
610 buttons : {
612 buttons : {
611 OK : {
613 OK : {
612 class: "btn-primary",
614 class: "btn-primary",
613 click: function() {
615 click: function() {
614 that.contents.rename(path, input.val()).then(function() {
616 that.contents.rename(item_path, utils.url_path_join(that.notebook_path, input.val())).then(function() {
615 that.load_list();
617 that.load_list();
616 }).catch(function(e) {
618 }).catch(function(e) {
617 dialog.modal({
619 dialog.modal({
618 title: "Rename Failed",
620 title: "Rename Failed",
619 body: $('<div/>')
621 body: $('<div/>')
620 .text("An error occurred while renaming \"" + path + "\" to \"" + input.val() + "\".")
622 .text("An error occurred while renaming \"" + item_name + "\" to \"" + input.val() + "\".")
621 .append($('<div/>')
623 .append($('<div/>')
622 .addClass('alert alert-danger')
624 .addClass('alert alert-danger')
623 .text(e.message || e)),
625 .text(e.message || e)),
General Comments 0
You need to be logged in to leave comments. Login now