mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add reusable path helper, consolidate use
Only allow window manager in analysis app Restore original window manager
This commit is contained in:
@@ -2,20 +2,17 @@
|
||||
* Temporary function used to mount the masthead inside the current application.
|
||||
* This function is exposed with the rest of the page-globals in bundledEntries.
|
||||
*/
|
||||
import { MastheadState, mountMasthead } from "../../layout/masthead";
|
||||
import { mountMasthead } from "../../layout/masthead";
|
||||
import $ from "jquery";
|
||||
|
||||
export function initMasthead(config, container) {
|
||||
console.log("initMasthead");
|
||||
|
||||
const $masthead = $("#masthead");
|
||||
|
||||
if (config.hide_masthead) {
|
||||
$masthead.remove();
|
||||
} else {
|
||||
if (container) {
|
||||
const mastheadState = new MastheadState();
|
||||
mountMasthead(container, config, mastheadState);
|
||||
mountMasthead(container, config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
id="masthead"
|
||||
:display-galaxy-brand="config.display_galaxy_brand"
|
||||
:brand="config.brand"
|
||||
:brand-link="staticUrlToPrefixed(config.logo_url)"
|
||||
:brand-image="staticUrlToPrefixed(config.logo_src)"
|
||||
:brand-image-secondary="staticUrlToPrefixed(config.logo_src_secondary)"
|
||||
:brand-link="getPath(config.logo_url)"
|
||||
:brand-image="getPath(config.logo_src)"
|
||||
:brand-image-secondary="getPath(config.logo_src_secondary)"
|
||||
:base-tabs="baseTabs"
|
||||
:window-tab="windowTab" />
|
||||
<alert
|
||||
@@ -37,13 +37,14 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { MastheadState } from "layout/masthead";
|
||||
import Modal from "mvc/ui/ui-modal";
|
||||
import Masthead from "components/Masthead/Masthead.vue";
|
||||
import { getGalaxyInstance } from "app";
|
||||
import { getAppRoot } from "onload";
|
||||
import { HistoryPanelProxy } from "components/History/adapters/HistoryPanelProxy";
|
||||
import { fetchMenu } from "entry/analysis/menu";
|
||||
import { safePath } from "utils/redirect";
|
||||
import { WindowManager } from "layout/window-manager";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -53,8 +54,8 @@ export default {
|
||||
return {
|
||||
config: getGalaxyInstance().config,
|
||||
confirmation: null,
|
||||
mastheadState: new MastheadState(),
|
||||
resendUrl: `${getAppRoot()}user/resend_verification`,
|
||||
windowManager: new WindowManager(),
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -69,7 +70,7 @@ export default {
|
||||
return true;
|
||||
},
|
||||
windowTab() {
|
||||
return this.mastheadState.windowManager.getTab();
|
||||
return this.windowManager.getTab();
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
@@ -82,17 +83,18 @@ export default {
|
||||
const Galaxy = getGalaxyInstance();
|
||||
Galaxy.currHistoryPanel = new HistoryPanelProxy();
|
||||
Galaxy.modal = new Modal.View();
|
||||
Galaxy.frame = this.windowManager;
|
||||
},
|
||||
created() {
|
||||
window.onbeforeunload = () => {
|
||||
if (this.confirmation || this.mastheadState.windowManager.beforeUnload()) {
|
||||
if (this.confirmation || this.windowManager.beforeUnload()) {
|
||||
return "Are you sure you want to leave the page?";
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
staticUrlToPrefixed(url) {
|
||||
return url?.startsWith("/") ? `${getAppRoot()}${url.substring(1)}` : url;
|
||||
getPath(url) {
|
||||
return safePath(url);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { getGalaxyInstance } from "app";
|
||||
import { prependPath } from "utils/redirect";
|
||||
import _l from "utils/localization";
|
||||
import { userLogout } from "utils/logout";
|
||||
|
||||
@@ -11,7 +10,7 @@ export function fetchMenu(options = {}) {
|
||||
//
|
||||
menu.push({
|
||||
id: "analysis",
|
||||
url: prependPath("/"),
|
||||
url: "/",
|
||||
tooltip: _l("Tools and Current History"),
|
||||
icon: "fa-home",
|
||||
target: "_top",
|
||||
@@ -62,7 +61,7 @@ export function fetchMenu(options = {}) {
|
||||
menu: [
|
||||
{
|
||||
title: _l("Data Libraries"),
|
||||
url: prependPath("/libraries"),
|
||||
url: "/libraries",
|
||||
target: "_top",
|
||||
},
|
||||
{
|
||||
@@ -92,7 +91,7 @@ export function fetchMenu(options = {}) {
|
||||
menu.push({
|
||||
id: "admin",
|
||||
title: _l("Admin"),
|
||||
url: prependPath("/admin"),
|
||||
url: "/admin",
|
||||
tooltip: _l("Administer this Galaxy"),
|
||||
cls: "admin-only",
|
||||
target: "_top",
|
||||
@@ -169,7 +168,7 @@ export function fetchMenu(options = {}) {
|
||||
id: "user",
|
||||
title: _l("Login or Register"),
|
||||
cls: "loggedout-only",
|
||||
url: prependPath("/login"),
|
||||
url: "/login",
|
||||
tooltip: _l("Log in or register a new account"),
|
||||
target: "_top",
|
||||
};
|
||||
@@ -179,7 +178,7 @@ export function fetchMenu(options = {}) {
|
||||
title: _l("Login"),
|
||||
cls: "loggedout-only",
|
||||
tooltip: _l("Login"),
|
||||
url: prependPath("/login"),
|
||||
url: "/login",
|
||||
target: "_top",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,40 +1,18 @@
|
||||
import { WindowManager } from "layout/window-manager";
|
||||
import { getGalaxyInstance } from "app";
|
||||
import { getAppRoot } from "onload/loadConfig";
|
||||
import Masthead from "../components/Masthead/Masthead";
|
||||
import { mountVueComponent } from "../utils/mountVueComponent";
|
||||
import { fetchMenu } from "entry/analysis/menu";
|
||||
import { safePath } from "utils/redirect";
|
||||
|
||||
export class MastheadState {
|
||||
// Used to be a Backbone View - not pretty but keep all window wide listeners,
|
||||
// global state, etc... related to the Masthead here to keep the VueJS component
|
||||
// more isolated, testable, etc.. (clean)
|
||||
|
||||
constructor(Galaxy = null) {
|
||||
Galaxy = Galaxy || getGalaxyInstance();
|
||||
if (!Galaxy.frame) {
|
||||
Galaxy.frame = new WindowManager();
|
||||
}
|
||||
this.windowManager = Galaxy.frame;
|
||||
}
|
||||
}
|
||||
|
||||
function staticUrlToPrefixed(appRoot, url) {
|
||||
return url?.startsWith("/") ? `${appRoot}${url.substring(1)}` : url;
|
||||
}
|
||||
|
||||
export function mountMasthead(el, options, mastheadState) {
|
||||
const appRoot = getAppRoot();
|
||||
export function mountMasthead(el, options) {
|
||||
return mountVueComponent(Masthead)(
|
||||
{
|
||||
el: el,
|
||||
displayGalaxyBrand: options.display_galaxy_brand,
|
||||
baseTabs: fetchMenu(options),
|
||||
brand: options.brand,
|
||||
brandLink: staticUrlToPrefixed(appRoot, options.logo_url),
|
||||
brandImage: staticUrlToPrefixed(appRoot, options.logo_src),
|
||||
brandImageSecondary: staticUrlToPrefixed(appRoot, options.logo_src_secondary),
|
||||
windowTab: mastheadState.windowManager.getTab(),
|
||||
brandLink: safePath(options.logo_url),
|
||||
brandImage: safePath(options.logo_src),
|
||||
brandImageSecondary: safePath(options.logo_src_secondary),
|
||||
},
|
||||
el
|
||||
);
|
||||
|
||||
@@ -34,6 +34,18 @@ export function absPath(path) {
|
||||
return `${server}${relativePath}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* (Safely) Prepends the configured app root to given url
|
||||
* @param {String} path
|
||||
* @returns The relative URL or original path.
|
||||
*/
|
||||
export function safePath(path) {
|
||||
if (path && path.startsWith("/")) {
|
||||
return prependPath(path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the path already has the app root.
|
||||
* @param {String} path
|
||||
|
||||
Reference in New Issue
Block a user