Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix masthead functionality for webhooks. #9810

Merged
merged 3 commits into from
May 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions client/galaxy/scripts/components/Masthead/Masthead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ export default {
}
});
},
addItem(item) {
this.tabs.push(item);
},
},
mounted() {
this.quotaMeter.setElement(this.$refs["quota-meter-container"]);
Expand Down
8 changes: 6 additions & 2 deletions client/galaxy/scripts/layout/masthead.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const View = Backbone.View.extend({
const Galaxy = getGalaxyInstance();
const self = this;
this.options = options;

this._component = null;
// build tabs
this.collection = new Menu.Collection();
this.collection
Expand Down Expand Up @@ -75,7 +75,7 @@ const View = Backbone.View.extend({
const tabs = this.collection.models.map((el) => {
return el.toJSON();
});
mountVueComponent(Masthead)(
this._component = mountVueComponent(Masthead)(
{
brandTitle: brandTitle,
brandLink: this.options.logo_url,
Expand All @@ -92,6 +92,10 @@ const View = Backbone.View.extend({
return this;
},

addItem(item) {
this._component.addItem(item);
},

highlight: function (id) {
this.activeView = id;
this.collection.forEach(function (model) {
Expand Down
25 changes: 16 additions & 9 deletions client/galaxy/scripts/layout/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ import { CommunicationServerView } from "layout/communication-server-view";
import Webhooks from "mvc/webhooks";
import Utils from "utils/utils";

function appendToPageMenu(item) {
const Galaxy = getGalaxyInstance();
// Galaxy.page is undefined for data libraries, workflows pages
if (Galaxy.page) {
Galaxy.page.masthead.addItem(item);
} else if (Galaxy.masthead) {
Galaxy.masthead.addItem(item);
}
}

export function logoutClick() {
const galaxy = getGalaxyInstance();
const session_csrf_token = galaxy.session_csrf_token;
Expand Down Expand Up @@ -153,16 +163,13 @@ const Collection = Backbone.Collection.extend({
tooltip: webhook.config.tooltip,
/*jslint evil: true */
onclick: webhook.config.function && new Function(webhook.config.function),
// fill in model defaults because this isn't added to
// collection first, will make more sense when other
// items aren't defined using backbone
visible: true,
target: "_parent",
};

// Galaxy.page is undefined for data libraries, workflows pages
const Galaxy = getGalaxyInstance();
if (Galaxy.page) {
Galaxy.page.masthead.collection.add(obj);
} else if (Galaxy.masthead) {
Galaxy.masthead.collection.add(obj);
}

appendToPageMenu(obj);
// Append masthead script and styles to Galaxy main
Utils.appendScriptStyle(webhook);
}
Expand Down
22 changes: 10 additions & 12 deletions client/galaxy/scripts/layout/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const View = Backbone.View.extend({
_panelids: ["left", "right"],

initialize: function (options) {
const self = this;
this.config = _.defaults(options.config || {}, {
message_box_visible: false,
message_box_content: "",
Expand All @@ -28,7 +27,7 @@ const View = Backbone.View.extend({
// attach global objects, build mastheads
const Galaxy = getGalaxyInstance();
Galaxy.modal = this.modal = new Modal.View();
Galaxy.router = this.router = options.Router && new options.Router(self, options);
Galaxy.router = this.router = options.Router && new options.Router(this, options);
this.masthead = new Masthead.View(this.config);
this.center = new Panel.CenterPanel();

Expand All @@ -42,9 +41,9 @@ const View = Backbone.View.extend({
view.allow_title_display = true;
}
if (view.active_tab) {
self.masthead.highlight(view.active_tab);
this.masthead.highlight(view.active_tab);
}
self.center.display(view);
this.center.display(view);
};

// build page template
Expand Down Expand Up @@ -73,10 +72,10 @@ const View = Backbone.View.extend({
const panel_class_name = panel_id.charAt(0).toUpperCase() + panel_id.slice(1);
const panel_class = options[panel_class_name];
if (panel_class) {
const panel_instance = new panel_class(self, options);
const panel_el = self.$(`#${panel_id}`);
self[panel_instance.toString()] = panel_instance;
self.panels[panel_id] = new Panel.SidePanel({
const panel_instance = new panel_class(this, options);
const panel_el = this.$(`#${panel_id}`);
this[panel_instance.toString()] = panel_instance;
this.panels[panel_id] = new Panel.SidePanel({
id: panel_id,
el: panel_el,
view: panel_instance,
Expand Down Expand Up @@ -143,14 +142,13 @@ const View = Backbone.View.extend({

/** Render panels */
renderPanels: function () {
const self = this;
_.each(this._panelids, (panel_id) => {
const panel = self.panels[panel_id];
const panel = this.panels[panel_id];
if (panel) {
panel.render();
} else {
self.$center.css(panel_id, 0);
self.$(`#${panel_id}`).hide();
this.$center.css(panel_id, 0);
this.$(`#${panel_id}`).hide();
}
});
return this;
Expand Down
16 changes: 0 additions & 16 deletions client/galaxy/scripts/layout/scratchbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,6 @@ export default Backbone.View.extend({
}
},
});
this.frames
.on("add remove", () => {
if (this.frames.visible && this.frames.length() === 0) {
this.frames.hide();
}
this.buttonLoad.set({
note: this.frames.length(),
visible: this.frames.length() > 0,
});
})
.on("show hide ", () => {
this.buttonLoad.set({
toggle: this.frames.visible,
icon: (this.frames.visible && "fa-eye") || "fa-eye-slash",
});
});
this.history_cache = {};
},

Expand Down