From 4e04393b701cec86469e3e381b033a762e628cbc Mon Sep 17 00:00:00 2001 From: guerler Date: Mon, 18 Apr 2022 12:21:23 -0400 Subject: [PATCH] Adjust tool tour generator plugin, remove legacy history dependence --- .../History/adapters/HistoryPanelProxy.js | 4 +- .../store/historyStore/historyItemsStore.js | 2 +- .../webhooks/demo/tour_generator/script.js | 4 +- .../demo/tour_generator/tour_generator.js | 77 +++++++------------ .../selenium/test_tool_describing_tours.py | 5 -- 5 files changed, 34 insertions(+), 58 deletions(-) diff --git a/client/src/components/History/adapters/HistoryPanelProxy.js b/client/src/components/History/adapters/HistoryPanelProxy.js index e90a37e8619..cb0bf6d4295 100644 --- a/client/src/components/History/adapters/HistoryPanelProxy.js +++ b/client/src/components/History/adapters/HistoryPanelProxy.js @@ -23,8 +23,8 @@ export class HistoryPanelProxy { this.models = models; this.unwatch = null; }, - each(callback) { - const historyItems = store.getters.getHistoryItems({ historyId: model.id, filterText: "" }); + each(callback, filterText = "") { + const historyItems = store.getters.getHistoryItems({ historyId: model.id, filterText: filterText }); historyItems.forEach((model) => { callback(new Backbone.Model(model)); }); diff --git a/client/src/store/historyStore/historyItemsStore.js b/client/src/store/historyStore/historyItemsStore.js index 945c961a98c..8a0976a3ee1 100644 --- a/client/src/store/historyStore/historyItemsStore.js +++ b/client/src/store/historyStore/historyItemsStore.js @@ -48,7 +48,7 @@ const getQueryString = (filterText) => { }; const actions = { - fetchHistoryItems: async ({ commit, dispatch }, { historyId, filterText, offset }) => { + fetchHistoryItems: async ({ commit }, { historyId, filterText, offset }) => { const queryString = getQueryString(filterText); const params = `v=dev&order=hid&offset=${offset}&limit=${limit}`; const url = `api/histories/${historyId}/contents?${params}&${queryString}`; diff --git a/config/plugins/webhooks/demo/tour_generator/script.js b/config/plugins/webhooks/demo/tour_generator/script.js index 81a57948472..372b52c7334 100644 --- a/config/plugins/webhooks/demo/tour_generator/script.js +++ b/config/plugins/webhooks/demo/tour_generator/script.js @@ -335,7 +335,7 @@ var r=arguments[3];Object.defineProperty(exports,"__esModule",{value:!0}),export },{"./index-default.js":"HxwB","./index.js":"lIGW"}],"kFNo":[function(require,module,exports) { var global = arguments[3]; var define; -var t,e=arguments[3];!function(i){var n="object"==typeof self&&self.self===self&&self||"object"==typeof e&&e.global===e&&e;if("function"==typeof t&&t.amd)t(["underscore","jquery","exports"],function(t,e,s){n.Backbone=i(n,s,t,e)});else if("undefined"!=typeof exports){var s,r=require("underscore");try{s=require("jquery")}catch(o){}i(n,exports,r,s)}else n.Backbone=i(n,{},n._,n.jQuery||n.Zepto||n.ender||n.$)}(function(t,e,i,n){var s=t.Backbone,r=Array.prototype.slice;e.VERSION="1.4.0",e.$=n,e.noConflict=function(){return t.Backbone=s,this},e.emulateHTTP=!1,e.emulateJSON=!1;var o,a=e.Events={},h=/\s+/,u=function(t,e,n,s,r){var o,a=0;if(n&&"object"==typeof n){void 0!==s&&"context"in r&&void 0===r.context&&(r.context=s);for(o=i.keys(n);athis.length&&(s=this.length),s<0&&(s+=this.length+1);var r,o,a=[],h=[],u=[],c=[],l={},d=e.add,f=e.merge,p=e.remove,g=!1,v=this.comparator&&null==s&&!1!==e.sort,m=i.isString(this.comparator)?this.comparator:null;for(o=0;o7),this._useHashChange=this._wantsHashChange&&this._hasHashChange,this._wantsPushState=!!this.options.pushState,this._hasPushState=!(!this.history||!this.history.pushState),this._usePushState=this._wantsPushState&&this._hasPushState,this.fragment=this.getFragment(),this.root=("/"+this.root+"/").replace(F,"/"),this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot()){var e=this.root.slice(0,-1)||"/";return this.location.replace(e+"#"+this.getPath()),!0}this._hasPushState&&this.atRoot()&&this.navigate(this.getHash(),{replace:!0})}if(!this._hasHashChange&&this._wantsHashChange&&!this._usePushState){this.iframe=document.createElement("iframe"),this.iframe.src="javascript:0",this.iframe.style.display="none",this.iframe.tabIndex=-1;var n=document.body,s=n.insertBefore(this.iframe,n.firstChild).contentWindow;s.document.open(),s.document.close(),s.location.hash="#"+this.fragment}var r=window.addEventListener||function(t,e){return attachEvent("on"+t,e)};if(this._usePushState?r("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe?r("hashchange",this.checkUrl,!1):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),!this.options.silent)return this.loadUrl()},stop:function(){var t=window.removeEventListener||function(t,e){return detachEvent("on"+t,e)};this._usePushState?t("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe&&t("hashchange",this.checkUrl,!1),this.iframe&&(document.body.removeChild(this.iframe),this.iframe=null),this._checkUrlInterval&&clearInterval(this._checkUrlInterval),z.started=!1},route:function(t,e){this.handlers.unshift({route:t,callback:e})},checkUrl:function(t){var e=this.getFragment();if(e===this.fragment&&this.iframe&&(e=this.getHash(this.iframe.contentWindow)),e===this.fragment)return!1;this.iframe&&this.navigate(e),this.loadUrl()},loadUrl:function(t){return!!this.matchRoot()&&(t=this.fragment=this.getFragment(t),i.some(this.handlers,function(e){if(e.route.test(t))return e.callback(t),!0}))},navigate:function(t,e){if(!z.started)return!1;e&&!0!==e||(e={trigger:!!e}),t=this.getFragment(t||"");var i=this.root;""!==t&&"?"!==t.charAt(0)||(i=i.slice(0,-1)||"/");var n=i+t;t=t.replace(B,"");var s=this.decodeFragment(t);if(this.fragment!==s){if(this.fragment=s,this._usePushState)this.history[e.replace?"replaceState":"pushState"]({},document.title,n);else{if(!this._wantsHashChange)return this.location.assign(n);if(this._updateHash(this.location,t,e.replace),this.iframe&&t!==this.getHash(this.iframe.contentWindow)){var r=this.iframe.contentWindow;e.replace||(r.document.open(),r.document.close()),this._updateHash(r.location,t,e.replace)}}return e.trigger?this.loadUrl(t):void 0}},_updateHash:function(t,e,i){if(i){var n=t.href.replace(/(javascript:|#).*$/,"");t.replace(n+"#"+e)}else t.hash="#"+e}}),e.history=new z;m.extend=_.extend=M.extend=T.extend=z.extend=function(t,e){var n,s=this;return n=t&&i.has(t,"constructor")?t.constructor:function(){return s.apply(this,arguments)},i.extend(n,s,e),n.prototype=i.create(s.prototype,t),n.prototype.constructor=n,n.__super__=s.prototype,n};var J=function(){throw new Error('A "url" property or function must be specified')},L=function(t,e){var i=e.error;e.error=function(n){i&&i.call(e.context,t,n,e),t.trigger("error",t,n,e)}};return e}); +var t,e=arguments[3];!function(i){var n="object"==typeof self&&self.self===self&&self||"object"==typeof e&&e.global===e&&e;if("function"==typeof t&&t.amd)t(["underscore","jquery","exports"],function(t,e,s){n.Backbone=i(n,s,t,e)});else if("undefined"!=typeof exports){var s,r=require("underscore");try{s=require("jquery")}catch(o){}i(n,exports,r,s)}else n.Backbone=i(n,{},n._,n.jQuery||n.Zepto||n.ender||n.$)}(function(t,e,i,n){var s=t.Backbone,r=Array.prototype.slice;e.VERSION="1.4.1",e.$=n,e.noConflict=function(){return t.Backbone=s,this},e.emulateHTTP=!1,e.emulateJSON=!1;var o,h=e.Events={},a=/\s+/,u=function(t,e,n,s,r){var o,h=0;if(n&&"object"==typeof n){void 0!==s&&"context"in r&&void 0===r.context&&(r.context=s);for(o=i.keys(n);hthis.length&&(s=this.length),s<0&&(s+=this.length+1);var r,o,h=[],a=[],u=[],c=[],l={},d=e.add,f=e.merge,p=e.remove,g=!1,v=this.comparator&&null==s&&!1!==e.sort,m=i.isString(this.comparator)?this.comparator:null;for(o=0;o7),this._useHashChange=this._wantsHashChange&&this._hasHashChange,this._wantsPushState=!!this.options.pushState,this._hasPushState=!(!this.history||!this.history.pushState),this._usePushState=this._wantsPushState&&this._hasPushState,this.fragment=this.getFragment(),this.root=("/"+this.root+"/").replace(F,"/"),this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot()){var e=this.root.slice(0,-1)||"/";return this.location.replace(e+"#"+this.getPath()),!0}this._hasPushState&&this.atRoot()&&this.navigate(this.getHash(),{replace:!0})}if(!this._hasHashChange&&this._wantsHashChange&&!this._usePushState){this.iframe=document.createElement("iframe"),this.iframe.src="javascript:0",this.iframe.style.display="none",this.iframe.tabIndex=-1;var n=document.body,s=n.insertBefore(this.iframe,n.firstChild).contentWindow;s.document.open(),s.document.close(),s.location.hash="#"+this.fragment}var r=window.addEventListener||function(t,e){return attachEvent("on"+t,e)};if(this._usePushState?r("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe?r("hashchange",this.checkUrl,!1):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),!this.options.silent)return this.loadUrl()},stop:function(){var t=window.removeEventListener||function(t,e){return detachEvent("on"+t,e)};this._usePushState?t("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe&&t("hashchange",this.checkUrl,!1),this.iframe&&(document.body.removeChild(this.iframe),this.iframe=null),this._checkUrlInterval&&clearInterval(this._checkUrlInterval),z.started=!1},route:function(t,e){this.handlers.unshift({route:t,callback:e})},checkUrl:function(t){var e=this.getFragment();if(e===this.fragment&&this.iframe&&(e=this.getHash(this.iframe.contentWindow)),e===this.fragment)return!1;this.iframe&&this.navigate(e),this.loadUrl()},loadUrl:function(t){return!!this.matchRoot()&&(t=this.fragment=this.getFragment(t),i.some(this.handlers,function(e){if(e.route.test(t))return e.callback(t),!0}))},navigate:function(t,e){if(!z.started)return!1;e&&!0!==e||(e={trigger:!!e}),t=this.getFragment(t||"");var i=this.root;""!==t&&"?"!==t.charAt(0)||(i=i.slice(0,-1)||"/");var n=i+t;t=t.replace(B,"");var s=this.decodeFragment(t);if(this.fragment!==s){if(this.fragment=s,this._usePushState)this.history[e.replace?"replaceState":"pushState"]({},document.title,n);else{if(!this._wantsHashChange)return this.location.assign(n);if(this._updateHash(this.location,t,e.replace),this.iframe&&t!==this.getHash(this.iframe.contentWindow)){var r=this.iframe.contentWindow;e.replace||(r.document.open(),r.document.close()),this._updateHash(r.location,t,e.replace)}}return e.trigger?this.loadUrl(t):void 0}},_updateHash:function(t,e,i){if(i){var n=t.href.replace(/(javascript:|#).*$/,"");t.replace(n+"#"+e)}else t.hash="#"+e}}),e.history=new z;m.extend=_.extend=M.extend=A.extend=z.extend=function(t,e){var n,s=this;return n=t&&i.has(t,"constructor")?t.constructor:function(){return s.apply(this,arguments)},i.extend(n,s,e),n.prototype=i.create(s.prototype,t),n.prototype.constructor=n,n.__super__=s.prototype,n};var J=function(){throw new Error('A "url" property or function must be specified')},L=function(t,e){var i=e.error;e.error=function(n){i&&i.call(e.context,t,n,e),t.trigger("error",t,n,e)}};return e}); },{"underscore":"XWoq","jquery":"HlZQ"}],"wXLC":[function(require,module,exports) { -"use strict";var e=n(require("toastr")),t=n(require("backbone")),r=n(require("underscore"));function o(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(o=function(e){return e?r:t})(e)}function n(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=o(t);if(r&&r.has(e))return r.get(e);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var u=a?Object.getOwnPropertyDescriptor(e,i):null;u&&(u.get||u.set)?Object.defineProperty(n,i,u):n[i]=e[i]}return n.default=e,r&&r.set(e,n),n}window.TourGenerator=t.View.extend({initialize:function(t){var o=this;o.toolId=t.toolId,o.toolVersion=t.toolVersion;var n=window.bundleEntries.getGalaxyInstance();$("#execute").attr("tour_id","execute"),e.info("Tour generation might take some time."),$.getJSON("".concat(n.root,"api/webhooks/tour_generator/data/"),{tool_id:o.toolId,tool_version:o.toolVersion},function(t){t.success?t.data.useDatasets?(n.currHistoryPanel.refreshContents(),setTimeout(function(){var a=[],i=0;r.each(t.data.hids,function(e){var t=n.currHistoryPanel.collection.where({hid:e})[0];t&&a.push(t)}),a.length===t.data.hids.length?r.each(a,function(e){"ok"===e.get("state")?i++:e.on("change:state",function(e){"ok"===e.get("state")&&i++,i===a.length&&o._generateTour(t.data.tour)})}):(e.warning("Cannot generate a tour."),console.error("Some of the test datasets cannot be found in the history."))},1500)):o._generateTour(t.data.tour):(e.warning("Cannot generate a tour."),console.error("Tour Generator: "+t.error))})},_generateTour:function(e){var t=window.bundleEntries.getGalaxyInstance().giveTourWithData(e);$("#execute").on("mousedown",function(){t&&t.end()})}}); +"use strict";var e=o(require("toastr")),t=o(require("backbone")),n=o(require("underscore"));function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(r=function(e){return e?n:t})(e)}function o(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=r(t);if(n&&n.has(e))return n.get(e);var o={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var u=a?Object.getOwnPropertyDescriptor(e,i):null;u&&(u.get||u.set)?Object.defineProperty(o,i,u):o[i]=e[i]}return o.default=e,n&&n.set(e,o),o}window.TourGenerator=t.View.extend({initialize:function(t){var n=this,r=window.bundleEntries.getGalaxyInstance(),o=t.toolId,a=t.toolVersion;$("#execute").attr("tour_id","execute"),e.info("Tour generation might take some time."),$.getJSON("".concat(r.root,"api/webhooks/tour_generator/data/"),{tool_id:o,tool_version:a},function(t){t.success?t.data.useDatasets?n._getData(t):n._generateTour(t.data.tour):(e.warning("Cannot generate a tour."),console.error("Tour Generator: "+t.error))})},_getData:function(t){var r=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,i=[];n.each(t.data.hids,function(e){Galaxy.currHistoryPanel.collection.each(function(e){i.push(e)},"hid=".concat(e," state=ok"))}),i.length===t.data.hids.length?this._generateTour(t.data.tour):o>0?setTimeout(function(){r._getData(t,o-1)},a):(e.warning("Cannot generate a tour."),console.error("Some of the test datasets cannot be found in the history."))},_generateTour:function(e){var t=window.bundleEntries.getGalaxyInstance().giveTourWithData(e);$("#execute").on("mousedown",function(){t&&t.end()})}}); },{"toastr":"cfPU","backbone":"kFNo","underscore":"XWoq"}]},{},["wXLC"], null) \ No newline at end of file diff --git a/config/plugins/webhooks/demo/tour_generator/tour_generator.js b/config/plugins/webhooks/demo/tour_generator/tour_generator.js index cdad7a54821..d2d0f811f32 100644 --- a/config/plugins/webhooks/demo/tour_generator/tour_generator.js +++ b/config/plugins/webhooks/demo/tour_generator/tour_generator.js @@ -6,59 +6,23 @@ import * as _ from "underscore"; window.TourGenerator = Backbone.View.extend({ initialize: function (options) { - var me = this; - me.toolId = options.toolId; - me.toolVersion = options.toolVersion; - const Galaxy = window.bundleEntries.getGalaxyInstance(); - + const toolId = options.toolId; + const toolVersion = options.toolVersion; // Add attribute 'tour_id' to the execution button $("#execute").attr("tour_id", "execute"); - Toastr.info("Tour generation might take some time."); $.getJSON( - `${Galaxy.root}api/webhooks/tour_generator/data/`, - { - tool_id: me.toolId, - tool_version: me.toolVersion, + `${Galaxy.root}api/webhooks/tour_generator/data/`, { + tool_id: toolId, + tool_version: toolVersion, }, - function (obj) { + (obj) => { if (obj.success) { if (obj.data.useDatasets) { - Galaxy.currHistoryPanel.refreshContents(); // Refresh history panel - - // Add a delay because of the history panel refreshing - setTimeout(function () { - var datasets = [], - numUploadedDatasets = 0; - - _.each(obj.data.hids, function (hid) { - var dataset = Galaxy.currHistoryPanel.collection.where({ - hid: hid, - })[0]; - if (dataset) datasets.push(dataset); - }); - - if (datasets.length === obj.data.hids.length) { - _.each(datasets, function (dataset) { - if (dataset.get("state") === "ok") { - numUploadedDatasets++; - } else { - dataset.on("change:state", function (model) { - if (model.get("state") === "ok") numUploadedDatasets++; - // Make sure that all test datasets have been successfully uploaded - if (numUploadedDatasets === datasets.length) - me._generateTour(obj.data.tour); - }); - } - }); - } else { - Toastr.warning("Cannot generate a tour."); - console.error("Some of the test datasets cannot be found in the history."); - } - }, 1500); + this._getData(obj); } else { - me._generateTour(obj.data.tour); + this._generateTour(obj.data.tour); } } else { Toastr.warning("Cannot generate a tour."); @@ -67,12 +31,29 @@ window.TourGenerator = Backbone.View.extend({ } ); }, - + _getData: function(obj, attempts = 20, delay = 1000) { + let datasets = []; + _.each(obj.data.hids, (hid) => { + Galaxy.currHistoryPanel.collection.each((dataset) => { + datasets.push(dataset); + }, `hid=${hid} state=ok`); + }); + if (datasets.length === obj.data.hids.length) { + this._generateTour(obj.data.tour); + } else if (attempts > 0) { + setTimeout(() => { + this._getData(obj, attempts - 1); + }, delay); + } else { + Toastr.warning("Cannot generate a tour."); + console.error("Some of the test datasets cannot be found in the history."); + } + }, _generateTour: function (data) { - var Galaxy = window.bundleEntries.getGalaxyInstance(); - var tour = Galaxy.giveTourWithData(data); + const Galaxy = window.bundleEntries.getGalaxyInstance(); + const tour = Galaxy.giveTourWithData(data); // Force ending the tour when pressing the Execute button - $("#execute").on("mousedown", function () { + $("#execute").on("mousedown", () => { if (tour) { tour.end(); } diff --git a/lib/galaxy_test/selenium/test_tool_describing_tours.py b/lib/galaxy_test/selenium/test_tool_describing_tours.py index b6e33bcd51b..7fdee274cdd 100644 --- a/lib/galaxy_test/selenium/test_tool_describing_tours.py +++ b/lib/galaxy_test/selenium/test_tool_describing_tours.py @@ -34,11 +34,8 @@ class ToolDescribingToursTestCase(SeleniumTestCase): def test_generate_tour_with_data(self): """Ensure a tour with data populates history.""" self._ensure_tdt_available() - self.use_legacy_history() self.tool_open("md5sum") - self.tool_form_generate_tour() - self.history_panel_wait_for_hid_ok(1) popover_component = self.components.tour.popover._ @@ -49,7 +46,6 @@ class ToolDescribingToursTestCase(SeleniumTestCase): self.screenshot("tool_describing_tour_0_start") popover_component.next.wait_for_and_click() - self.sleep_for(self.wait_types.UX_RENDER) text = popover_component.content.wait_for_visible().text @@ -57,7 +53,6 @@ class ToolDescribingToursTestCase(SeleniumTestCase): self.screenshot("tool_describing_tour_1_select") popover_component.next.wait_for_and_click() - self.sleep_for(self.wait_types.UX_RENDER) title = popover_component.title.wait_for_visible().text