diff --git a/client/src/components/Workflow/TrsImport.vue b/client/src/components/Workflow/TrsImport.vue index 0391f29bf04..eaf78eba916 100644 --- a/client/src/components/Workflow/TrsImport.vue +++ b/client/src/components/Workflow/TrsImport.vue @@ -90,7 +90,7 @@ export default { this.errorMessage = null; const version = this.trsTool.versions.find((version) => version.id === this.queryTrsVersionId); if (version) { - this.importVersion(this.trsTool.id, version); + this.importVersion(this.trsTool.id, version, true); } }) .catch((errorMessage) => { diff --git a/client/src/components/Workflow/WorkflowImport.vue b/client/src/components/Workflow/WorkflowImport.vue index 1dec22910db..53797936ce9 100644 --- a/client/src/components/Workflow/WorkflowImport.vue +++ b/client/src/components/Workflow/WorkflowImport.vue @@ -31,6 +31,7 @@ import { getGalaxyInstance } from "app"; import axios from "axios"; import Vue from "vue"; import BootstrapVue from "bootstrap-vue"; +import {redirectOnImport} from "./utils" Vue.use(BootstrapVue); @@ -67,9 +68,7 @@ export default { axios .post(`${getAppRoot()}api/workflows`, formData) .then((response) => { - window.location = `${getAppRoot()}workflows/list?message=${ - response.data.message - }&status=success`; + redirectOnImport(getAppRoot(), response.data) }) .catch((error) => { const message = error.response.data && error.response.data.err_msg; diff --git a/client/src/components/Workflow/trsMixin.js b/client/src/components/Workflow/trsMixin.js index 44dbde859f9..6a0c29043d5 100644 --- a/client/src/components/Workflow/trsMixin.js +++ b/client/src/components/Workflow/trsMixin.js @@ -1,6 +1,7 @@ import { getAppRoot } from "onload/loadConfig"; import TrsServerSelection from "./TrsServerSelection"; import TrsTool from "./TrsTool"; +import { redirectOnImport } from "./utils"; export default { components: { @@ -8,12 +9,19 @@ export default { TrsTool, }, methods: { - importVersion(toolId, version) { + importVersion(toolId, version, isRunFormRedirect = false) { this.services .importTrsTool(this.trsSelection.id, toolId, version.name) .then((response_data) => { - // copied from the WorkflowImport, de-duplicate somehow - window.location = `${getAppRoot()}workflows/list?message=${response_data.message}&status=success`; + console.log("isRunFormRedirect", isRunFormRedirect); + console.log("isRunFormRedirect", isRunFormRedirect); + console.log("isRunFormRedirect", isRunFormRedirect); + console.log("isRunFormRedirect", isRunFormRedirect); + console.log("isRunFormRedirect", isRunFormRedirect); + console.log("isRunFormRedirect", isRunFormRedirect); + console.log("isRunFormRedirect", isRunFormRedirect); + console.log("isRunFormRedirect", isRunFormRedirect); + redirectOnImport(getAppRoot(), response_data, isRunFormRedirect); }) .catch((errorMessage) => { this.errorMessage = errorMessage || "Import failed for an unknown reason."; diff --git a/client/src/components/Workflow/utils.js b/client/src/components/Workflow/utils.js new file mode 100644 index 00000000000..03c8d7634be --- /dev/null +++ b/client/src/components/Workflow/utils.js @@ -0,0 +1,5 @@ +export function redirectOnImport(appRoot, response, isRunFormRedirect = false) { + isRunFormRedirect + ? (window.location = `${appRoot}workflows/run?id=${response.id}`) + : (window.location = `${appRoot}workflows/list?message=${response.message}&status=success`); +} diff --git a/lib/galaxy/webapps/galaxy/api/workflows.py b/lib/galaxy/webapps/galaxy/api/workflows.py index fe0d8ea0411..ca123f8d1f3 100644 --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -678,14 +678,21 @@ class WorkflowsAPIController(BaseAPIController, UsesStoredWorkflowMixin, UsesAnn raise exceptions.MessageException("The data content is missing.") raw_workflow_description = self.__normalize_workflow(trans, data) workflow, missing_tool_tups = self._workflow_from_dict(trans, raw_workflow_description, source=source) + workflow_id = workflow.id workflow = workflow.latest_workflow + + response = {"message": "Workflow '%s' imported successfully." % escape(workflow.name), "status": "success", + "id": trans.security.encode_id(workflow_id)} if workflow.has_errors: - return {"message": "Imported, but some steps in this workflow have validation errors.", "status": "error"} + response["message"] = "Imported, but some steps in this workflow have validation errors." + response["status"] = "error" elif len(workflow.steps) == 0: - return {"message": "Imported, but this workflow has no steps.", "status": "error"} + response["message"] = "Imported, but this workflow has no steps." + response["status"] = "error" elif workflow.has_cycles: - return {"message": "Imported, but this workflow contains cycles.", "status": "error"} - return {"message": "Workflow '%s' imported successfully." % escape(workflow.name), "status": "success"} + response["message"] = "Imported, but this workflow contains cycles." + response["status"] = "error" + return response def __api_import_new_workflow(self, trans, payload, **kwd): data = payload['workflow']