From db4c67395ec802f26db95bc1e1dd63b15b3c12f0 Mon Sep 17 00:00:00 2001 From: Ivan Kuzmin Date: Fri, 6 Dec 2019 19:02:39 +0200 Subject: [PATCH 01/36] port masthead to vue --- client/galaxy/scripts/components/Masthead.vue | 91 +++++++++++++++++++ client/galaxy/scripts/layout/masthead.js | 50 +++++++--- 2 files changed, 129 insertions(+), 12 deletions(-) create mode 100644 client/galaxy/scripts/components/Masthead.vue diff --git a/client/galaxy/scripts/components/Masthead.vue b/client/galaxy/scripts/components/Masthead.vue new file mode 100644 index 000000000000..620347a9f521 --- /dev/null +++ b/client/galaxy/scripts/components/Masthead.vue @@ -0,0 +1,91 @@ + + + + + diff --git a/client/galaxy/scripts/layout/masthead.js b/client/galaxy/scripts/layout/masthead.js index 2265f30d01b0..cc3efab1391c 100644 --- a/client/galaxy/scripts/layout/masthead.js +++ b/client/galaxy/scripts/layout/masthead.js @@ -5,6 +5,10 @@ import Scratchbook from "layout/scratchbook"; import QuotaMeter from "mvc/user/user-quotameter"; import { getGalaxyInstance } from "app"; +import Masthead from "../components/Masthead.vue"; +import { mountVueComponent } from "../utils/mountVueComponent"; +import _ from "../libs/underscore"; + /** Masthead **/ const View = Backbone.View.extend({ initialize: function(options) { @@ -36,7 +40,8 @@ const View = Backbone.View.extend({ .fetch(this.options); // highlight initial active view - this.highlight(options.active_view); + this.activeView = options.active_view; + this.highlight(options.active_view); // covered // scratchbook Galaxy.frame = this.frame = new Scratchbook({ @@ -81,10 +86,29 @@ const View = Backbone.View.extend({ }, render: function() { - this.$navbarBrandTitle.html(`Galaxy ${(this.options.brand && `/ ${this.options.brand}`) || ""}`); - this.$navbarBrandLink.attr("href", this.options.logo_url); - this.$navbarBrandImage.attr("src", this.options.logo_src); + this.$navbarBrandTitle.html(`Galaxy ${(this.options.brand && `/ ${this.options.brand}`) || ""}`); // covered + this.$navbarBrandLink.attr("href", this.options.logo_url); // covered + this.$navbarBrandImage.attr("src", this.options.logo_src); // covered this.quotaMeter.render(); + + + const el = document.createElement('div'); + this.el.appendChild(el); // use this.el directly when feature parity is accomplished + + mountVueComponent(Masthead)( + { // params + brandTitle: `Galaxy ${(this.options.brand && `/ ${this.options.brand}`) || ""}`, + brandLink: this.options.logo_url, + brandImage: this.options.logo_src, + + quotaMeter: this.quotaMeter, + activeTab: this.activeView, + tabs: _.map(this.collection.models, el => { + return el.toJSON(); + }) + }, + el + ); return this; }, @@ -97,14 +121,16 @@ const View = Backbone.View.extend({ /** body template */ _template: function() { return ` - `; +
+ +
`; } }); From a61b3d211e5b5409168f34658de9f42a2bc4b47d Mon Sep 17 00:00:00 2001 From: Ivan Kuzmin Date: Fri, 6 Dec 2019 19:38:55 +0200 Subject: [PATCH 02/36] add tooltips --- client/galaxy/scripts/components/Masthead.vue | 13 ++++++++++--- client/galaxy/scripts/layout/menu.js | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/client/galaxy/scripts/components/Masthead.vue b/client/galaxy/scripts/components/Masthead.vue index 620347a9f521..935d713e896c 100644 --- a/client/galaxy/scripts/components/Masthead.vue +++ b/client/galaxy/scripts/components/Masthead.vue @@ -14,6 +14,8 @@ :class="{ active: tab.id === activeTab }" + v-b-tooltip.hover.bottom + :title="tab.tooltip" :style="{ visibility: tab.visible ? 'visible' : 'hidden', }" @@ -26,6 +28,8 @@ {{ item["title"] }} @@ -39,11 +43,14 @@ diff --git a/client/galaxy/scripts/layout/masthead.js b/client/galaxy/scripts/layout/masthead.js index cc3efab1391c..ba818fd874bd 100644 --- a/client/galaxy/scripts/layout/masthead.js +++ b/client/galaxy/scripts/layout/masthead.js @@ -8,6 +8,7 @@ import { getGalaxyInstance } from "app"; import Masthead from "../components/Masthead.vue"; import { mountVueComponent } from "../utils/mountVueComponent"; import _ from "../libs/underscore"; +import { getAppRoot } from "onload/loadConfig"; /** Masthead **/ const View = Backbone.View.extend({ @@ -105,7 +106,9 @@ const View = Backbone.View.extend({ activeTab: this.activeView, tabs: _.map(this.collection.models, el => { return el.toJSON(); - }) + }), + + appRoot: getAppRoot() }, el ); diff --git a/client/galaxy/scripts/layout/menu.js b/client/galaxy/scripts/layout/menu.js index d8777f9b1610..722e75b17405 100644 --- a/client/galaxy/scripts/layout/menu.js +++ b/client/galaxy/scripts/layout/menu.js @@ -477,7 +477,7 @@ const Tab = Backbone.View.extend({ } else { model.set("show_menu", true); } - } else { + } else { // covered if (this.$link.popover) { this.$link.popover("dispose"); } From 3bd05089035a0d1d1bcd458b266a73b5a0f73a58 Mon Sep 17 00:00:00 2001 From: Ivan Kuzmin Date: Fri, 6 Dec 2019 20:48:14 +0200 Subject: [PATCH 04/36] actions --- client/galaxy/scripts/components/Masthead.vue | 31 ++++++++++++++++--- client/galaxy/scripts/layout/masthead.js | 3 +- client/galaxy/scripts/layout/menu.js | 6 ++-- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/client/galaxy/scripts/components/Masthead.vue b/client/galaxy/scripts/components/Masthead.vue index c004cdd2caf7..3cee90511051 100644 --- a/client/galaxy/scripts/components/Masthead.vue +++ b/client/galaxy/scripts/components/Masthead.vue @@ -20,8 +20,9 @@ :style="{ visibility: tab.visible ? 'visible' : 'hidden', }" - :id="tab.id" href="#" - + :id="tab.id" + :href="tab.url" + :target="tab.target" :link-classes="[tab.icon && 'nav-icon', tab.icon && 'fa', tab.icon || '']" > @@ -35,7 +36,13 @@ v-b-popover.manual.bottom="{id: tab.id, content: popoverNote, html: true}" :style="{visibility: tab.visible ? 'visible' : 'hidden'}" :id="tab.id" href="#"> - {{ item["title"] }} + + {{ item["title"] }} + @@ -77,6 +84,9 @@ }, appRoot: { type: String, + }, + Galaxy: { + type: Object, } }, components: { @@ -104,12 +114,23 @@ setTimeout(() => { this.$root.$emit('bv::hide::popover', tab.id); }, 3000); - } else { - // TODO: action + } else if (!tab.menu) { + event.preventDefault(); + + if (tab.target === "__use_router__" && typeof this.Galaxy.page !== "undefined") { + this.Galaxy.page.router.executeUseRouter(tab.url); + } else { + try { + this.Galaxy.frame.add(tab); + } catch (err) { + console.warn("Missing frame element on galaxy instance", err); + } + } } }, }, mounted() { + console.log(this.tabs); this.quotaMeter.setElement(this.$refs['quota-meter-container']); this.quotaMeter.render(); } diff --git a/client/galaxy/scripts/layout/masthead.js b/client/galaxy/scripts/layout/masthead.js index ba818fd874bd..bd93a7a1bf25 100644 --- a/client/galaxy/scripts/layout/masthead.js +++ b/client/galaxy/scripts/layout/masthead.js @@ -108,7 +108,8 @@ const View = Backbone.View.extend({ return el.toJSON(); }), - appRoot: getAppRoot() + appRoot: getAppRoot(), + Galaxy: getGalaxyInstance(), }, el ); diff --git a/client/galaxy/scripts/layout/menu.js b/client/galaxy/scripts/layout/menu.js index 722e75b17405..61f403d97f68 100644 --- a/client/galaxy/scripts/layout/menu.js +++ b/client/galaxy/scripts/layout/menu.js @@ -442,7 +442,7 @@ const Tab = Backbone.View.extend({ }); }, - buildLink: function(label, url) { + buildLink: function(label, url) { // covered return $("
") .append( $("") @@ -453,7 +453,7 @@ const Tab = Backbone.View.extend({ }, /** Handle click event */ - _toggleClick: function(e) { + _toggleClick: function(e) { // covered const model = this.model; e.preventDefault(); $(".tooltip").hide(); @@ -477,7 +477,7 @@ const Tab = Backbone.View.extend({ } else { model.set("show_menu", true); } - } else { // covered + } else { if (this.$link.popover) { this.$link.popover("dispose"); } From 71459d6253606e5fcbc94d0ffc2f048d0ab3170c Mon Sep 17 00:00:00 2001 From: Ivan Kuzmin Date: Fri, 6 Dec 2019 20:59:04 +0200 Subject: [PATCH 05/36] port nav-note --- client/galaxy/scripts/components/Masthead.vue | 9 ++++++++- client/galaxy/scripts/layout/menu.js | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/client/galaxy/scripts/components/Masthead.vue b/client/galaxy/scripts/components/Masthead.vue index 3cee90511051..6d493b76157c 100644 --- a/client/galaxy/scripts/components/Masthead.vue +++ b/client/galaxy/scripts/components/Masthead.vue @@ -27,6 +27,7 @@ > {{ tab["title"] }} + {{ item["title"] }} + @@ -138,5 +140,10 @@ diff --git a/client/galaxy/scripts/layout/menu.js b/client/galaxy/scripts/layout/menu.js index 61f403d97f68..5d449f6516fe 100644 --- a/client/galaxy/scripts/layout/menu.js +++ b/client/galaxy/scripts/layout/menu.js @@ -60,7 +60,7 @@ const Collection = Backbone.Collection.extend({ tooltip: _l("Chain tools into workflows"), disabled: !Galaxy.user.id, url: "workflows/list", - target: "__use_router__" + target: "__use_router__", }); // @@ -353,7 +353,7 @@ const Tab = Backbone.View.extend({ visibility: (this.model.get("visible") && "visible") || "hidden" }); this.model.set("url", this._formatUrl(this.model.get("url"))); - this.$note // TODO: port note + this.$note .html(this.model.get("note") || "") .removeClass() .addClass("nav-note") From 38042daf239ee97b436df1513c00f4c850fe6b91 Mon Sep 17 00:00:00 2001 From: Ivan Kuzmin Date: Mon, 9 Dec 2019 21:06:30 +0200 Subject: [PATCH 06/36] add scratch book --- client/galaxy/scripts/components/Masthead.vue | 75 +++++++++++++++++-- client/galaxy/scripts/layout/masthead.js | 2 + client/galaxy/scripts/layout/menu.js | 2 +- client/galaxy/scripts/layout/scratchbook.js | 4 + 4 files changed, 75 insertions(+), 8 deletions(-) diff --git a/client/galaxy/scripts/components/Masthead.vue b/client/galaxy/scripts/components/Masthead.vue index 6d493b76157c..56f049d21b9c 100644 --- a/client/galaxy/scripts/components/Masthead.vue +++ b/client/galaxy/scripts/components/Masthead.vue @@ -23,13 +23,15 @@ :id="tab.id" :href="tab.url" :target="tab.target" - :link-classes="[tab.icon && 'nav-icon', tab.icon && 'fa', tab.icon || '']" - > + :link-classes="[ + tab.toggle && 'toggle', + tab.icon && 'nav-icon', + tab.icon && 'fa', + tab.icon || '' + ]"> {{ tab["title"] }} - - {{ item["title"] }} - + @@ -58,6 +60,7 @@ import { VBTooltip } from "bootstrap-vue"; import { VBPopover } from "bootstrap-vue"; import { BNavbar, BNavbarBrand, BNavbarNav } from "bootstrap-vue"; + import _ from "underscore"; export default { name: "Masthead", @@ -84,6 +87,9 @@ tabs: { type: Array }, + frames: { + type: Object, + }, appRoot: { type: String, }, @@ -107,6 +113,10 @@ }, methods: { open(tab, event) { + if (tab.onclick) { + return this.propogateClick(tab, event); + } + if (tab.disabled) { event.preventDefault(); @@ -121,29 +131,80 @@ if (tab.target === "__use_router__" && typeof this.Galaxy.page !== "undefined") { this.Galaxy.page.router.executeUseRouter(tab.url); + this.activeTab = tab.id; } else { try { this.Galaxy.frame.add(tab); + this.activeTab = tab.id; } catch (err) { console.warn("Missing frame element on galaxy instance", err); } } } }, + propogateClick(tab, event) { + event.preventDefault(); + tab.onclick(); + + if (tab.id === "enable-scratchbook") { + _.each(this.tabs, (tab, i) => { + if (tab.id === "enable-scratchbook") { + tab.active = !tab.active; + + this.$set(this.tabs, i, { + ...tab, + toggle: tab.active, + show_note: tab.active, + note_cls: tab.active && "fa fa-check" + }); + } + }); + } + }, + }, + created() { + _.each(this.tabs, tab => { + if (tab.onbeforeunload) { + console.log(tab); + document.addEventListener('beforeunload', () => { + tab.onbeforeunload(); + }); + } + }); }, mounted() { console.log(this.tabs); this.quotaMeter.setElement(this.$refs['quota-meter-container']); this.quotaMeter.render(); + + const idx = _.findIndex(this.tabs, { id: "show-scratchbook" }); + this.frames + .on("add remove", () => { + this.$set(this.tabs, idx, { + ...this.tabs[idx], + note: this.frames.length(), + visible: this.frames.length() > 0 + }); + }) + .on("show hide", () => { + this.$set(this.tabs, idx, { + ...this.tabs[idx], + toggle: this.frames.visible, + icon: (this.frames.visible && "fa-eye") || "fa-eye-slash" + }); + }); } } diff --git a/client/galaxy/scripts/layout/masthead.js b/client/galaxy/scripts/layout/masthead.js index bd93a7a1bf25..ed7accb6c0e1 100644 --- a/client/galaxy/scripts/layout/masthead.js +++ b/client/galaxy/scripts/layout/masthead.js @@ -108,6 +108,8 @@ const View = Backbone.View.extend({ return el.toJSON(); }), + frames: this.frame.getFrames(), + appRoot: getAppRoot(), Galaxy: getGalaxyInstance(), }, diff --git a/client/galaxy/scripts/layout/menu.js b/client/galaxy/scripts/layout/menu.js index 5d449f6516fe..b1f91448c76d 100644 --- a/client/galaxy/scripts/layout/menu.js +++ b/client/galaxy/scripts/layout/menu.js @@ -60,7 +60,7 @@ const Collection = Backbone.Collection.extend({ tooltip: _l("Chain tools into workflows"), disabled: !Galaxy.user.id, url: "workflows/list", - target: "__use_router__", + target: "__use_router__" }); // diff --git a/client/galaxy/scripts/layout/scratchbook.js b/client/galaxy/scripts/layout/scratchbook.js index eeb7953ef5d8..532fa391ca33 100644 --- a/client/galaxy/scripts/layout/scratchbook.js +++ b/client/galaxy/scripts/layout/scratchbook.js @@ -70,6 +70,10 @@ export default Backbone.View.extend({ this.history_cache = {}; }, + getFrames() { // needed for Vue.js integration + return this.frames; + }, + /** Add a dataset to the frames */ addDataset: function(dataset_id) { const self = this; From 3545c387c7bf9142d90e4d87e0f7f795e0f3e78b Mon Sep 17 00:00:00 2001 From: Ivan Kuzmin Date: Mon, 9 Dec 2019 21:54:15 +0200 Subject: [PATCH 07/36] active tab --- client/galaxy/scripts/components/Masthead.vue | 11 +++++------ client/galaxy/scripts/layout/masthead.js | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/galaxy/scripts/components/Masthead.vue b/client/galaxy/scripts/components/Masthead.vue index 56f049d21b9c..47ef75ef7078 100644 --- a/client/galaxy/scripts/components/Masthead.vue +++ b/client/galaxy/scripts/components/Masthead.vue @@ -11,7 +11,7 @@ From cd36bd20d1b81cad33732a16402dcaec5385312c Mon Sep 17 00:00:00 2001 From: Ivan Kuzmin Date: Thu, 2 Jan 2020 17:38:16 +0200 Subject: [PATCH 10/36] prepare nav item to be refactored into a separate component --- client/galaxy/scripts/components/Masthead.vue | 23 +++++++++++-------- .../scripts/components/MastheadItem.vue | 13 +++++++++++ 2 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 client/galaxy/scripts/components/MastheadItem.vue diff --git a/client/galaxy/scripts/components/Masthead.vue b/client/galaxy/scripts/components/Masthead.vue index a97aead090ba..c6520cfeb787 100644 --- a/client/galaxy/scripts/components/Masthead.vue +++ b/client/galaxy/scripts/components/Masthead.vue @@ -24,13 +24,16 @@ :href="tab.url" :target="tab.target" :link-classes="[ - tab.toggle && 'toggle', tab.icon && 'nav-icon', - tab.icon && 'fa', - tab.icon || '' ]"> - {{ tab.title }} + + {{ tab.note }} @@ -199,12 +201,15 @@ diff --git a/client/galaxy/scripts/components/MastheadItem.vue b/client/galaxy/scripts/components/MastheadItem.vue new file mode 100644 index 000000000000..058164e1174b --- /dev/null +++ b/client/galaxy/scripts/components/MastheadItem.vue @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file From c368f682abaf3838354fa43424c6c441535236bb Mon Sep 17 00:00:00 2001 From: Ivan Kuzmin Date: Thu, 2 Jan 2020 18:24:03 +0200 Subject: [PATCH 11/36] refactor nav item (wip) --- client/galaxy/scripts/components/Masthead.vue | 145 +++--------------- .../scripts/components/MastheadItem.vue | 139 ++++++++++++++++- client/galaxy/scripts/layout/masthead.js | 2 +- 3 files changed, 156 insertions(+), 130 deletions(-) diff --git a/client/galaxy/scripts/components/Masthead.vue b/client/galaxy/scripts/components/Masthead.vue index c6520cfeb787..20e1ac1ea716 100644 --- a/client/galaxy/scripts/components/Masthead.vue +++ b/client/galaxy/scripts/components/Masthead.vue @@ -8,52 +8,10 @@ - + +
@@ -62,17 +20,12 @@ diff --git a/client/galaxy/scripts/components/MastheadItem.vue b/client/galaxy/scripts/components/MastheadItem.vue index 058164e1174b..09c70da167da 100644 --- a/client/galaxy/scripts/components/MastheadItem.vue +++ b/client/galaxy/scripts/components/MastheadItem.vue @@ -1,13 +1,148 @@ \ No newline at end of file diff --git a/client/galaxy/scripts/layout/masthead.js b/client/galaxy/scripts/layout/masthead.js index 6bedbfbaaa46..dedc39be3c4e 100644 --- a/client/galaxy/scripts/layout/masthead.js +++ b/client/galaxy/scripts/layout/masthead.js @@ -103,7 +103,7 @@ const View = Backbone.View.extend({ brandImage: this.options.logo_src, quotaMeter: this.quotaMeter, - activeTab: () => {return this.activeView}, + activeTab: () => { return this.activeView }, tabs: _.map(this.collection.models, el => { return el.toJSON(); }), From 4e6417dcfabac843b7f589e1e0128d641ff402e5 Mon Sep 17 00:00:00 2001 From: Ivan Kuzmin Date: Wed, 8 Jan 2020 15:31:37 +0200 Subject: [PATCH 12/36] refactor some attributes as computed properties --- .../scripts/components/MastheadItem.vue | 66 +++++++++++-------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/client/galaxy/scripts/components/MastheadItem.vue b/client/galaxy/scripts/components/MastheadItem.vue index 09c70da167da..0f9d254d72a5 100644 --- a/client/galaxy/scripts/components/MastheadItem.vue +++ b/client/galaxy/scripts/components/MastheadItem.vue @@ -1,40 +1,41 @@