Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[24.1] Fix pinia in manually mounted components #18315

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading