mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 00:12:08 +08:00
Merge branch '7132_fix_cors_singleton_storage' into dev
This commit is contained in:
@@ -4,12 +4,12 @@
|
||||
|
||||
import addLogging from "utils/add-logging";
|
||||
import { GalaxyApp } from "./galaxy";
|
||||
// import { serverPath } from "utils/serverPath";
|
||||
import { serverPath } from "utils/serverPath";
|
||||
|
||||
export function setGalaxyInstance(factory, atTop = true) {
|
||||
// console.warn("setGalaxyInstance", serverPath());
|
||||
export function setGalaxyInstance(factory) {
|
||||
console.warn("setGalaxyInstance", serverPath());
|
||||
|
||||
let storage = getStorage(atTop);
|
||||
let storage = getStorage();
|
||||
let newInstance = factory(GalaxyApp);
|
||||
if (!(newInstance instanceof GalaxyApp)) {
|
||||
newInstance = new GalaxyApp(newInstance);
|
||||
@@ -19,7 +19,6 @@ export function setGalaxyInstance(factory, atTop = true) {
|
||||
}
|
||||
|
||||
// Debugging frame property
|
||||
|
||||
// storage._galaxyInstance = new Proxy(newInstance, {
|
||||
// get(galaxy, prop) {
|
||||
// if (prop == "frame") {
|
||||
@@ -46,17 +45,18 @@ export function setGalaxyInstance(factory, atTop = true) {
|
||||
return storage._galaxyInstance;
|
||||
}
|
||||
|
||||
export function getGalaxyInstance(atTop = true) {
|
||||
let storage = getStorage(atTop);
|
||||
export function getGalaxyInstance() {
|
||||
let storage = getStorage();
|
||||
return storage._galaxyInstance;
|
||||
}
|
||||
|
||||
export function galaxyIsInitialized(atTop = true) {
|
||||
let instance = getGalaxyInstance(atTop);
|
||||
export function galaxyIsInitialized() {
|
||||
let instance = getGalaxyInstance();
|
||||
return instance !== null;
|
||||
}
|
||||
|
||||
export function getStorage(atTop = true) {
|
||||
let storage = window !== window.top && atTop ? window.top : window;
|
||||
return storage;
|
||||
// Having a CORS issue in the toolshed iframe, store separate versions
|
||||
// of galaxy in each window for the short-term
|
||||
export function getStorage() {
|
||||
return window;
|
||||
}
|
||||
|
||||
@@ -203,23 +203,29 @@ var CenterPanel = Backbone.View.extend({
|
||||
this.setElement($(this.template()));
|
||||
this.$frame = this.$(".center-frame");
|
||||
this.$panel = this.$(".center-panel");
|
||||
this.$frame.on("load", _.bind(this._iframeChangeHandler, this));
|
||||
this.$frame.on("load", this._iframeChangeHandler.bind(this));
|
||||
},
|
||||
|
||||
/** Display iframe if its target url changes, hide center panel */
|
||||
_iframeChangeHandler: function(ev) {
|
||||
var iframe = ev.currentTarget;
|
||||
var location = iframe.contentWindow && iframe.contentWindow.location;
|
||||
if (location && location.host) {
|
||||
$(iframe).show();
|
||||
this.$panel.empty().hide();
|
||||
var Galaxy = getGalaxyInstance();
|
||||
Galaxy.trigger("center-frame:load", {
|
||||
fullpath: location.pathname + location.search + location.hash,
|
||||
pathname: location.pathname,
|
||||
search: location.search,
|
||||
hash: location.hash
|
||||
});
|
||||
var Galaxy = getGalaxyInstance();
|
||||
// Adding try/catch to manage a CORS error in toolshed. Accessing
|
||||
// location.host is a CORS no-no
|
||||
try {
|
||||
if (location && location.host) {
|
||||
$(iframe).show();
|
||||
this.$panel.empty().hide();
|
||||
Galaxy.trigger("center-frame:load", {
|
||||
fullpath: location.pathname + location.search + location.hash,
|
||||
pathname: location.pathname,
|
||||
search: location.search,
|
||||
hash: location.hash
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn("_iframeChangeHandler error", ev, location, Galaxy);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user