mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Support to delete project feature (#1509)
* First commit to support to delete projects * Add delete project menu & Implement delete project API * Correspond to the PR feedback
This commit is contained in:
committed by
Nick O'Leary
parent
304c597a2f
commit
3adfe249b0
@@ -217,6 +217,7 @@
|
||||
menuOptions.push({id:"menu-item-projects-menu",label:"NLS: Projects",options:[
|
||||
{id:"menu-item-projects-new",label:"New...",disabled:false,onselect:"core:new-project"},
|
||||
{id:"menu-item-projects-open",label:"Open...",disabled:false,onselect:"core:open-project"},
|
||||
{id:"menu-item-projects-delete",label:"Delete...",disabled:false,onselect:"core:delete-project"},
|
||||
]});
|
||||
|
||||
|
||||
|
@@ -505,6 +505,9 @@ RED.projects = (function() {
|
||||
canSelectActive: false,
|
||||
dblclick: function() {
|
||||
$("#projects-dialog-open").click();
|
||||
},
|
||||
select: function() {
|
||||
$("#projects-dialog-open").prop('disabled',false).removeClass('disabled ui-button-disabled ui-state-disabled');
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -536,6 +539,49 @@ RED.projects = (function() {
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
'delete': {
|
||||
content: function() {
|
||||
return createProjectList({
|
||||
canSelectActive: false,
|
||||
dblclick: function() {
|
||||
$("#projects-dialog-delete").click();
|
||||
},
|
||||
select: function() {
|
||||
$("#projects-dialog-delete").prop('disabled',false).removeClass('disabled ui-button-disabled ui-state-disabled');
|
||||
}
|
||||
})
|
||||
},
|
||||
buttons: [
|
||||
{
|
||||
// id: "clipboard-dialog-cancel",
|
||||
text: RED._("common.label.cancel"),
|
||||
click: function() {
|
||||
$( this ).dialog( "close" );
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "projects-dialog-delete",
|
||||
text: "Delete project", // TODO: nls
|
||||
class: "primary disabled",
|
||||
disabled: true,
|
||||
click: function() {
|
||||
deleteProject(selectedProject.name,function(err,data) {
|
||||
if (err) {
|
||||
if (err.error === 'credentials_load_failed') {
|
||||
dialog.dialog( "close" );
|
||||
} else {
|
||||
console.log("unexpected_error",err)
|
||||
}
|
||||
} else {
|
||||
dialog.dialog( "close" );
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -565,6 +611,23 @@ RED.projects = (function() {
|
||||
})
|
||||
}
|
||||
|
||||
function deleteProject(name,done) {
|
||||
sendRequest({
|
||||
url: "projects/"+name,
|
||||
type: "DELETE",
|
||||
responses: {
|
||||
200: function(data) {
|
||||
done(null,data);
|
||||
},
|
||||
400: {
|
||||
'unexpected_error': function(error) {
|
||||
done(error,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function show(s,options) {
|
||||
if (!dialog) {
|
||||
RED.projects.init();
|
||||
@@ -607,7 +670,6 @@ RED.projects = (function() {
|
||||
row.click(function(evt) {
|
||||
$('.projects-dialog-project-list-entry').removeClass('selected');
|
||||
header.addClass('selected');
|
||||
$("#projects-dialog-open").prop('disabled',false).removeClass('disabled ui-button-disabled ui-state-disabled');
|
||||
selectedProject = entry;
|
||||
if (options.select) {
|
||||
options.select(entry);
|
||||
@@ -947,6 +1009,7 @@ RED.projects = (function() {
|
||||
|
||||
RED.actions.add("core:new-project",RED.projects.newProject);
|
||||
RED.actions.add("core:open-project",RED.projects.selectProject);
|
||||
RED.actions.add("core:delete-project",RED.projects.deleteProject);
|
||||
var projectsAPI = {
|
||||
sendRequest:sendRequest,
|
||||
createBranchList:createBranchList,
|
||||
@@ -990,6 +1053,9 @@ RED.projects = (function() {
|
||||
selectProject: function() {
|
||||
show('open')
|
||||
},
|
||||
deleteProject: function() {
|
||||
show('delete')
|
||||
},
|
||||
showCredentialsPrompt: function() { //TODO: rename this function
|
||||
RED.projects.settings.show('settings');
|
||||
},
|
||||
|
Reference in New Issue
Block a user