mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Merge pull request #2845 from node-red/subflow-delete-prompt
Add confirm dialog when deleting subflow with instances in use
This commit is contained in:
		@@ -338,6 +338,7 @@
 | 
				
			|||||||
        "output": "outputs:",
 | 
					        "output": "outputs:",
 | 
				
			||||||
        "status": "status node",
 | 
					        "status": "status node",
 | 
				
			||||||
        "deleteSubflow": "delete subflow",
 | 
					        "deleteSubflow": "delete subflow",
 | 
				
			||||||
 | 
					        "confirmDelete": "Are you sure you want to delete this subflow?",
 | 
				
			||||||
        "info": "Description",
 | 
					        "info": "Description",
 | 
				
			||||||
        "category": "Category",
 | 
					        "category": "Category",
 | 
				
			||||||
        "module": "Module",
 | 
					        "module": "Module",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -464,12 +464,43 @@ RED.subflow = (function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $("#red-ui-subflow-delete").on("click", function(event) {
 | 
					        $("#red-ui-subflow-delete").on("click", function(event) {
 | 
				
			||||||
            event.preventDefault();
 | 
					            event.preventDefault();
 | 
				
			||||||
 | 
					            var subflow = RED.nodes.subflow(RED.workspaces.active());
 | 
				
			||||||
 | 
					            if (subflow.instances.length > 0) {
 | 
				
			||||||
 | 
					                var msg = $('<div>')
 | 
				
			||||||
 | 
					                $('<p>').text(RED._("subflow.subflowInstances",{count: subflow.instances.length})).appendTo(msg);
 | 
				
			||||||
 | 
					                $('<p>').text(RED._("subflow.confirmDelete")).appendTo(msg);
 | 
				
			||||||
 | 
					                var confirmDeleteNotification = RED.notify(msg, {
 | 
				
			||||||
 | 
					                    modal: true,
 | 
				
			||||||
 | 
					                    fixed: true,
 | 
				
			||||||
 | 
					                    buttons: [
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            text: RED._('common.label.cancel'),
 | 
				
			||||||
 | 
					                            click: function() {
 | 
				
			||||||
 | 
					                                confirmDeleteNotification.close();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        },
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            text: RED._('workspace.confirmDelete'),
 | 
				
			||||||
 | 
					                            class: "primary",
 | 
				
			||||||
 | 
					                            click: function() {
 | 
				
			||||||
 | 
					                                confirmDeleteNotification.close();
 | 
				
			||||||
 | 
					                                completeDelete();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    ]
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                completeDelete();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            function completeDelete() {
 | 
				
			||||||
                var startDirty = RED.nodes.dirty();
 | 
					                var startDirty = RED.nodes.dirty();
 | 
				
			||||||
                var historyEvent = removeSubflow(RED.workspaces.active());
 | 
					                var historyEvent = removeSubflow(RED.workspaces.active());
 | 
				
			||||||
                historyEvent.t = 'delete';
 | 
					                historyEvent.t = 'delete';
 | 
				
			||||||
                historyEvent.dirty = startDirty;
 | 
					                historyEvent.dirty = startDirty;
 | 
				
			||||||
 | 
					 | 
				
			||||||
                RED.history.push(historyEvent);
 | 
					                RED.history.push(historyEvent);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user