diff --git a/editor/js/ui/deploy.js b/editor/js/ui/deploy.js index f8293e996..4dd9a3a2f 100644 --- a/editor/js/ui/deploy.js +++ b/editor/js/ui/deploy.js @@ -29,12 +29,43 @@ RED.deploy = (function() { $("#btn-deploy img").attr("src",deploymentTypes[type].img); } - function init() { + + /** + * options: + * type: "default" - Button with drop-down options - no further customisation available + * type: "simple" - Button without dropdown. Customisations: + * label: the text to display - default: "Deploy" + * icon : the icon to use. Null removes the icon. default: "red/images/deploy-full-o.png" + */ + function init(options) { + options = options || {}; + var type = options.type || "default"; - var deployButton = $('
  • '+ - ' Deploy'+ - ''+ - '
  • ').prependTo(".header-toolbar"); + if (type == "default") { + $('
  • '+ + ' Deploy'+ + ''+ + '
  • ').prependTo(".header-toolbar"); + RED.menu.init({id:"btn-deploy-options", + options: [ + {id:"btn-deploy-full",toggle:"deploy-type",icon:"red/images/deploy-full.png",label:"Full",sublabel:"Deploys everything in the workspace",onselect:function(s) { if(s){changeDeploymentType("full")}}}, + {id:"btn-deploy-flow",toggle:"deploy-type",icon:"red/images/deploy-flows.png",label:"Modified Flows",sublabel:"Only deploys flows that contain changed nodes", onselect:function(s) {if(s){changeDeploymentType("flows")}}}, + {id:"btn-deploy-node",toggle:"deploy-type",icon:"red/images/deploy-nodes.png",label:"Modified Nodes",sublabel:"Only deploys nodes that have changed",onselect:function(s) { if(s){changeDeploymentType("nodes")}}} + ] + }); + } else if (type == "simple") { + var label = options.label || "Deploy"; + var icon = 'red/images/deploy-full-o.png'; + if (options.hasOwnProperty('icon')) { + icon = options.icon; + } + + $('
  • '+ + ''+ + (icon?' ':'')+ + ''+label+''+ + '
  • ').prependTo(".header-toolbar"); + } $('#btn-deploy').click(function() { save(); }); @@ -61,14 +92,6 @@ RED.deploy = (function() { ] }); - RED.menu.init({id:"btn-deploy-options", - options: [ - {id:"btn-deploy-full",toggle:"deploy-type",icon:"red/images/deploy-full.png",label:"Full",sublabel:"Deploys everything in the workspace",onselect:function(s) { if(s){changeDeploymentType("full")}}}, - {id:"btn-deploy-flow",toggle:"deploy-type",icon:"red/images/deploy-flows.png",label:"Modified Flows",sublabel:"Only deploys flows that contain changed nodes", onselect:function(s) {if(s){changeDeploymentType("flows")}}}, - {id:"btn-deploy-node",toggle:"deploy-type",icon:"red/images/deploy-nodes.png",label:"Modified Nodes",sublabel:"Only deploys nodes that have changed",onselect:function(s) { if(s){changeDeploymentType("nodes")}}} - ] - }); - RED.nodes.on('change',function(state) { if (state.dirty) { window.onbeforeunload = function() {