From cd5058da7d9405ea78b1060260f35a865ad8b1bc Mon Sep 17 00:00:00 2001 From: guerler Date: Sun, 18 Sep 2022 16:54:37 -0400 Subject: [PATCH 01/29] Prep mounting of history view in makos --- client/src/bundleEntries.js | 1 + client/src/components/History/mount.js | 15 +++++++++++++++ templates/webapps/galaxy/history/display.mako | 6 ++++-- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 client/src/components/History/mount.js diff --git a/client/src/bundleEntries.js b/client/src/bundleEntries.js index 8c23d9f8b21..f92233589f0 100644 --- a/client/src/bundleEntries.js +++ b/client/src/bundleEntries.js @@ -55,6 +55,7 @@ export function chart(options) { } export { initMasthead } from "components/Masthead/initMasthead"; +export { mountHistory } from "components/History/mount"; export { mountMakoTags } from "components/Tags"; export { mountWorkflowEditor } from "components/Workflow/Editor/mount"; export { mountPageEditor } from "components/PageEditor/mount"; diff --git a/client/src/components/History/mount.js b/client/src/components/History/mount.js new file mode 100644 index 00000000000..145cd44c649 --- /dev/null +++ b/client/src/components/History/mount.js @@ -0,0 +1,15 @@ +/** + * Endpoint for mounting History in non-Vue environment. + */ +import Vue from "vue"; +import HistoryView from "./HistoryView"; +import store from "store"; + +export const mountHistory = (el, propsData) => { + const component = Vue.extend(HistoryView); + return new component({ + store: store, + propsData: propsData, + el: el, + }); +}; diff --git a/templates/webapps/galaxy/history/display.mako b/templates/webapps/galaxy/history/display.mako index 31acc072cb5..b657a4d1715 100644 --- a/templates/webapps/galaxy/history/display.mako +++ b/templates/webapps/galaxy/history/display.mako @@ -77,7 +77,9 @@ }); }); - window.historyView = new window.bundleEntries.HistoryViewAnnotated.AnnotatedHistoryView({ + window.bundleEntries.mountHistory("#history-" + historyJSON.id, { id: historyJSON.id }); + + /*window.historyView = new window.bundleEntries.HistoryViewAnnotated.AnnotatedHistoryView({ el : $( "#history-" + historyJSON.id ), className : window.bundleEntries.HistoryViewAnnotated.AnnotatedHistoryView.prototype.className + ' wide', model : historyModel, @@ -90,7 +92,7 @@ .done( function(){ historyView.trigger( 'loading-done' ); historyView.render(); - }); + });*/ }); From 461cd6d0b00b8c657430dc3769e10377f98901df Mon Sep 17 00:00:00 2001 From: guerler Date: Sun, 18 Sep 2022 17:19:38 -0400 Subject: [PATCH 02/29] Remove legacy bundle helpers from display mako --- client/src/store/historyStore/historyStore.js | 2 +- templates/webapps/galaxy/history/display.mako | 81 +------------------ 2 files changed, 5 insertions(+), 78 deletions(-) diff --git a/client/src/store/historyStore/historyStore.js b/client/src/store/historyStore/historyStore.js index d81b1bddb74..0c6a3814b65 100644 --- a/client/src/store/historyStore/historyStore.js +++ b/client/src/store/historyStore/historyStore.js @@ -135,7 +135,7 @@ const actions = { .finally(() => { isLoadingHistory.delete(id); }); - isLoadingHistory.set(id, p); + //isLoadingHistory.set(id, p); } }, resetHistory({ commit }) { diff --git a/templates/webapps/galaxy/history/display.mako b/templates/webapps/galaxy/history/display.mako index b657a4d1715..514eb641f0a 100644 --- a/templates/webapps/galaxy/history/display.mako +++ b/templates/webapps/galaxy/history/display.mako @@ -1,11 +1,5 @@ <%inherit file="/display_base.mako"/> -## Set vars so that there's no need to change the code below. -<% - history = published_item - datasets = published_item_data -%> - <%def name="javascripts()"> ${parent.javascripts()} @@ -15,85 +9,18 @@ <%def name="render_item_links( history )"> -<% - encoded_history_id = history_dict[ 'id' ] - switch_url = h.url_for( controller='history', action='switch_to_history', hist_id=encoded_history_id ) -%> - %if not user_is_owner: - - - Import - - %else: - - - Switch - - %endif <%def name="render_item_header( item )"> -<%def name="render_item( history, datasets )"> -
+<%def name="render_item( item, item_data )"> +
From 6c4d248d82d2de3db82f2859ae3d197a6d6e9aad Mon Sep 17 00:00:00 2001 From: guerler Date: Sun, 18 Sep 2022 21:07:28 -0400 Subject: [PATCH 03/29] Adjust endpoint, prevent from crashing for large histories --- lib/galaxy/webapps/galaxy/controllers/history.py | 11 +---------- templates/webapps/galaxy/history/display.mako | 16 ++++++++-------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/lib/galaxy/webapps/galaxy/controllers/history.py b/lib/galaxy/webapps/galaxy/controllers/history.py index d02f1443af3..a3e2040cc22 100644 --- a/lib/galaxy/webapps/galaxy/controllers/history.py +++ b/lib/galaxy/webapps/galaxy/controllers/history.py @@ -566,13 +566,12 @@ class HistoryController(BaseUIController, SharableMixin, UsesAnnotations, UsesIt user = session.query(model.User).filter_by(username=username).first() history = ( trans.sa_session.query(model.History) - .options(joinedload("tags")) - .options(joinedload("annotations")) .filter_by(user=user, slug=slug, deleted=False) .first() ) if history is None: raise web.httpexceptions.HTTPNotFound() + # Security check raises error if user cannot access history. self.history_manager.error_unless_accessible(history, trans.user, current_history=trans.history) @@ -587,18 +586,10 @@ class HistoryController(BaseUIController, SharableMixin, UsesAnnotations, UsesIt ave_item_rating, num_ratings = self.get_ave_item_rating_data(trans.sa_session, history) # create ownership flag for template, dictify models - user_is_owner = trans.user == history.user - history_dictionary = self.history_serializer.serialize_to_view( - history, view="dev-detailed", user=trans.user, trans=trans - ) - history_dictionary["annotation"] = self.get_item_annotation_str(trans.sa_session, history.user, history) - return trans.fill_template_mako( "history/display.mako", item=history, item_data=[], - user_is_owner=user_is_owner, - history_dict=history_dictionary, user_item_rating=user_item_rating, ave_item_rating=ave_item_rating, num_ratings=num_ratings, diff --git a/templates/webapps/galaxy/history/display.mako b/templates/webapps/galaxy/history/display.mako index 514eb641f0a..e0ec6d45bf0 100644 --- a/templates/webapps/galaxy/history/display.mako +++ b/templates/webapps/galaxy/history/display.mako @@ -15,12 +15,12 @@ <%def name="render_item( item, item_data )"> -
- + <% history_id = trans.security.encode_id(item.id) %> +
+ From 3c04f727e83930871fb413c07ea5311167a58bc8 Mon Sep 17 00:00:00 2001 From: guerler Date: Tue, 20 Sep 2022 10:10:58 -0400 Subject: [PATCH 04/29] Augment history store, avoid loosing already stored histories --- client/src/components/History/HistoryView.vue | 3 --- client/src/store/historyStore/historyStore.js | 22 ++++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/client/src/components/History/HistoryView.vue b/client/src/components/History/HistoryView.vue index 67891c2de8d..cfadfe598ad 100644 --- a/client/src/components/History/HistoryView.vue +++ b/client/src/components/History/HistoryView.vue @@ -35,9 +35,6 @@ @view-collection="onViewCollection" /> - - - diff --git a/client/src/store/historyStore/historyStore.js b/client/src/store/historyStore/historyStore.js index 0c6a3814b65..6a15c2deb9a 100644 --- a/client/src/store/historyStore/historyStore.js +++ b/client/src/store/historyStore/historyStore.js @@ -32,13 +32,23 @@ const mutations = { Vue.delete(state.histories, doomed.id); }, setHistories(state, newHistories = []) { - // The incoming history list contains less information than the current history - // so we ensure that already available details are not getting lost + // The incoming history list may contain less information than the already stored + // histories, so we ensure that already available details are not getting lost. const enrichedHistories = newHistories.map((history) => { const historyState = state.histories[history.id] || {}; return Object.assign({}, history, historyState); }); + // Histories are provided as list but stored as map. const newMap = enrichedHistories.reduce((acc, h) => ({ ...acc, [h.id]: h }), {}); + // Ensure that already stored histories, which are not available in the incoming array, + // are not lost. This happens e.g. with shared histories since they have different owners. + state.histories.forEach((history) => { + const historyId = history.id; + if (!newMap[historyId]) { + newMap[historyId] = history; + } + }); + // Update stored histories Vue.set(state, "histories", newMap); }, setHistoriesLoading(state, isLoading) { @@ -82,7 +92,7 @@ const getters = { }; // flags to keep track of loading states -const isLoadingHistory = new Map(); +const isLoadingHistory = new Set(); let isLoadingHistories = false; const actions = { @@ -125,7 +135,7 @@ const actions = { }, loadHistoryById({ dispatch }, id) { if (!isLoadingHistory.has(id)) { - const p = getHistoryById(id) + getHistoryById(id) .then((history) => { dispatch("setHistory", history); }) @@ -135,7 +145,7 @@ const actions = { .finally(() => { isLoadingHistory.delete(id); }); - //isLoadingHistory.set(id, p); + isLoadingHistory.add(id); } }, resetHistory({ commit }) { @@ -150,7 +160,7 @@ const actions = { commit("setHistory", history); commit("setCurrentHistoryId", history.id); }, - async setCurrentHistory({ dispatch, getters }, id) { + async setCurrentHistory({ dispatch }, id) { const changedHistory = await setCurrentHistoryOnServer(id); return dispatch("selectHistory", changedHistory); }, From 976f9487b0e2f9cb5db98f2c91f10ac487512ec3 Mon Sep 17 00:00:00 2001 From: guerler Date: Tue, 20 Sep 2022 10:44:04 -0400 Subject: [PATCH 05/29] Expand usage of writable prop in history panel to allow read only histories --- client/src/components/History/Content/ContentItem.vue | 5 ++++- client/src/components/History/Content/ContentOptions.vue | 9 +++++---- .../History/Content/Dataset/DatasetActions.vue | 3 ++- .../History/Content/Dataset/DatasetDetails.vue | 2 ++ .../components/History/CurrentHistory/HistoryPanel.vue | 7 ++++++- client/src/components/History/HistoryView.vue | 1 + client/src/components/History/Layout/DetailsLayout.vue | 2 +- 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/client/src/components/History/Content/ContentItem.vue b/client/src/components/History/Content/ContentItem.vue index 3711c7a9f03..785ab82fa70 100644 --- a/client/src/components/History/Content/ContentItem.vue +++ b/client/src/components/History/Content/ContentItem.vue @@ -52,6 +52,7 @@ @@ -97,6 +98,7 @@ export default { }, props: { dataset: { type: Object, required: true }, + writable: { type: Boolean, default: true }, showHighlight: { type: Boolean, default: false }, itemUrls: { type: Object, required: true }, }, diff --git a/client/src/components/History/CurrentHistory/HistoryPanel.vue b/client/src/components/History/CurrentHistory/HistoryPanel.vue index ded6ad9d475..d924aa70d63 100644 --- a/client/src/components/History/CurrentHistory/HistoryPanel.vue +++ b/client/src/components/History/CurrentHistory/HistoryPanel.vue @@ -35,7 +35,10 @@ :filter-text.sync="filterText" :show-advanced.sync="showAdvanced" />
- + diff --git a/client/src/components/History/Layout/DetailsLayout.vue b/client/src/components/History/Layout/DetailsLayout.vue index 629388419b3..91640105ada 100644 --- a/client/src/components/History/Layout/DetailsLayout.vue +++ b/client/src/components/History/Layout/DetailsLayout.vue @@ -1,7 +1,7 @@ From dd3f3a17c2669ec4e2b9b40595ad37349dba7fab Mon Sep 17 00:00:00 2001 From: guerler Date: Wed, 21 Sep 2022 20:01:34 -0400 Subject: [PATCH 12/29] Remove all legacy history imports from bundle --- client/src/bundleEntries.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/client/src/bundleEntries.js b/client/src/bundleEntries.js index f92233589f0..86a5a03d956 100644 --- a/client/src/bundleEntries.js +++ b/client/src/bundleEntries.js @@ -18,18 +18,8 @@ import Circster from "viz/circster"; export { PhylovizView as phyloviz } from "viz/phyloviz"; export { SweepsterVisualization, SweepsterVisualizationView } from "viz/sweepster"; export { createTabularDatasetChunkedView } from "mvc/dataset/data"; -export { History } from "mvc/history/history-model"; -export { HistoryContents } from "mvc/history/history-contents"; -// TODO: there are side effects in history-view-edit somewhere; follow up as legacy history panel bits are removed. -import { HistoryViewEdit } from "mvc/history/history-view-edit"; // eslint-disable-line no-unused-vars -export { historyEntry as history } from "mvc/history/history-view"; -export { default as HistoryViewAnnotated } from "mvc/history/history-view-annotated"; -export { default as HistoryCopyDialog } from "mvc/history/copy-dialog"; -export { default as HDAListItemEdit } from "mvc/history/hda-li-edit"; -export { default as HDAModel } from "mvc/history/hda-model"; export { default as LegacyGridView } from "legacy/grid/grid-view"; export { create_chart, create_histogram } from "reports/run_stats"; -export { default as ToolshedGroups } from "toolshed/toolshed.groups"; export { openGlobalUploadModal } from "components/Upload"; export { runTour } from "components/Tour/runTour"; export { Toast } from "ui/toast"; // TODO: remove when external consumers are updated/gone (IES right now) From ebd4d4ba06c3f215c17b4c71e3fee3fddbd56c72 Mon Sep 17 00:00:00 2001 From: guerler Date: Wed, 21 Sep 2022 20:16:38 -0400 Subject: [PATCH 13/29] Move job state model out of mvc/history to utils --- client/src/components/JobInformation/JobInformation.vue | 2 +- client/src/components/JobStates/wait.js | 2 +- client/src/components/RuleCollectionBuilder.vue | 2 +- .../WorkflowInvocationState/WorkflowInvocationState.vue | 2 +- client/src/components/admin/Jobs.vue | 2 +- client/src/components/providers/utils.js | 2 +- client/src/{mvc/history => utils}/job-states-model.js | 0 7 files changed, 6 insertions(+), 6 deletions(-) rename client/src/{mvc/history => utils}/job-states-model.js (100%) diff --git a/client/src/components/JobInformation/JobInformation.vue b/client/src/components/JobInformation/JobInformation.vue index 2a31f707a1f..9c520be436b 100644 --- a/client/src/components/JobInformation/JobInformation.vue +++ b/client/src/components/JobInformation/JobInformation.vue @@ -79,7 +79,7 @@ import CodeRow from "./CodeRow.vue"; import { JobDetailsProvider } from "components/providers/JobProvider"; import UtcDate from "components/UtcDate"; import CopyToClipboard from "components/CopyToClipboard"; -import JOB_STATES_MODEL from "mvc/history/job-states-model"; +import JOB_STATES_MODEL from "utils/job-states-model"; import { formatDuration, intervalToDuration } from "date-fns"; export default { diff --git a/client/src/components/JobStates/wait.js b/client/src/components/JobStates/wait.js index 880edd3afff..0c5621cc219 100644 --- a/client/src/components/JobStates/wait.js +++ b/client/src/components/JobStates/wait.js @@ -1,5 +1,5 @@ import { getAppRoot } from "onload/loadConfig"; -import JOB_STATES_MODEL from "mvc/history/job-states-model"; +import JOB_STATES_MODEL from "utils/job-states-model"; import axios from "axios"; export function waitOnJob(jobId, onStateUpdate = null, interval = 1000) { diff --git a/client/src/components/RuleCollectionBuilder.vue b/client/src/components/RuleCollectionBuilder.vue index ab4ae62bf69..1a2f50e2093 100644 --- a/client/src/components/RuleCollectionBuilder.vue +++ b/client/src/components/RuleCollectionBuilder.vue @@ -574,7 +574,7 @@ import _l from "utils/localization"; import { refreshContentsWrapper } from "utils/data"; import HotTable from "@handsontable/vue"; import UploadUtils from "mvc/upload/upload-utils"; -import JobStatesModel from "mvc/history/job-states-model"; +import JobStatesModel from "utils/job-states-model"; import RuleDefs from "mvc/rules/rule-definitions"; import Vue from "vue"; import BootstrapVue from "bootstrap-vue"; diff --git a/client/src/components/WorkflowInvocationState/WorkflowInvocationState.vue b/client/src/components/WorkflowInvocationState/WorkflowInvocationState.vue index c4da850d742..b8186244d4c 100644 --- a/client/src/components/WorkflowInvocationState/WorkflowInvocationState.vue +++ b/client/src/components/WorkflowInvocationState/WorkflowInvocationState.vue @@ -36,7 +36,7 @@ import WorkflowInvocationSummary from "./WorkflowInvocationSummary.vue"; import WorkflowInvocationDetails from "./WorkflowInvocationDetails.vue"; import WorkflowInvocationExportOptions from "./WorkflowInvocationExportOptions.vue"; -import JOB_STATES_MODEL from "mvc/history/job-states-model"; +import JOB_STATES_MODEL from "utils/job-states-model"; import mixin from "components/JobStates/mixin"; import { mapGetters, mapActions } from "vuex"; diff --git a/client/src/components/admin/Jobs.vue b/client/src/components/admin/Jobs.vue index 2ff17dee792..feef58d091b 100644 --- a/client/src/components/admin/Jobs.vue +++ b/client/src/components/admin/Jobs.vue @@ -106,7 +106,7 @@ import { getAppRoot } from "onload/loadConfig"; import axios from "axios"; import JobsTable from "components/admin/JobsTable"; import JobLock from "./JobLock"; -import JOB_STATES_MODEL from "mvc/history/job-states-model"; +import JOB_STATES_MODEL from "utils/job-states-model"; import { commonJobFields } from "./JobFields"; import { errorMessageAsString } from "utils/simple-error"; import { jobsProvider } from "components/providers/JobProvider"; diff --git a/client/src/components/providers/utils.js b/client/src/components/providers/utils.js index 56d3bf6bd9c..cfa2aa90610 100644 --- a/client/src/components/providers/utils.js +++ b/client/src/components/providers/utils.js @@ -1,4 +1,4 @@ -import JOB_STATES_MODEL from "mvc/history/job-states-model"; +import JOB_STATES_MODEL from "utils/job-states-model"; import { snakeCase } from "snake-case"; export function stateIsTerminal(result) { diff --git a/client/src/mvc/history/job-states-model.js b/client/src/utils/job-states-model.js similarity index 100% rename from client/src/mvc/history/job-states-model.js rename to client/src/utils/job-states-model.js From 2f5dd3a2ffec4f472b3e49065eae2a2eb8fd4d7f Mon Sep 17 00:00:00 2001 From: guerler Date: Wed, 21 Sep 2022 20:19:13 -0400 Subject: [PATCH 14/29] Move grid related histroy list to Grids component --- client/src/components/Grid/GridHistory.vue | 2 +- client/src/{mvc/history => components/Grid}/history-list.js | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename client/src/{mvc/history => components/Grid}/history-list.js (100%) diff --git a/client/src/components/Grid/GridHistory.vue b/client/src/components/Grid/GridHistory.vue index 46bbbe72677..8f91a6af438 100644 --- a/client/src/components/Grid/GridHistory.vue +++ b/client/src/components/Grid/GridHistory.vue @@ -3,7 +3,7 @@