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