Skip to content

Commit

Permalink
Merge pull request #16008 from hujambo-dunia/fix-toaster-onclick
Browse files Browse the repository at this point in the history
Fix for link pop-up window/toaster after Data Library to History import
  • Loading branch information
dannon authored Apr 27, 2023
2 parents 4950310 + c3e5f0c commit 45c50c2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var ImportDatasetModal = Backbone.View.extend({
// set the used history as current so user will see the last one
// that he imported into in the history panel on the 'analysis' page
$.getJSON(`${getAppRoot()}history/set_as_current?id=${history_id}`);
this.chainCallImportingIntoHistory(items_to_import, history_name);
this.chainCallImportingIntoHistory(items_to_import, history_name, history_id);
},

initChainCallControlToHistory: function (options) {
Expand All @@ -147,27 +147,23 @@ var ImportDatasetModal = Backbone.View.extend({
* @param {array} history_item_set array of empty history items
* @param {str} history_name name of the history to import to
*/
chainCallImportingIntoHistory: function (history_item_set, history_name) {
chainCallImportingIntoHistory: function (history_item_set, history_name, history_id) {
const Galaxy = getGalaxyInstance();
var popped_item = history_item_set.pop();
if (typeof popped_item == "undefined") {
if (this.options.chain_call_control.failed_number === 0) {
Toast.success("Selected datasets imported into history. Click this to start analyzing it.", "", {
onclick: () => {
window.location = getAppRoot();
},
});
Toast.success(
"Click here to start analyzing it.",
"Selected datasets imported into history",
`${getAppRoot()}histories/view?id=${history_id}`
);
} else if (this.options.chain_call_control.failed_number === this.options.chain_call_control.total_number) {
Toast.error("There was an error and no datasets were imported into history.");
} else if (this.options.chain_call_control.failed_number < this.options.chain_call_control.total_number) {
Toast.warning(
"Some of the datasets could not be imported into history. Click this to see what was imported.",
"",
{
onclick: () => {
window.location = getAppRoot();
},
}
`${getAppRoot()}histories/view?id=${history_id}`
);
}
Galaxy.modal.hide();
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/Toast.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export default {
methods: {
showToast(message, title, variant) {
showToast(message, title, variant, href) {
this.$bvToast.toast(message, {
variant,
title,
href,
toaster: "b-toaster-bottom-right",
append: true,
solid: true,
Expand Down
16 changes: 8 additions & 8 deletions client/src/composables/toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ export const setToastComponentRef = (newRef: typeof toastRef) => {
* Use 'useToast' for the Composition Api instead.
*/
export const Toast = {
success(message: string, title = "Success") {
toastRef.value?.showToast(message, title, "success");
success(message: string, title = "Success", href = "") {
toastRef.value?.showToast(message, title, "success", href);
},

info(message: string, title = "Info") {
toastRef.value?.showToast(message, title, "info");
info(message: string, title = "Info", href = "") {
toastRef.value?.showToast(message, title, "info", href);
},

warning(message: string, title = "Warning") {
toastRef.value?.showToast(message, title, "warning");
warning(message: string, title = "Warning", href = "") {
toastRef.value?.showToast(message, title, "warning", href);
},

error(message: string, title = "Error") {
toastRef.value?.showToast(message, title, "danger");
error(message: string, title = "Error", href = "") {
toastRef.value?.showToast(message, title, "danger", href);
},
};

Expand Down

0 comments on commit 45c50c2

Please sign in to comment.