diff --git a/client/src/app/__mocks__/index.js b/client/src/app/__mocks__/index.js index d7dd9c5f59e..affc3d038d0 100644 --- a/client/src/app/__mocks__/index.js +++ b/client/src/app/__mocks__/index.js @@ -24,9 +24,9 @@ export function getGalaxyInstance() { model_class: "User", id: "f2db41e1fa331b3e", attributes: {}, - isAdmin: function() { + isAdmin: function () { return false; - } + }, }, root: "/", emit: { diff --git a/client/src/components/Upload/UploadModal.vue b/client/src/components/Upload/UploadModal.vue index 18bab28dc93..b1b6630428a 100644 --- a/client/src/components/Upload/UploadModal.vue +++ b/client/src/components/Upload/UploadModal.vue @@ -48,7 +48,7 @@ import LoadingSpan from "components/LoadingSpan"; import { mapState } from "vuex"; import { BModal, BTabs, BTab } from "bootstrap-vue"; -export default { +const UploadModal = { components: { Collection, Composite, @@ -57,7 +57,7 @@ export default { LoadingSpan, BModal, BTabs, - BTab + BTab, }, props: { modalStatic: { @@ -174,15 +174,9 @@ export default { }), currentHistoryId() { - // TODO: currentHistory is only in Vuex if beta is enabled - // Remove when no longer in beta - if ("betaHistory/currentHistoryId" in this.$store.getters) { - return this.$store.getters["betaHistory/currentHistoryId"]; - } else { - const Galaxy = getGalaxyInstance(); - const legacyId = Galaxy.currHistoryPanel?.model.get("id"); - return legacyId; - } + const Galaxy = getGalaxyInstance(); + const legacyId = Galaxy.currHistoryPanel?.model.get("id"); + return legacyId; }, historyAvailable() { @@ -341,4 +335,14 @@ export default { }, }, }; + +// Beta history patch +const useBetaHistory = sessionStorage.getItem("useBetaHistory"); +if (useBetaHistory) { + UploadModal.computed.currentHistoryId = function () { + return this.$store.getters["betaHistory/currentHistoryId"]; + }; +} + +export default UploadModal; diff --git a/client/src/components/Upload/mount.js b/client/src/components/Upload/mount.js index aa67e14010e..b59db4150bc 100644 --- a/client/src/components/Upload/mount.js +++ b/client/src/components/Upload/mount.js @@ -1,7 +1,6 @@ import Vue from "vue"; import UploadModal from "./UploadModal"; import { initializeUploadDefaults } from "./config"; -import store from "../../store"; export function mount(propsData = {}) { propsData = initializeUploadDefaults(propsData); @@ -10,6 +9,5 @@ export function mount(propsData = {}) { document.getElementsByTagName("body")[0].appendChild(vm); new instance({ propsData: propsData, - store, }).$mount(vm); } diff --git a/client/src/entry/panels/tool-panel.js b/client/src/entry/panels/tool-panel.js index 6fc694d6653..85d5581fa29 100644 --- a/client/src/entry/panels/tool-panel.js +++ b/client/src/entry/panels/tool-panel.js @@ -7,6 +7,7 @@ import Vue from "vue"; import ToolBox from "../../components/Panels/ToolBox"; import SidePanel from "../../components/Panels/SidePanel"; import { mountVueComponent } from "../../utils/mountVueComponent"; +import store from "../../store"; const ToolPanel = Backbone.View.extend({ initialize: function () { @@ -19,6 +20,7 @@ const ToolPanel = Backbone.View.extend({ $("body").append(vm); const upload = new modalInstance({ propsData: propsData, + store, }).$mount(vm); // attach upload entrypoint to Galaxy object diff --git a/client/src/store/index.js b/client/src/store/index.js index bae4ff0642a..aaea892b7ed 100644 --- a/client/src/store/index.js +++ b/client/src/store/index.js @@ -22,15 +22,13 @@ import { datasetsStore } from "./datasetsStore"; import { jobStore } from "./jobStore"; // beta features -import { historyStore as betaHistoryStore, historyPersist } from "components/History/model/historyStore"; +import { historyStore as betaHistoryStore } from "components/History/model/historyStore"; Vue.use(Vuex); export function createStore() { const storeConfig = { - plugins: [ - createCache(), - ], + plugins: [createCache()], modules: { gridSearch: gridSearchStore, histories: historyStore, @@ -48,29 +46,20 @@ export function createStore() { }, }; - // TODO: Remove conditional loads when history beta is complete + // Initialize store + if (!config.testBuild) { + storeConfig.plugins.push((store) => { + store.dispatch("user/$init", { store }); + store.dispatch("config/$init", { store }); + }); + } - // beta history panel features features const useBetaHistory = sessionStorage.getItem("useBetaHistory"); if (useBetaHistory) { storeConfig.modules.betaHistory = betaHistoryStore; - storeConfig.plugins.push(historyPersist.plugin); - } - - // Do not run initialization ajax calls when unit testing - if (!config.testBuild) { - const userInitPlugin = (store) => { - store.dispatch("user/$init", { store }); - store.dispatch("config/$init", { store }); - }; - storeConfig.plugins.push(userInitPlugin); - - if (useBetaHistory) { - const loadUserHistories = (store) => { - store.dispatch("betaHistory/$init", { store }); - }; - storeConfig.plugins.push(loadUserHistories); - } + storeConfig.plugins.push((store) => { + store.dispatch("betaHistory/$init", { store }); + }); } return new Vuex.Store(storeConfig); diff --git a/client/src/utils/mountVueComponent.js b/client/src/utils/mountVueComponent.js index 47151bcf315..42b8cd007e9 100644 --- a/client/src/utils/mountVueComponent.js +++ b/client/src/utils/mountVueComponent.js @@ -10,7 +10,7 @@ import { // legacyNavigationPlugin, eventHubPlugin, localizationPlugin, - vueRxShortcutPlugin + vueRxShortcutPlugin, } from "components/plugins"; // Bootstrap components