mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add projects editorTheme flag to disable the feature
This commit is contained in:
parent
028d66befc
commit
a3a1bba5ef
@ -43,9 +43,13 @@
|
|||||||
$(".palette-scroll").removeClass("hide");
|
$(".palette-scroll").removeClass("hide");
|
||||||
$("#palette-search").removeClass("hide");
|
$("#palette-search").removeClass("hide");
|
||||||
loadFlows(function() {
|
loadFlows(function() {
|
||||||
|
if (RED.settings.theme("projects.enabled",true)) {
|
||||||
RED.projects.refresh(function() {
|
RED.projects.refresh(function() {
|
||||||
RED.sidebar.info.refresh()
|
RED.sidebar.info.refresh()
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
RED.sidebar.info.refresh()
|
||||||
|
}
|
||||||
|
|
||||||
var persistentNotifications = {};
|
var persistentNotifications = {};
|
||||||
RED.comms.subscribe("notification/#",function(topic,msg) {
|
RED.comms.subscribe("notification/#",function(topic,msg) {
|
||||||
@ -65,7 +69,6 @@
|
|||||||
RED.view.redraw(true);
|
RED.view.redraw(true);
|
||||||
RED.projects.refresh(function() {
|
RED.projects.refresh(function() {
|
||||||
loadFlows(function() {
|
loadFlows(function() {
|
||||||
console.log(msg);
|
|
||||||
var project = RED.projects.getActiveProject();
|
var project = RED.projects.getActiveProject();
|
||||||
var message = {
|
var message = {
|
||||||
"change-branch":"Change to local branch '"+project.git.branches.local+"'",
|
"change-branch":"Change to local branch '"+project.git.branches.local+"'",
|
||||||
@ -214,12 +217,13 @@
|
|||||||
|
|
||||||
function loadEditor() {
|
function loadEditor() {
|
||||||
var menuOptions = [];
|
var menuOptions = [];
|
||||||
|
if (RED.settings.theme("projects.enabled",true)) {
|
||||||
menuOptions.push({id:"menu-item-projects-menu",label:"NLS: Projects",options:[
|
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-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-open",label:"Open...",disabled:false,onselect:"core:open-project"},
|
||||||
{id:"menu-item-projects-delete",label:"Delete...",disabled:false,onselect:"core:delete-project"},
|
{id:"menu-item-projects-delete",label:"Delete...",disabled:false,onselect:"core:delete-project"},
|
||||||
]});
|
]});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
menuOptions.push({id:"menu-item-view-menu",label:RED._("menu.label.view.view"),options:[
|
menuOptions.push({id:"menu-item-view-menu",label:RED._("menu.label.view.view"),options:[
|
||||||
@ -284,10 +288,18 @@
|
|||||||
RED.palette.init();
|
RED.palette.init();
|
||||||
if (RED.settings.theme('palette.editable') !== false) {
|
if (RED.settings.theme('palette.editable') !== false) {
|
||||||
RED.palette.editor.init();
|
RED.palette.editor.init();
|
||||||
|
} else {
|
||||||
|
console.log("Palette editor disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
RED.sidebar.init();
|
RED.sidebar.init();
|
||||||
|
|
||||||
|
if (RED.settings.theme("projects.enabled",true)) {
|
||||||
RED.projects.init();
|
RED.projects.init();
|
||||||
|
} else {
|
||||||
|
console.log("Palette editor disabled");
|
||||||
|
}
|
||||||
|
|
||||||
RED.subflow.init();
|
RED.subflow.init();
|
||||||
RED.workspaces.init();
|
RED.workspaces.init();
|
||||||
RED.clipboard.init();
|
RED.clipboard.init();
|
||||||
|
@ -68,9 +68,11 @@ 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");
|
||||||
|
@ -31,7 +31,6 @@ module.exports = {
|
|||||||
|
|
||||||
// List all projects
|
// List all projects
|
||||||
app.get("/", needsPermission("projects.read"), function(req,res) {
|
app.get("/", needsPermission("projects.read"), function(req,res) {
|
||||||
console.log(req.user);
|
|
||||||
runtime.storage.projects.listProjects(req.user, req.user).then(function(list) {
|
runtime.storage.projects.listProjects(req.user, req.user).then(function(list) {
|
||||||
var active = runtime.storage.projects.getActiveProject(req.user);
|
var active = runtime.storage.projects.getActiveProject(req.user);
|
||||||
var response = {
|
var response = {
|
||||||
|
@ -182,6 +182,12 @@ module.exports = {
|
|||||||
if (theme.hasOwnProperty("palette")) {
|
if (theme.hasOwnProperty("palette")) {
|
||||||
themeSettings.palette = theme.palette;
|
themeSettings.palette = theme.palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (theme.hasOwnProperty("projects")) {
|
||||||
|
themeSettings.projects = theme.projects;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return themeApp;
|
return themeApp;
|
||||||
},
|
},
|
||||||
context: function() {
|
context: function() {
|
||||||
|
@ -133,13 +133,19 @@
|
|||||||
"localfilesystem": {
|
"localfilesystem": {
|
||||||
"user-dir": "User directory : __path__",
|
"user-dir": "User directory : __path__",
|
||||||
"flows-file": "Flows file : __path__",
|
"flows-file": "Flows file : __path__",
|
||||||
"changing-project": "Setting active project : __project__",
|
|
||||||
"active-project": "Active project : __project__",
|
|
||||||
"create": "Creating new __type__ file",
|
"create": "Creating new __type__ file",
|
||||||
"empty": "Existing __type__ file is empty",
|
"empty": "Existing __type__ file is empty",
|
||||||
"invalid": "Existing __type__ file is not valid json",
|
"invalid": "Existing __type__ file is not valid json",
|
||||||
"restore": "Restoring __type__ file backup : __path__",
|
"restore": "Restoring __type__ file backup : __path__",
|
||||||
"restore-fail": "Restoring __type__ file backup failed : __message__"
|
"restore-fail": "Restoring __type__ file backup failed : __message__",
|
||||||
|
"projects": {
|
||||||
|
"changing-project": "Setting active project : __project__",
|
||||||
|
"active-project": "Active project : __project__",
|
||||||
|
"no-active-project": "No active project : using default flows file",
|
||||||
|
"disabled": "Projects disabled : editorTheme.projects.enabled=false",
|
||||||
|
"git-not-found": "Projects disabled : git command not found",
|
||||||
|
"git-version-old": "Projects disabled : git __version__ too old"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,11 +177,9 @@ var persistentSettings = {
|
|||||||
userSettings[username] = settings;
|
userSettings[username] = settings;
|
||||||
try {
|
try {
|
||||||
assert.deepEqual(current,settings);
|
assert.deepEqual(current,settings);
|
||||||
console.log("skip the save");
|
|
||||||
return when.resolve();
|
return when.resolve();
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
globalSettings.users = userSettings;
|
globalSettings.users = userSettings;
|
||||||
console.log("saving");
|
|
||||||
return storage.saveSettings(globalSettings);
|
return storage.saveSettings(globalSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,9 +54,11 @@ var storageModuleInterface = {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
return when.reject(e);
|
return when.reject(e);
|
||||||
}
|
}
|
||||||
|
if (runtime.settings.hasOwnProperty("editorTheme") && runtime.settings.editorTheme.hasOwnProperty("projects")) {
|
||||||
if (storageModule.projects) {
|
if (storageModule.projects) {
|
||||||
storageModuleInterface.projects = storageModule.projects;
|
storageModuleInterface.projects = storageModule.projects;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return storageModule.init(runtime.settings,runtime);
|
return storageModule.init(runtime.settings,runtime);
|
||||||
},
|
},
|
||||||
getFlows: function() {
|
getFlows: function() {
|
||||||
|
@ -22,6 +22,7 @@ var clone = require('clone');
|
|||||||
var path = require("path");
|
var path = require("path");
|
||||||
|
|
||||||
var gitCommand = "git";
|
var gitCommand = "git";
|
||||||
|
var gitVersion;
|
||||||
var log;
|
var log;
|
||||||
|
|
||||||
function runGitCommand(args,cwd,env) {
|
function runGitCommand(args,cwd,env) {
|
||||||
@ -334,6 +335,15 @@ function removeRemote(cwd,name) {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
init: function(_settings,_runtime) {
|
init: function(_settings,_runtime) {
|
||||||
log = _runtime.log
|
log = _runtime.log
|
||||||
|
return new Promise(function(resolve,reject) {
|
||||||
|
runGitCommand(["--version"]).then(function(output) {
|
||||||
|
var m = / (\d\S+)/.exec(output);
|
||||||
|
gitVersion = m[1];
|
||||||
|
resolve(gitVersion);
|
||||||
|
}).catch(function(err) {
|
||||||
|
resolve(null);
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
initRepo: function(cwd) {
|
initRepo: function(cwd) {
|
||||||
return runGitCommand(["init"],cwd);
|
return runGitCommand(["init"],cwd);
|
||||||
|
@ -29,6 +29,9 @@ var Projects = require("./Project");
|
|||||||
var settings;
|
var settings;
|
||||||
var runtime;
|
var runtime;
|
||||||
|
|
||||||
|
var projectsEnabled;
|
||||||
|
var projectLogMessages = [];
|
||||||
|
|
||||||
var projectsDir;
|
var projectsDir;
|
||||||
var activeProject
|
var activeProject
|
||||||
|
|
||||||
@ -36,11 +39,15 @@ function init(_settings, _runtime) {
|
|||||||
settings = _settings;
|
settings = _settings;
|
||||||
runtime = _runtime;
|
runtime = _runtime;
|
||||||
log = runtime.log;
|
log = runtime.log;
|
||||||
gitTools.init(_settings, _runtime);
|
|
||||||
|
|
||||||
Projects.init(settings,runtime);
|
try {
|
||||||
|
if (settings.editorTheme.projects.enabled === false) {
|
||||||
projectsDir = fspath.join(settings.userDir,"projects");
|
projectLogMessages.push(log._("storage.localfilesystem.projects.disabled"))
|
||||||
|
projectsEnabled = false;
|
||||||
|
}
|
||||||
|
} catch(err) {
|
||||||
|
projectsEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (settings.flowFile) {
|
if (settings.flowFile) {
|
||||||
flowsFile = settings.flowFile;
|
flowsFile = settings.flowFile;
|
||||||
@ -73,6 +80,16 @@ function init(_settings, _runtime) {
|
|||||||
credentialsFile = fspath.join(settings.userDir,ffBase+"_cred"+ffExt);
|
credentialsFile = fspath.join(settings.userDir,ffBase+"_cred"+ffExt);
|
||||||
credentialsFileBackup = getBackupFilename(credentialsFile)
|
credentialsFileBackup = getBackupFilename(credentialsFile)
|
||||||
|
|
||||||
|
var setupProjectsPromise;
|
||||||
|
|
||||||
|
if (projectsEnabled) {
|
||||||
|
return gitTools.init(_settings, _runtime).then(function(gitVersion) {
|
||||||
|
if (!gitVersion) {
|
||||||
|
projectLogMessages.push(log._("storage.localfilesystem.projects.git-not-found"))
|
||||||
|
projectsEnabled = false;
|
||||||
|
} else {
|
||||||
|
Projects.init(settings,runtime);
|
||||||
|
projectsDir = fspath.join(settings.userDir,"projects");
|
||||||
if (!settings.readOnly) {
|
if (!settings.readOnly) {
|
||||||
return fs.ensureDir(projectsDir)
|
return fs.ensureDir(projectsDir)
|
||||||
//TODO: this is accessing settings from storage directly as settings
|
//TODO: this is accessing settings from storage directly as settings
|
||||||
@ -91,9 +108,11 @@ function init(_settings, _runtime) {
|
|||||||
activeProject = globalSettings.projects.activeProject;
|
activeProject = globalSettings.projects.activeProject;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
return when.resolve();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUserGitSettings(user) {
|
function getUserGitSettings(user) {
|
||||||
@ -263,9 +282,8 @@ function setActiveProject(user, projectName) {
|
|||||||
var globalProjectSettings = settings.get("projects");
|
var globalProjectSettings = settings.get("projects");
|
||||||
globalProjectSettings.activeProject = project.name;
|
globalProjectSettings.activeProject = project.name;
|
||||||
return settings.set("projects",globalProjectSettings).then(function() {
|
return settings.set("projects",globalProjectSettings).then(function() {
|
||||||
log.info(log._("storage.localfilesystem.changing-project",{project:activeProject||"none"}));
|
log.info(log._("storage.localfilesystem.projects.changing-project",{project:activeProject||"none"}));
|
||||||
log.info(log._("storage.localfilesystem.flows-file",{path:flowsFullPath}));
|
log.info(log._("storage.localfilesystem.flows-file",{path:flowsFullPath}));
|
||||||
|
|
||||||
// console.log("Updated file targets to");
|
// console.log("Updated file targets to");
|
||||||
// console.log(flowsFullPath)
|
// console.log(flowsFullPath)
|
||||||
// console.log(credentialsFile)
|
// console.log(credentialsFile)
|
||||||
@ -346,11 +364,16 @@ function getFlows() {
|
|||||||
log.info(log._("storage.localfilesystem.user-dir",{path:settings.userDir}));
|
log.info(log._("storage.localfilesystem.user-dir",{path:settings.userDir}));
|
||||||
if (activeProject) {
|
if (activeProject) {
|
||||||
return loadProject(activeProject).then(function() {
|
return loadProject(activeProject).then(function() {
|
||||||
log.info(log._("storage.localfilesystem.active-project",{project:activeProject.name||"none"}));
|
log.info(log._("storage.localfilesystem.projects.active-project",{project:activeProject.name||"none"}));
|
||||||
log.info(log._("storage.localfilesystem.flows-file",{path:flowsFullPath}));
|
log.info(log._("storage.localfilesystem.flows-file",{path:flowsFullPath}));
|
||||||
return getFlows();
|
return getFlows();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
if (projectsEnabled) {
|
||||||
|
log.warn(log._("storage.localfilesystem.projects.no-active-project"))
|
||||||
|
} else {
|
||||||
|
projectLogMessages.forEach(log.warn);
|
||||||
|
}
|
||||||
log.info(log._("storage.localfilesystem.flows-file",{path:flowsFullPath}));
|
log.info(log._("storage.localfilesystem.flows-file",{path:flowsFullPath}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user