Skip to content

Commit

Permalink
refactor history view entrypoint out of extended bundle into history-…
Browse files Browse the repository at this point in the history
…view; swap HistoryView.vue to use new points. Minor import refactoring/cleanup, too.
  • Loading branch information
dannon committed Feb 19, 2018
1 parent 3c25883 commit 433472a
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 93 deletions.
87 changes: 1 addition & 86 deletions client/galaxy/scripts/apps/extended.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion client/galaxy/scripts/components/HistoryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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() {
Expand Down
100 changes: 95 additions & 5 deletions client/galaxy/scripts/mvc/history/history-view.js
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
};
1 change: 0 additions & 1 deletion client/galaxy/scripts/mvc/history/multi-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 $ */
Expand Down

0 comments on commit 433472a

Please sign in to comment.