diff --git a/client/galaxy/scripts/mvc/history/options-menu.js b/client/galaxy/scripts/mvc/history/options-menu.js index e2393347daa..48d68c1fe30 100644 --- a/client/galaxy/scripts/mvc/history/options-menu.js +++ b/client/galaxy/scripts/mvc/history/options-menu.js @@ -141,30 +141,9 @@ var menu = [ } ]; - // Webhooks +Webhooks.addToHistoryMenu(_l, menu); -var webhooks = new Webhooks.Webhooks(); -webhooks.url = Galaxy.root + 'api/webhooks/history-menu/all'; -webhooks.fetch({ - async: false, // slows down History Panel loading - success: function() { - if (webhooks.length > 0) { - menu.push({ - html : _l( 'Webhooks' ), - header : true - }); - - $.each(webhooks.models, function(index, model) { - var webhook = model.toJSON(); - menu.push({ - html : _l( webhook.config.title ), - anon : true - }); - }); - } - } -}); function buildMenu( isAnon, purgeAllowed, urlRoot ){ return _.clone( menu ).filter( function( menuOption ){ diff --git a/client/galaxy/scripts/mvc/tool/tool-form.js b/client/galaxy/scripts/mvc/tool/tool-form.js index 001f21c0e27..d3f283b841f 100644 --- a/client/galaxy/scripts/mvc/tool/tool-form.js +++ b/client/galaxy/scripts/mvc/tool/tool-form.js @@ -85,7 +85,7 @@ define([ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-modal', 'mvc/tool/tool-form if ( response.jobs && response.jobs.length > 0 ) { self.$el.append( $( '
', { id: 'webhook-view' } ) ); var WebhookApp = new Webhooks.WebhookView({ - urlRoot: Galaxy.root + 'api/webhooks/tools' + urlRoot: Galaxy.root + 'api/webhooks/tool' }); } diff --git a/client/galaxy/scripts/mvc/webhooks.js b/client/galaxy/scripts/mvc/webhooks.js index 790ac2a1ede..55b3c938b29 100644 --- a/client/galaxy/scripts/mvc/webhooks.js +++ b/client/galaxy/scripts/mvc/webhooks.js @@ -5,7 +5,7 @@ define([], function() { var WebhookModel = Backbone.Model.extend({ defaults: { - activate: true + activate: false } }); @@ -30,29 +30,73 @@ define([], function() { render: function() { var webhook = this.model.toJSON(); - - if (webhook.type == 'masthead' && webhook.activate) { - // There must be a better way to make sure Galaxy is fully loaded - $(document).ready(function() { - Galaxy.page.masthead.collection.add({ - id : webhook.name, - icon : (typeof webhook.config.icon != 'undefined') ? webhook.config.icon : '', - url : (typeof webhook.config.url != 'undefined') ? webhook.config.url : '', - tooltip : (typeof webhook.config.tooltip != 'undefined') ? webhook.config.tooltip : '', - // visible : webhook.activate - }); - }); + if (webhook.activate) { + this.$el.html(''); + if (webhook.styles) $('', {type: 'text/css'}).text(webhook.styles).appendTo('head'); + if (webhook.script) $('', {type: 'text/javascript'}).text(webhook.script).appendTo('head'); } - - this.$el.html(''); - if (webhook.styles) $('', {type: 'text/css'}).text(webhook.styles).appendTo('head'); - if (webhook.script) $('', {type: 'text/javascript'}).text(webhook.script).appendTo('head'); return this; } }); + var addToMastheadMenu = function() { + var webhooks = new Webhooks(); + webhooks.url = Galaxy.root + 'api/webhooks/masthead/all'; + webhooks.fetch({ + success: function() { + $(document).ready(function() { + $.each(webhooks.models, function(index, model) { + var webhook = model.toJSON(); + if (webhook.activate) { + Galaxy.page.masthead.collection.add({ + id : webhook.name, + icon : (typeof webhook.config.icon != 'undefined') ? webhook.config.icon : '', + url : (typeof webhook.config.url != 'undefined') ? webhook.config.url : '', + tooltip : (typeof webhook.config.tooltip != 'undefined') ? webhook.config.tooltip : '', + // onclick : function() {}, + // visible : webhook.activate + }); + } + }); + }); + } + }); + }; + + var addToHistoryMenu = function(_l, menu) { + var webhooks = new Webhooks(); + webhooks.url = Galaxy.root + 'api/webhooks/history-menu/all'; + webhooks.fetch({ + async: false, // slows down History Panel loading + success: function() { + var webhooks_menu = []; + + $.each(webhooks.models, function(index, model) { + var webhook = model.toJSON(); + if (webhook.activate) { + webhooks_menu.push({ + html : _l( webhook.config.title ), + // func: function() {}, + anon : true + }); + } + }); + + if (webhooks_menu.length > 0) { + webhooks_menu.unshift({ + html : _l( 'Webhooks' ), + header : true + }); + $.merge(menu, webhooks_menu); + } + } + }); + }; + return { Webhooks: Webhooks, - WebhookView: WebhookView + WebhookView: WebhookView, + addToMastheadMenu: addToMastheadMenu, + addToHistoryMenu: addToHistoryMenu }; }); diff --git a/config/plugins/webhooks/history_test1/config/history_test1.yml b/config/plugins/webhooks/history_test1/config/history_test1.yml index 2b67355f8f7..cff4be38932 100644 --- a/config/plugins/webhooks/history_test1/config/history_test1.yml +++ b/config/plugins/webhooks/history_test1/config/history_test1.yml @@ -2,3 +2,4 @@ name: history_test1 title: History Menu Webhook Item 1 type: - history-menu +activate: false diff --git a/config/plugins/webhooks/history_test2/config/history_test2.yml b/config/plugins/webhooks/history_test2/config/history_test2.yml index 7c90ec87823..11241863254 100644 --- a/config/plugins/webhooks/history_test2/config/history_test2.yml +++ b/config/plugins/webhooks/history_test2/config/history_test2.yml @@ -2,3 +2,4 @@ name: history_test2 title: History Menu Webhook Item 2 type: - history-menu +activate: false diff --git a/config/plugins/webhooks/masthead_test/config/masthead_test.yml b/config/plugins/webhooks/masthead_test/config/masthead_test.yml index b91c5f372fd..f1f2172f221 100644 --- a/config/plugins/webhooks/masthead_test/config/masthead_test.yml +++ b/config/plugins/webhooks/masthead_test/config/masthead_test.yml @@ -1,6 +1,8 @@ name: masthead_test -icon: fa-repeat type: - masthead +activate: false + +icon: fa-repeat tooltip: Masthead Plugin Test -activate: true + diff --git a/config/plugins/webhooks/phdcomics/config/phdcomics.yaml b/config/plugins/webhooks/phdcomics/config/phdcomics.yaml index e0cc09075ed..22feba5797c 100644 --- a/config/plugins/webhooks/phdcomics/config/phdcomics.yaml +++ b/config/plugins/webhooks/phdcomics/config/phdcomics.yaml @@ -1,4 +1,5 @@ name: phdcomics type: - - tools + - tool - workflow +activate: false diff --git a/config/plugins/webhooks/xkcd/config/xkcd.yml b/config/plugins/webhooks/xkcd/config/xkcd.yml index ff6cce51e27..c8ce604b002 100644 --- a/config/plugins/webhooks/xkcd/config/xkcd.yml +++ b/config/plugins/webhooks/xkcd/config/xkcd.yml @@ -1,4 +1,5 @@ name: xkcd type: - - tools + - tool - workflow +activate: true diff --git a/lib/galaxy/webhooks/__init__.py b/lib/galaxy/webhooks/__init__.py index 38ac36ea05c..ccd13f75d67 100644 --- a/lib/galaxy/webhooks/__init__.py +++ b/lib/galaxy/webhooks/__init__.py @@ -13,9 +13,10 @@ log = logging.getLogger(__name__) <<<<<<< HEAD class Webhook(object): - def __init__(self, w_name, w_type, w_path): + def __init__(self, w_name, w_type, w_activate, w_path): self.name = w_name self.type = w_type + self.activate = w_activate self.path = w_path self.styles = '' self.script = '' @@ -26,6 +27,7 @@ class Webhook(object): return { 'name': self.name, 'type': self.type, + 'activate': self.activate, 'styles': self.styles, 'script': self.script, 'config': self.config @@ -67,7 +69,12 @@ class WebhooksRegistry(object): with open(os.path.join(config_dir, config_file)) as f: config = yaml.load(f) path = os.path.normpath(os.path.join(config_dir, '..')) - webhook = Webhook(config['name'], config['type'], path) + webhook = Webhook( + config['name'], + config['type'], + config['activate'], + path, + ) # Read styles into a string, assuming all styles are in a # single file diff --git a/static/maps/mvc/webhooks.js.map b/static/maps/mvc/webhooks.js.map index 112aeb495a3..84e87fe4bf6 100644 --- a/static/maps/mvc/webhooks.js.map +++ b/static/maps/mvc/webhooks.js.map @@ -1 +1 @@ -{"version":3,"file":"webhooks.js","sources":["../../src/mvc/webhooks.js"],"names":["define","WebhookModel","Backbone","Model","extend","defaults","activate","Webhooks","Collection","model","WebhookView","View","el","initialize","options","me","this","urlRoot","fetch","success","render","webhook","toJSON","type","$","document","ready","Galaxy","page","masthead","collection","add","id","name","icon","config","url","tooltip","$el","html","styles","text","appendTo","script"],"mappings":"AAGAA,UAAW,WAEP,GAAIC,GAAeC,SAASC,MAAMC,QAC9BC,UACIC,UAAU,KAIdC,EAAWL,SAASM,WAAWJ,QAC/BK,MAAOR,IAGPS,EAAcR,SAASS,KAAKP,QAC5BQ,GAAI,gBAEJC,WAAY,SAASC,GACjB,GAAIC,GAAKC,IAETA,MAAKP,MAAQ,GAAIR,GACjBe,KAAKP,MAAMQ,QAAUH,EAAQG,QAC7BD,KAAKP,MAAMS,OACPC,QAAS,WACLJ,EAAGK,aAKfA,OAAQ,WACJ,GAAIC,GAAUL,KAAKP,MAAMa,QAkBzB,OAhBoB,YAAhBD,EAAQE,MAAsBF,EAAQf,UAEtCkB,EAAEC,UAAUC,MAAM,WACdC,OAAOC,KAAKC,SAASC,WAAWC,KAC5BC,GAAUX,EAAQY,KAClBC,KAAyC,mBAAvBb,GAAQc,OAAOD,KAAuBb,EAAQc,OAAOD,KAAO,GAC9EE,IAAwC,mBAAtBf,GAAQc,OAAOC,IAAsBf,EAAQc,OAAOC,IAAM,GAC5EC,QAA4C,mBAA1BhB,GAAQc,OAAOE,QAA0BhB,EAAQc,OAAOE,QAAU,OAMhGrB,KAAKsB,IAAIC,KAAK,YAAclB,EAAQY,KAAO,YACvCZ,EAAQmB,QAAQhB,EAAE,YAAaD,KAAM,aAAakB,KAAKpB,EAAQmB,QAAQE,SAAS,QAChFrB,EAAQsB,QAAQnB,EAAE,aAAcD,KAAM,oBAAoBkB,KAAKpB,EAAQsB,QAAQD,SAAS,QACrF1B,OAIf,QACIT,SAAUA,EACVG,YAAaA"} \ No newline at end of file +{"version":3,"file":"webhooks.js","sources":["../../src/mvc/webhooks.js"],"names":["define","WebhookModel","Backbone","Model","extend","defaults","activate","Webhooks","Collection","model","WebhookView","View","el","initialize","options","me","this","urlRoot","fetch","success","render","webhook","toJSON","$el","html","name","styles","$","type","text","appendTo","script","addToMastheadMenu","webhooks","url","Galaxy","root","document","ready","each","models","index","page","masthead","collection","add","id","icon","config","tooltip","addToHistoryMenu","_l","menu","async","webhooks_menu","push","title","anon","length","unshift","header","merge"],"mappings":"AAGAA,UAAW,WAEP,GAAIC,GAAeC,SAASC,MAAMC,QAC9BC,UACIC,UAAU,KAIdC,EAAWL,SAASM,WAAWJ,QAC/BK,MAAOR,IAGPS,EAAcR,SAASS,KAAKP,QAC5BQ,GAAI,gBAEJC,WAAY,SAASC,GACjB,GAAIC,GAAKC,IAETA,MAAKP,MAAQ,GA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cK,SACVnC,KAAS2B,EAAI,YACbS,QAAS,IAEbjC,EAAEkC,MAAMT,EAAME,OAM9B,QACI/C,SAAUA,EACVG,YAAaA,EACbsB,kBAAmBA,EACnBkB,iBAAkBA"} \ No newline at end of file diff --git a/static/scripts/mvc/webhooks.js b/static/scripts/mvc/webhooks.js index 7dd9c2f8976..478711fa344 100644 --- a/static/scripts/mvc/webhooks.js +++ b/static/scripts/mvc/webhooks.js @@ -1,2 +1,2 @@ -define([],function(){var a=Backbone.Model.extend({defaults:{activate:!0}}),b=Backbone.Collection.extend({model:a}),c=Backbone.View.extend({el:"#webhook-view",initialize:function(b){var c=this;this.model=new a,this.model.urlRoot=b.urlRoot,this.model.fetch({success:function(){c.render()}})},render:function(){var a=this.model.toJSON();return"masthead"==a.type&&a.activate&&$(document).ready(function(){Galaxy.page.masthead.collection.add({id:a.name,icon:"undefined"!=typeof a.config.icon?a.config.icon:"",url:"undefined"!=typeof a.config.url?a.config.url:"",tooltip:"undefined"!=typeof a.config.tooltip?a.config.tooltip:""})}),this.$el.html(''),a.styles&&$("",{type:"text/css"}).text(a.styles).appendTo("head"),a.script&&$("",{type:"text/javascript"}).text(a.script).appendTo("head"),this}});return{Webhooks:b,WebhookView:c}}); +define([],function(){var a=Backbone.Model.extend({defaults:{activate:!1}}),b=Backbone.Collection.extend({model:a}),c=Backbone.View.extend({el:"#webhook-view",initialize:function(b){var c=this;this.model=new a,this.model.urlRoot=b.urlRoot,this.model.fetch({success:function(){c.render()}})},render:function(){var a=this.model.toJSON();return a.activate&&(this.$el.html(''),a.styles&&$("",{type:"text/css"}).text(a.styles).appendTo("head"),a.script&&$("",{type:"text/javascript"}).text(a.script).appendTo("head")),this}}),d=function(){var a=new b;a.url=Galaxy.root+"api/webhooks/masthead/all",a.fetch({success:function(){$(document).ready(function(){$.each(a.models,function(a,b){var c=b.toJSON();c.activate&&Galaxy.page.masthead.collection.add({id:c.name,icon:"undefined"!=typeof c.config.icon?c.config.icon:"",url:"undefined"!=typeof c.config.url?c.config.url:"",tooltip:"undefined"!=typeof c.config.tooltip?c.config.tooltip:""})})})}})},e=function(a,c){var d=new b;d.url=Galaxy.root+"api/webhooks/history-menu/all",d.fetch({async:!1,success:function(){var b=[];$.each(d.models,function(c,d){var e=d.toJSON();e.activate&&b.push({html:a(e.config.title),anon:!0})}),b.length>0&&(b.unshift({html:a("Webhooks"),header:!0}),$.merge(c,b))}})};return{Webhooks:b,WebhookView:c,addToMastheadMenu:d,addToHistoryMenu:e}}); //# sourceMappingURL=../../maps/mvc/webhooks.js.map \ No newline at end of file