1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #2763 from node-red/simple-git-setting

Allow project workflow to be configured via settings file
This commit is contained in:
Nick O'Leary 2021-01-08 15:20:11 +00:00 committed by GitHub
commit b0bc7ecacb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 10 deletions

View File

@ -43,9 +43,11 @@ RED.projects.userSettings = (function() {
function createWorkflowSection(pane) {
var defaultWorkflowMode = RED.settings.theme("projects.workflow.mode","manual");
var currentGitSettings = RED.settings.get('git') || {};
currentGitSettings.workflow = currentGitSettings.workflow || {};
currentGitSettings.workflow.mode = currentGitSettings.workflow.mode || "manual";
currentGitSettings.workflow.mode = currentGitSettings.workflow.mode || defaultWorkflowMode;
var title = $('<h3></h3>').text(RED._("editor:sidebar.project.userSettings.workflow")).appendTo(pane);

View File

@ -294,7 +294,10 @@ RED.sidebar.versionControl = (function() {
// TODO: this is a full refresh of the files - should be able to
// just do an incremental refresh
var workflowMode = ((RED.settings.get('git') || {}).workflow || {}).mode || "manual";
// Get the default workflow mode from theme settings
var defaultWorkflowMode = RED.settings.theme("projects.workflow.mode","manual");
// Check for the user-defined choice of mode
var workflowMode = ((RED.settings.get('git') || {}).workflow || {}).mode || defaultWorkflowMode;
if (workflowMode === 'auto') {
refresh(true);
} else {

View File

@ -421,7 +421,7 @@ Project.prototype.update = async function (user, data) {
}
return Promise.all(promises).then(function(res) {
var gitSettings = getUserGitSettings(user) || {};
var workflowMode = (gitSettings.workflow||{}).mode || "manual";
var workflowMode = (gitSettings.workflow||{}).mode || settings.editorTheme.projects.workflow.mode;
if (workflowMode === 'auto') {
return project.stageFile(modifiedFiles.map(f => project.paths[f])).then(() => {
return project.commit(user,{message:"Update "+modifiedFiles.join(", ")})

View File

@ -34,7 +34,7 @@ var projectsEnabled = false;
var projectLogMessages = [];
var projectsDir;
var activeProject
var activeProject;
var globalGitUser = false;
@ -106,6 +106,10 @@ function init(_settings, _runtime) {
} catch(err) {
}
} else {
// Ensure there's a default workflow mode set
settings.editorTheme.projects.workflow = {
mode: (settings.editorTheme.projects.workflow || {}).mode || "manual"
}
globalGitUser = gitConfig.user;
Projects.init(settings,runtime);
sshTools.init(settings);
@ -574,12 +578,14 @@ async function saveFlows(flows, user) {
}
return util.writeFile(flowsFullPath, flowData, flowsFileBackup).then(() => {
var gitSettings = getUserGitSettings(user) || {};
var workflowMode = (gitSettings.workflow||{}).mode || "manual";
if (activeProject && workflowMode === 'auto') {
if (activeProject) {
var workflowMode = (gitSettings.workflow||{}).mode || settings.editorTheme.projects.workflow.mode;
if (workflowMode === 'auto') {
return activeProject.stageFile([flowsFullPath, credentialsFile]).then(() => {
return activeProject.commit(user,{message:"Update flow files"})
})
}
}
});
}

View File

@ -292,7 +292,15 @@ module.exports = {
editorTheme: {
projects: {
// To enable the Projects feature, set this value to true
enabled: false
enabled: false,
workflow: {
// Set the default projects workflow mode.
// - manual - you must manually commit changes
// - auto - changes are automatically committed
// This can be overridden per-user from the 'Git config'
// section of 'User Settings' within the editor
mode: "manual"
}
}
}
}