Skip to content

Commit

Permalink
Merge pull request galaxyproject#18315 from davelopez/24.1_fix_pinia_…
Browse files Browse the repository at this point in the history
…in_manually_mounted_components

[24.1] Fix pinia in manually mounted components
  • Loading branch information
mvdbeek authored Jun 4, 2024
2 parents c052641 + 67dd190 commit c681c0c
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 69 deletions.
7 changes: 3 additions & 4 deletions client/src/utils/mountVueComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import BootstrapVue from "bootstrap-vue";
import { iconPlugin, localizationPlugin, vueRxShortcutPlugin } from "components/plugins";
import { createPinia, PiniaVuePlugin } from "pinia";
import { getActivePinia, PiniaVuePlugin } from "pinia";
import Vue from "vue";

// Load Pinia
Expand All @@ -22,18 +22,17 @@ Vue.use(vueRxShortcutPlugin);
// font-awesome svg icon registration/loading
Vue.use(iconPlugin);

// Create Pinia
const pinia = createPinia();

export const mountVueComponent = (ComponentDefinition) => {
const component = Vue.extend(ComponentDefinition);
const pinia = getActivePinia();
return (propsData, el) => new component({ propsData, el, pinia });
};

export const replaceChildrenWithComponent = (el, ComponentDefinition, propsData = {}) => {
const container = document.createElement("div");
el.replaceChildren(container);
const component = Vue.extend(ComponentDefinition);
const pinia = getActivePinia();
const mountFn = (propsData, el) => new component({ propsData, el, pinia });
return mountFn(propsData, container);
};
123 changes: 62 additions & 61 deletions config/plugins/webhooks/demo/tour_generator/script.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions config/plugins/webhooks/demo/tour_generator/tour_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ window.TourGenerator = Backbone.View.extend({
$("#execute").attr("tour_id", "execute");
Toastr.info("Tour generation might take some time.");
$.getJSON(
`${Galaxy.root}api/webhooks/tour_generator/data/`, {
`${Galaxy.root}api/webhooks/tour_generator/data/`,
{
tool_id: toolId,
tool_version: toolVersion,
},
Expand All @@ -31,7 +32,7 @@ window.TourGenerator = Backbone.View.extend({
}
);
},
_getData: function(obj, attempts = 20, delay = 1000) {
_getData: function (obj, attempts = 20, delay = 1000) {
let datasets = [];
_.each(obj.data.hids, (hid) => {
Galaxy.currHistoryPanel.collection.each((dataset) => {
Expand All @@ -49,8 +50,8 @@ window.TourGenerator = Backbone.View.extend({
console.error("Some of the test datasets cannot be found in the history.");
}
},
_generateTour: function (data) {
const tour = window.bundleEntries.runTour("auto.generated", data);
_generateTour: async function (data) {
const tour = await window.bundleEntries.runTour("auto.generated", data);
// Force ending the tour when pressing the Execute button
$("#execute").on("mousedown", () => {
if (tour) {
Expand Down

0 comments on commit c681c0c

Please sign in to comment.