From 433472a315ced57e033583ef0569d95e36d13bc3 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Mon, 19 Feb 2018 11:02:31 -0500 Subject: [PATCH] refactor history view entrypoint out of extended bundle into history-view; swap HistoryView.vue to use new points. Minor import refactoring/cleanup, too. --- client/galaxy/scripts/apps/extended.js | 87 +-------------- .../galaxy/scripts/components/HistoryView.vue | 3 +- .../scripts/mvc/history/history-view.js | 100 +++++++++++++++++- .../galaxy/scripts/mvc/history/multi-panel.js | 1 - 4 files changed, 98 insertions(+), 93 deletions(-) diff --git a/client/galaxy/scripts/apps/extended.js b/client/galaxy/scripts/apps/extended.js index dffaa6605f0d..125a453e9c20 100644 --- a/client/galaxy/scripts/apps/extended.js +++ b/client/galaxy/scripts/apps/extended.js @@ -1,4 +1,3 @@ -import _l from "utils/localization"; import GalaxyApp from "galaxy"; import WorkflowView from "mvc/workflow/workflow-view"; import Trackster from "viz/trackster"; @@ -17,7 +16,6 @@ import StructureView from "mvc/history/history-structure-view"; import HistoryContents from "mvc/history/history-contents"; import MultiPanel from "mvc/history/multi-panel"; import HistoryView from "mvc/history/history-view"; -import HistoryViewEdit from "mvc/history/history-view-edit"; import HistoryViewAnnotated from "mvc/history/history-view-annotated"; import HistoryCopyDialog from "mvc/history/copy-dialog"; import HDAListItemEdit from "mvc/history/hda-li-edit"; @@ -67,89 +65,6 @@ export function libraryEntry(options) { new GalaxyLibrary.GalaxyApp(options); } -export function historyEntry(options) { - $("#toggle-deleted").modeButton({ - initialMode: options.initialModeDeleted, - modes: [ - { mode: "showing_deleted", html: _l("Exclude deleted") }, - { mode: "not_showing_deleted", html: _l("Include deleted") } - ] - }); - $("#toggle-hidden").modeButton({ - initialMode: options.initialModeHidden, - modes: [ - { mode: "showing_hidden", html: _l("Exclude hidden") }, - { mode: "not_showing_hidden", html: _l("Include hidden") } - ] - }); - $("#switch").click(function() { - //##HACK:ity hack hack - //##TODO: remove when out of iframe - var hview = - Galaxy.currHistoryPanel || (window.top.Galaxy && window.top.Galaxy.currHistoryPanel) - ? window.top.Galaxy.currHistoryPanel - : null; - if (hview) { - hview.switchToHistory("${ history[ 'id' ] }"); - } else { - window.location = "${ switch_to_url }"; - } - }); - // use_panels effects where the the center_panel() is rendered: - // w/o it renders to the body, w/ it renders to #center - we need to adjust a few things for scrolling to work - if (options.hasMasthead) { - $("#center").addClass("flex-vertical-container"); - } - - let viewClass = options.userIsOwner ? HistoryViewEdit.HistoryViewEdit : HistoryView.HistoryView; - let historyModel = new History.History(options.historyJSON); - - // attach the copy dialog to the import button now that we have a history - $("#import").click(function() { - HistoryCopyDialog(historyModel, { - useImport: true, - // use default datasets option to match the toggle-deleted button - allDatasets: $("#toggle-deleted").modeButton("getMode").mode === "showing_deleted" - }).done(function() { - if (window === window.parent) { - window.location = Galaxy.root; - } else if (Galaxy.currHistoryPanel) { - Galaxy.currHistoryPanel.loadCurrentHistory(); - } - }); - }); - - let historyView = new viewClass({ - el: $("#history-" + options.historyJSON.id), - className: viewClass.prototype.className + " wide", - $scrollContainer: options.hasMasthead - ? function() { - return this.$el.parent(); - } - : undefined, - model: historyModel, - show_deleted: options.showDeletedJson, - show_hidden: options.showHiddenJson, - purgeAllowed: options.allow_user_dataset_purge - }); - historyView.trigger("loading"); - historyModel - .fetchContents({ silent: true }) - .fail(function() { - alert("Galaxy history failed to load"); - }) - .done(function() { - historyView.trigger("loading-done"); - historyView.render(); - }); - $("#toggle-deleted").on("click", function() { - historyView.toggleShowDeleted(); - }); - $("#toggle-hidden").on("click", function() { - historyView.toggleShowHidden(); - }); -} - export function multiHistoryEntry(options) { let histories = new History.HistoryCollection([], { includeDeleted: options.includingDeleted, @@ -180,7 +95,7 @@ export const bundleEntries = { phyloviz: Phyloviz.PhylovizView, createTabularDatasetChunkedView: Data.createTabularDatasetChunkedView, multiHistory: multiHistoryEntry, - history: historyEntry, + history: HistoryView.historyEntry, History: History.History, HistoryContents: HistoryContents.HistoryContents, SweepsterVisualization: Sweepster.SweepsterVisualization, diff --git a/client/galaxy/scripts/components/HistoryView.vue b/client/galaxy/scripts/components/HistoryView.vue index 16599c7bcf8c..8e39c08c8c8c 100644 --- a/client/galaxy/scripts/components/HistoryView.vue +++ b/client/galaxy/scripts/components/HistoryView.vue @@ -26,6 +26,7 @@ import axios from "axios"; import Vue from "vue"; import DisplayStructure from "components/DisplayStructured.vue"; import QueryStringParsing from "utils/query-string-parsing"; +import HistoryView from "mvc/history/history-view"; export default { props: { @@ -78,7 +79,7 @@ export default { options.viewToUse = options.userIsOwner ? { location: "mvc/history/history-view-edit", className: "HistoryViewEdit" } : { location: "mvc/history/history-view", className: "HistoryView" }; - window.bundleEntries.history(options); + HistoryView.historyEntry(options); }); }, showStructure: function() { diff --git a/client/galaxy/scripts/mvc/history/history-view.js b/client/galaxy/scripts/mvc/history/history-view.js index 2cfa71fb99ab..ff06c5d29625 100644 --- a/client/galaxy/scripts/mvc/history/history-view.js +++ b/client/galaxy/scripts/mvc/history/history-view.js @@ -1,15 +1,21 @@ +import * as _ from "underscore"; +import _l from "utils/localization"; import LIST_VIEW from "mvc/list/list-view"; import HISTORY_MODEL from "mvc/history/history-model"; import HISTORY_CONTENTS from "mvc/history/history-contents"; -import HISTORY_PREFS from "mvc/history/history-preferences"; +import History from "mvc/history/history-model"; import HDA_LI from "mvc/history/hda-li"; import HDCA_LI from "mvc/history/hdca-li"; -import USER from "mvc/user/user-model"; import ERROR_MODAL from "mvc/ui/error-modal"; import faIconButton from "ui/fa-icon-button"; import BASE_MVC from "mvc/base-mvc"; -import _l from "utils/localization"; +import HistoryViewEdit from "mvc/history/history-view-edit"; +import HistoryCopyDialog from "mvc/history/copy-dialog"; import "ui/search-input"; +import "ui/mode-button"; + +/* global $ */ +/* global Galaxy */ /* ============================================================================= TODO: @@ -413,7 +419,7 @@ var HistoryView = _super.extend( this.$(inputSelector).searchInput("toggle-loading"); // set this now so that only results will show during progress this.searchFor = searchFor; - var xhr = this.model.contents + this.model.contents .progressivelyFetchDetails({ silent: true }) .progress((response, limit, offset) => { this.renderItems(); @@ -611,7 +617,91 @@ HistoryView.prototype.templates = (() => { }); })(); +export function historyEntry(options) { + $("#toggle-deleted").modeButton({ + initialMode: options.initialModeDeleted, + modes: [ + { mode: "showing_deleted", html: _l("Exclude deleted") }, + { mode: "not_showing_deleted", html: _l("Include deleted") } + ] + }); + $("#toggle-hidden").modeButton({ + initialMode: options.initialModeHidden, + modes: [ + { mode: "showing_hidden", html: _l("Exclude hidden") }, + { mode: "not_showing_hidden", html: _l("Include hidden") } + ] + }); + $("#switch").click(function() { + //##HACK:ity hack hack + //##TODO: remove when out of iframe + var hview = + Galaxy.currHistoryPanel || (window.top.Galaxy && window.top.Galaxy.currHistoryPanel) + ? window.top.Galaxy.currHistoryPanel + : null; + if (hview) { + hview.switchToHistory("${ history[ 'id' ] }"); + } else { + window.location = "${ switch_to_url }"; + } + }); + // use_panels effects where the the center_panel() is rendered: + // w/o it renders to the body, w/ it renders to #center - we need to adjust a few things for scrolling to work + if (options.hasMasthead) { + $("#center").addClass("flex-vertical-container"); + } + + let viewClass = options.userIsOwner ? HistoryViewEdit.HistoryViewEdit : HistoryView.HistoryView; + let historyModel = new History.History(options.historyJSON); + + // attach the copy dialog to the import button now that we have a history + $("#import").click(function() { + HistoryCopyDialog(historyModel, { + useImport: true, + // use default datasets option to match the toggle-deleted button + allDatasets: $("#toggle-deleted").modeButton("getMode").mode === "showing_deleted" + }).done(function() { + if (window === window.parent) { + window.location = Galaxy.root; + } else if (Galaxy.currHistoryPanel) { + Galaxy.currHistoryPanel.loadCurrentHistory(); + } + }); + }); + + let historyView = new viewClass({ + el: $("#history-" + options.historyJSON.id), + className: viewClass.prototype.className + " wide", + $scrollContainer: options.hasMasthead + ? function() { + return this.$el.parent(); + } + : undefined, + model: historyModel, + show_deleted: options.showDeletedJson, + show_hidden: options.showHiddenJson, + purgeAllowed: options.allow_user_dataset_purge + }); + historyView.trigger("loading"); + historyModel + .fetchContents({ silent: true }) + .fail(function() { + alert("Galaxy history failed to load"); + }) + .done(function() { + historyView.trigger("loading-done"); + historyView.render(); + }); + $("#toggle-deleted").on("click", function() { + historyView.toggleShowDeleted(); + }); + $("#toggle-hidden").on("click", function() { + historyView.toggleShowHidden(); + }); +} + //============================================================================== export default { - HistoryView: HistoryView + HistoryView: HistoryView, + historyEntry: historyEntry }; diff --git a/client/galaxy/scripts/mvc/history/multi-panel.js b/client/galaxy/scripts/mvc/history/multi-panel.js index 5b7e395d6a75..545926ddf7e3 100644 --- a/client/galaxy/scripts/mvc/history/multi-panel.js +++ b/client/galaxy/scripts/mvc/history/multi-panel.js @@ -8,7 +8,6 @@ import historyCopyDialog from "mvc/history/copy-dialog"; import ERROR_MODAL from "mvc/ui/error-modal"; import baseMVC from "mvc/base-mvc"; import ajaxQueue from "utils/ajax-queue"; -import "ui/mode-button"; import "ui/search-input"; /* global $ */