mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	default stop/start feature to enabled:false
				
					
				
			This commit is contained in:
		@@ -56,7 +56,7 @@ module.exports = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Flows/state
 | 
					        // Flows/state
 | 
				
			||||||
        adminApp.get("/flows/state", needsPermission("flows.read"), flows.getState, apiUtil.errorHandler);
 | 
					        adminApp.get("/flows/state", needsPermission("flows.read"), flows.getState, apiUtil.errorHandler);
 | 
				
			||||||
        if (!settings.runtimeState || settings.runtimeState.enabled !== false) {
 | 
					        if (settings.runtimeState && settings.runtimeState.enabled === true) {
 | 
				
			||||||
            adminApp.post("/flows/state", needsPermission("flows.write"), flows.postState, apiUtil.errorHandler);
 | 
					            adminApp.post("/flows/state", needsPermission("flows.write"), flows.postState, apiUtil.errorHandler);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,12 +1,12 @@
 | 
				
			|||||||
RED.runtime = (function() {
 | 
					RED.runtime = (function() {
 | 
				
			||||||
    let state = ""
 | 
					    let state = ""
 | 
				
			||||||
    let settings = {ui: true, enabled: true};
 | 
					    let settings = {ui: false, enabled: false};
 | 
				
			||||||
    const STOPPED = "stopped"
 | 
					    const STOPPED = "stopped"
 | 
				
			||||||
    const STARTED = "started"
 | 
					    const STARTED = "started"
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
        init: function() {
 | 
					        init: function() {
 | 
				
			||||||
            // refresh the current runtime status from server
 | 
					            // refresh the current runtime status from server
 | 
				
			||||||
            settings = RED.settings.runtimeState;
 | 
					            settings = Object.assign({}, settings, RED.settings.runtimeState);
 | 
				
			||||||
            RED.runtime.requestState()
 | 
					            RED.runtime.requestState()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // {id:"flows-run-state", started: false, state: "stopped", retain:true}
 | 
					            // {id:"flows-run-state", started: false, state: "stopped", retain:true}
 | 
				
			||||||
@@ -29,7 +29,7 @@ RED.runtime = (function() {
 | 
				
			|||||||
            // disable pointer events on node buttons (e.g. inject/debug nodes)
 | 
					            // disable pointer events on node buttons (e.g. inject/debug nodes)
 | 
				
			||||||
            $(".red-ui-flow-node-button").toggleClass("red-ui-flow-node-button-stopped", state === STOPPED)
 | 
					            $(".red-ui-flow-node-button").toggleClass("red-ui-flow-node-button-stopped", state === STOPPED)
 | 
				
			||||||
            // show/hide Start/Stop based on current state
 | 
					            // show/hide Start/Stop based on current state
 | 
				
			||||||
            if(!RED.settings.runtimeState || RED.settings.runtimeState.ui !== false) {
 | 
					            if(settings.enabled === true && settings.ui === true) {
 | 
				
			||||||
                RED.menu.setVisible("deploymenu-item-runtime-stop", state === STARTED)
 | 
					                RED.menu.setVisible("deploymenu-item-runtime-stop", state === STARTED)
 | 
				
			||||||
                RED.menu.setVisible("deploymenu-item-runtime-start", state === STOPPED)
 | 
					                RED.menu.setVisible("deploymenu-item-runtime-start", state === STOPPED)
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -69,7 +69,7 @@ RED.deploy = (function() {
 | 
				
			|||||||
                    {id:"deploymenu-item-node",toggle:"deploy-type",icon:"red/images/deploy-nodes.svg",label:RED._("deploy.modifiedNodes"),sublabel:RED._("deploy.modifiedNodesDesc"),onselect:function(s) { if(s){changeDeploymentType("nodes")}}},
 | 
					                    {id:"deploymenu-item-node",toggle:"deploy-type",icon:"red/images/deploy-nodes.svg",label:RED._("deploy.modifiedNodes"),sublabel:RED._("deploy.modifiedNodesDesc"),onselect:function(s) { if(s){changeDeploymentType("nodes")}}},
 | 
				
			||||||
                    null
 | 
					                    null
 | 
				
			||||||
            ]
 | 
					            ]
 | 
				
			||||||
            if(!RED.settings.runtimeState || RED.settings.runtimeState.ui !== false) {
 | 
					            if(RED.settings.runtimeState && RED.settings.runtimeState.ui === true) {
 | 
				
			||||||
                mainMenuItems.push({id:"deploymenu-item-runtime-start", icon:"red/images/start.svg",label:"Start"/*RED._("deploy.startFlows")*/,sublabel:"Start Flows" /*RED._("deploy.startFlowsDesc")*/,onselect:"core:start-flows", visible:false})
 | 
					                mainMenuItems.push({id:"deploymenu-item-runtime-start", icon:"red/images/start.svg",label:"Start"/*RED._("deploy.startFlows")*/,sublabel:"Start Flows" /*RED._("deploy.startFlowsDesc")*/,onselect:"core:start-flows", visible:false})
 | 
				
			||||||
                mainMenuItems.push({id:"deploymenu-item-runtime-stop", icon:"red/images/stop.svg",label:"Stop"/*RED._("deploy.startFlows")*/,sublabel:"Stop Flows" /*RED._("deploy.startFlowsDesc")*/,onselect:"core:stop-flows", visible:false})
 | 
					                mainMenuItems.push({id:"deploymenu-item-runtime-stop", icon:"red/images/stop.svg",label:"Stop"/*RED._("deploy.startFlows")*/,sublabel:"Stop Flows" /*RED._("deploy.startFlowsDesc")*/,onselect:"core:stop-flows", visible:false})
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -310,7 +310,7 @@ var api = module.exports = {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(runtime.settings.runtimeState ? runtime.settings.runtimeState.enabled === false : false) {
 | 
					        if(!runtime.settings.runtimeState || runtime.settings.runtimeState.enabled !== true) {
 | 
				
			||||||
            throw (makeError("Method Not Allowed", "not_allowed", 405))
 | 
					            throw (makeError("Method Not Allowed", "not_allowed", 405))
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        switch (opts.requestedState) {
 | 
					        switch (opts.requestedState) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -153,11 +153,11 @@ var api = module.exports = {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            safeSettings.runtimeState = {
 | 
					            safeSettings.runtimeState = {
 | 
				
			||||||
                //unless runtimeState.ui and runtimeState.enabled are explicitly false, they will default to true.
 | 
					                //unless runtimeState.ui and runtimeState.enabled are explicitly true, they will default to false.
 | 
				
			||||||
                enabled: (runtime.settings.runtimeState && runtime.settings.runtimeState.enabled === false) ? false : true,
 | 
					                enabled: !!runtime.settings.runtimeState && runtime.settings.runtimeState.enabled === true,
 | 
				
			||||||
                ui: (runtime.settings.runtimeState && runtime.settings.runtimeState.ui === false) ? false : true
 | 
					                ui: !!runtime.settings.runtimeState && runtime.settings.runtimeState.ui === true
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if(safeSettings.runtimeState.enabled === false) {
 | 
					            if(safeSettings.runtimeState.enabled !== true) {
 | 
				
			||||||
                safeSettings.runtimeState.ui = false; // cannot have UI without endpoint
 | 
					                safeSettings.runtimeState.ui = false; // cannot have UI without endpoint
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										12
									
								
								packages/node_modules/node-red/settings.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								packages/node_modules/node-red/settings.js
									
									
									
									
										vendored
									
									
								
							@@ -269,17 +269,17 @@ module.exports = {
 | 
				
			|||||||
        ui: true,
 | 
					        ui: true,
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    /** Configure runtimeState options 
 | 
					    /** Configure runtimeState options 
 | 
				
			||||||
     * - enabled:  When `enabled` is `true` (or unset), runtime Start/Stop will
 | 
					     * - enabled:  When `enabled` is `true` flows runtime can be Started/Stoped 
 | 
				
			||||||
     *   be available at http://localhost:1880/flows/state  
 | 
					     *   by POSTing to available at http://localhost:1880/flows/state  
 | 
				
			||||||
     * - ui: When `ui` is `true` (or unset), the action `core:start-flows` and 
 | 
					     * - ui: When `ui` is `true`, the action `core:start-flows` and 
 | 
				
			||||||
     *   `core:stop-flows` be available to logged in users of node-red editor
 | 
					     *   `core:stop-flows` will be available to logged in users of node-red editor
 | 
				
			||||||
     *   Also, the deploy menu (when set to default) will show a stop or start button
 | 
					     *   Also, the deploy menu (when set to default) will show a stop or start button
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    runtimeState: {
 | 
					    runtimeState: {
 | 
				
			||||||
        /** enable or disable flows/state endpoint. Must be set to `false` to disable */
 | 
					        /** enable or disable flows/state endpoint. Must be set to `false` to disable */
 | 
				
			||||||
        enabled: true,
 | 
					        enabled: false,
 | 
				
			||||||
        /** show or hide runtime stop/start options in the node-red editor. Must be set to `false` to hide */
 | 
					        /** show or hide runtime stop/start options in the node-red editor. Must be set to `false` to hide */
 | 
				
			||||||
        ui: true,
 | 
					        ui: false,
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    /** Configure the logging output */
 | 
					    /** Configure the logging output */
 | 
				
			||||||
    logging: {
 | 
					    logging: {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user