mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Fix webhook filtering, make it a bit more defensive. Minor other tweaks.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import Utils from "utils/utils";
|
||||
import Menu from "layout/menu";
|
||||
import Scratchbook from "layout/scratchbook";
|
||||
import QuotaMeter from "mvc/user/user-quotameter";
|
||||
|
||||
/** Masthead **/
|
||||
var View = Backbone.View.extend({
|
||||
initialize: function(options) {
|
||||
@@ -62,7 +62,9 @@ var View = Backbone.View.extend({
|
||||
var text = "";
|
||||
self.collection.each(model => {
|
||||
var q = model.get("onbeforeunload") && model.get("onbeforeunload")();
|
||||
q && (text += `${q} `);
|
||||
if (q) {
|
||||
text += `${q} `;
|
||||
}
|
||||
});
|
||||
if (text !== "") {
|
||||
return text;
|
||||
|
||||
@@ -2,6 +2,7 @@ import Masthead from "layout/masthead";
|
||||
import Panel from "layout/panel";
|
||||
import Modal from "mvc/ui/ui-modal";
|
||||
import Utils from "utils/utils";
|
||||
|
||||
var View = Backbone.View.extend({
|
||||
el: "body",
|
||||
className: "full-content",
|
||||
|
||||
@@ -19,8 +19,9 @@ const WebhookView = Backbone.View.extend({
|
||||
const webhooks = new Webhooks();
|
||||
webhooks.fetch({
|
||||
success: data => {
|
||||
data.reset(filterType(data, options.type));
|
||||
|
||||
if (options.type) {
|
||||
data.reset(filterType(data, options.type));
|
||||
}
|
||||
if (data.length > 0) {
|
||||
this.render(weightedRandomPick(data));
|
||||
}
|
||||
@@ -50,7 +51,14 @@ const load = options => {
|
||||
};
|
||||
|
||||
function filterType(data, type) {
|
||||
return data.models.filter(item => item.get("type").indexOf(type) !== -1);
|
||||
return data.models.filter(item => {
|
||||
let itype = item.get("type");
|
||||
if (itype) {
|
||||
return itype.indexOf(type) !== -1;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function weightedRandomPick(data) {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
/** Creates a generic/global Galaxy environment, loads shared libraries and a fake server */
|
||||
/* global define */
|
||||
|
||||
define(
|
||||
[
|
||||
"jquery",
|
||||
|
||||
Reference in New Issue
Block a user