mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge branch 'projects' into sshkey-management
This commit is contained in:
commit
2a9d0a5e7d
@ -68,11 +68,9 @@ module.exports = {
|
||||
editorApp.use("/",ui.editorResources);
|
||||
|
||||
//Projects
|
||||
if (runtime.storage.projects) {
|
||||
var projects = require("./projects");
|
||||
projects.init(runtime);
|
||||
editorApp.use("/projects",projects.app());
|
||||
}
|
||||
|
||||
// Locales
|
||||
var locales = require("./locales");
|
||||
|
@ -27,6 +27,14 @@ module.exports = {
|
||||
app: function() {
|
||||
var app = express();
|
||||
|
||||
app.use(function(req,res,next) {
|
||||
if (!runtime.storage.projects) {
|
||||
res.status(404).end();
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
||||
// Projects
|
||||
|
||||
// List all projects
|
||||
|
@ -54,8 +54,12 @@ var storageModuleInterface = {
|
||||
} catch (e) {
|
||||
return when.reject(e);
|
||||
}
|
||||
if (!!storageModule.projects) {
|
||||
var projectsEnabled = true;
|
||||
if (runtime.settings.hasOwnProperty("editorTheme") && runtime.settings.editorTheme.hasOwnProperty("projects")) {
|
||||
if (storageModule.projects) {
|
||||
projectsEnabled = runtime.settings.editorTheme.projects.enabled !== false;
|
||||
}
|
||||
if (projectsEnabled) {
|
||||
storageModuleInterface.projects = storageModule.projects;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ var Projects = require("./Project");
|
||||
var settings;
|
||||
var runtime;
|
||||
|
||||
var projectsEnabled;
|
||||
var projectsEnabled = true;
|
||||
var projectLogMessages = [];
|
||||
|
||||
var projectsDir;
|
||||
@ -96,17 +96,21 @@ function init(_settings, _runtime) {
|
||||
// has not yet been initialised. That isn't ideal - can this be deferred?
|
||||
.then(storageSettings.getSettings)
|
||||
.then(function(globalSettings) {
|
||||
var saveSettings = false;
|
||||
if (!globalSettings.projects) {
|
||||
// TODO: Migration Case
|
||||
console.log("TODO: Migration from single file to project");
|
||||
globalSettings.projects = {
|
||||
activeProject: "",
|
||||
projects: {}
|
||||
}
|
||||
return storageSettings.saveSettings(globalSettings);
|
||||
saveSettings = true;
|
||||
} else {
|
||||
activeProject = globalSettings.projects.activeProject;
|
||||
}
|
||||
if (!activeProject) {
|
||||
projectLogMessages.push(log._("storage.localfilesystem.no-active-project"))
|
||||
}
|
||||
if (saveSettings) {
|
||||
return storageSettings.saveSettings(globalSettings);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -151,12 +155,7 @@ function getProject(user, name) {
|
||||
username = user.username;
|
||||
}
|
||||
return Projects.get(name).then(function(project) {
|
||||
var result = project.toJSON();
|
||||
var projectSettings = settings.get("projects").projects;
|
||||
if (projectSettings[name] && projectSettings[name].git && projectSettings[name].git.user[username]) {
|
||||
result.git.user = projectSettings[name].git.user[username];
|
||||
}
|
||||
return result;
|
||||
return project.toJSON();
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user