Skip to content

Commit 6adfb36

Browse files
Merge pull request #20774 from mvdbeek/drop_old_load_workflow_route
Drop old load_workflow controller method, use API
2 parents a06be1d + 93b3827 commit 6adfb36

File tree

12 files changed

+36
-232
lines changed

12 files changed

+36
-232
lines changed

client/src/api/workflows.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,15 @@ export async function loadWorkflows({
8686
return { data, totalMatches };
8787
}
8888

89-
export async function getWorkflowInfo(workflowId: string, version?: number) {
89+
export async function getWorkflowInfo(workflowId: string, version?: number, instance?: boolean) {
9090
const { data, error } = await GalaxyApi().GET("/api/workflows/{workflow_id}", {
9191
params: {
9292
path: {
9393
workflow_id: workflowId,
9494
},
9595
query: {
9696
version: version,
97+
instance: instance,
9798
},
9899
},
99100
});

client/src/components/Panels/ToolBox.vue

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { library } from "@fortawesome/fontawesome-svg-core";
33
import { faEye, faEyeSlash } from "@fortawesome/free-regular-svg-icons";
44
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
55
import { storeToRefs } from "pinia";
6-
import { computed, type ComputedRef, type PropType, type Ref, ref } from "vue";
6+
import { computed, type ComputedRef, type Ref, ref } from "vue";
77
88
import { useGlobalUploadModal } from "@/composables/globalUploadModal";
99
import { useToolRouting } from "@/composables/route";
@@ -25,15 +25,12 @@ const emit = defineEmits<{
2525
(e: "update:show-advanced", showAdvanced: boolean): void;
2626
(e: "update:panel-query", query: string): void;
2727
(e: "onInsertTool", toolId: string, toolName: string): void;
28-
(e: "onInsertModule", moduleName: string, moduleTitle: string | undefined): void;
2928
}>();
3029
3130
const props = defineProps({
3231
workflow: { type: Boolean, default: false },
3332
showAdvanced: { type: Boolean, default: false, required: true },
3433
panelQuery: { type: String, required: true },
35-
dataManagers: { type: Array, default: null },
36-
moduleSections: { type: Array as PropType<Record<string, any>>, default: null },
3734
useSearchWorker: { type: Boolean, default: true },
3835
});
3936
@@ -71,17 +68,6 @@ const hasResults = computed(() => results.value.length > 0);
7168
const queryTooShort = computed(() => query.value && query.value.length < 3);
7269
const queryFinished = computed(() => query.value && queryPending.value != true);
7370
74-
const hasDataManagerSection = computed(() => props.workflow && props.dataManagers && props.dataManagers.length > 0);
75-
const dataManagerSection = computed(() => {
76-
const dynamicSection: ToolSectionType = {
77-
model_class: "ToolSection",
78-
id: "__data_managers",
79-
name: localize("Data Managers"),
80-
elems: props.dataManagers as Tool[],
81-
};
82-
return dynamicSection;
83-
});
84-
8571
/** `toolsById` from `toolStore`, except it only has valid tools for `props.workflow` value */
8672
const localToolsById = computed(() => {
8773
if (toolStore.toolsById && Object.keys(toolStore.toolsById).length > 0) {
@@ -132,11 +118,6 @@ const localPanel: ComputedRef<Record<string, Tool | ToolSectionType> | null> = c
132118
const buttonIcon = computed(() => (showSections.value ? faEyeSlash : faEye));
133119
const buttonText = computed(() => (showSections.value ? localize("Hide Sections") : localize("Show Sections")));
134120
135-
function onInsertModule(module: Record<string, any>, event: Event) {
136-
event.preventDefault();
137-
emit("onInsertModule", module.name, module.title);
138-
}
139-
140121
function onToolClick(tool: Tool, evt: Event) {
141122
if (!props.workflow) {
142123
if (tool.id === "upload1") {
@@ -231,24 +212,6 @@ function onToggle() {
231212
<div v-if="!propShowAdvanced" class="unified-panel-body">
232213
<div class="toolMenuContainer">
233214
<div v-if="localPanel" class="toolMenu">
234-
<div v-if="props.workflow">
235-
<ToolSection
236-
v-for="category in moduleSections"
237-
:key="category.name"
238-
:hide-name="true"
239-
:category="category"
240-
tool-key="name"
241-
:section-name="category.name"
242-
:query-filter="queryFilter || undefined"
243-
:disable-filter="true"
244-
@onClick="onInsertModule" />
245-
</div>
246-
<ToolSection
247-
v-if="hasDataManagerSection"
248-
:category="dataManagerSection"
249-
:query-filter="queryFilter || undefined"
250-
:disable-filter="true"
251-
@onClick="onToolClick" />
252215
<div v-for="(panel, key) in localPanel" :key="key">
253216
<ToolSection
254217
v-if="panel"

client/src/components/Panels/ToolPanel.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ describe("ToolPanel", () => {
108108
propsData: {
109109
workflow: false,
110110
editorWorkflows: null,
111-
dataManagers: null,
112-
moduleSections: null,
113111
useSearchWorker: false,
114112
},
115113
localVue,

client/src/components/Panels/ToolPanel.vue

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,11 @@ const toolStore = useToolStore();
2121
2222
const userStore = useUserStore();
2323
const props = defineProps({
24-
dataManagers: { type: Array, default: null },
25-
moduleSections: { type: Array, default: null },
2624
useSearchWorker: { type: Boolean, default: true },
2725
workflow: { type: Boolean, default: false },
2826
});
2927
3028
const emit = defineEmits<{
31-
(e: "onInsertModule", moduleName: string, moduleTitle: string | undefined): void;
3229
(e: "onInsertTool", toolId: string, toolName: string): void;
3330
(e: "onInsertWorkflow", workflowLatestId: string | undefined, workflowName: string): void;
3431
(e: "onInsertWorkflowSteps", workflowId: string, workflowStepCount: number | undefined): void;
@@ -108,10 +105,6 @@ async function updatePanelView(panelView: string) {
108105
panelName.value = "";
109106
}
110107
111-
function onInsertModule(moduleName: string, moduleTitle: string | undefined) {
112-
emit("onInsertModule", moduleName, moduleTitle);
113-
}
114-
115108
function onInsertTool(toolId: string, toolName: string) {
116109
emit("onInsertTool", toolId, toolName);
117110
}
@@ -191,11 +184,8 @@ initializePanel();
191184
:workflow="props.workflow"
192185
:panel-query.sync="query"
193186
:show-advanced.sync="showAdvanced"
194-
:data-managers="dataManagers"
195-
:module-sections="moduleSections"
196187
:use-search-worker="useSearchWorker"
197188
@onInsertTool="onInsertTool"
198-
@onInsertModule="onInsertModule"
199189
@onInsertWorkflow="onInsertWorkflow"
200190
@onInsertWorkflowSteps="onInsertWorkflowSteps" />
201191
<div v-else-if="errorMessage" data-description="tool panel error message">

client/src/components/Workflow/Editor/Index.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import { getLocalVue, mockUnprivilegedToolsRequest } from "tests/jest/helpers";
66

77
import { useServerMock } from "@/api/client/__mocks__";
88
import { testDatatypesMapper } from "@/components/Datatypes/test_fixtures";
9+
import { getWorkflowFull } from "@/components/Workflow/workflows.services";
910
import { getAppRoot } from "@/onload/loadConfig";
1011
import { useDatatypesMapperStore } from "@/stores/datatypesMapperStore";
1112

12-
import { getVersions, loadWorkflow } from "./modules/services";
13+
import { getVersions } from "./modules/services";
1314
import { getStateUpgradeMessages } from "./modules/utilities";
1415

1516
import Index from "./Index.vue";
@@ -22,14 +23,15 @@ jest.mock("./modules/services");
2223
jest.mock("layout/modal");
2324
jest.mock("onload/loadConfig");
2425
jest.mock("./modules/utilities");
26+
jest.mock("@/components/Workflow/workflows.services");
2527

2628
jest.mock("app");
2729

2830
const { server, http } = useServerMock();
2931

3032
const mockGetAppRoot = getAppRoot as jest.Mocked<typeof getAppRoot>;
3133
const mockGetStateUpgradeMessages = getStateUpgradeMessages as jest.Mock<typeof getStateUpgradeMessages>;
32-
const mockLoadWorkflow = loadWorkflow as jest.Mocked<typeof loadWorkflow>;
34+
const mockLoadWorkflow = getWorkflowFull as jest.Mocked<typeof getWorkflowFull>;
3335
const MockGetVersions = getVersions as jest.Mocked<typeof getVersions>;
3436

3537
describe("Index", () => {
@@ -54,8 +56,6 @@ describe("Index", () => {
5456
workflowId: "workflow_id",
5557
initialVersion: 1,
5658
workflowTags: ["moo", "cow"],
57-
moduleSections: [],
58-
dataManagers: [],
5959
workflows: [],
6060
toolbox: [],
6161
},

client/src/components/Workflow/Editor/Index.vue

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@
4545
<ToolPanel
4646
v-if="isActiveSideBar('workflow-editor-tools')"
4747
workflow
48-
:module-sections="moduleSections"
49-
:data-managers="dataManagers"
5048
@onInsertTool="onInsertTool"
51-
@onInsertModule="onInsertModule"
5249
@onInsertWorkflow="onInsertWorkflow"
5350
@onInsertWorkflowSteps="onInsertWorkflowSteps" />
5451
<SearchPanel v-if="isActiveSideBar('workflow-editor-search')" @result-clicked="onSearchResultClicked" />
@@ -226,6 +223,7 @@ import { storeToRefs } from "pinia";
226223
import Vue, { computed, nextTick, onUnmounted, ref, unref, watch } from "vue";
227224
228225
import { getUntypedWorkflowParameters } from "@/components/Workflow/Editor/modules/parameters";
226+
import { getWorkflowFull } from "@/components/Workflow/workflows.services";
229227
import { ConfirmDialog, useConfirmDialog } from "@/composables/confirmDialog";
230228
import { useDatatypesMapper } from "@/composables/datatypesMapper";
231229
import { useMagicKeys } from "@/composables/useMagicKeys";
@@ -247,7 +245,7 @@ import { useActivityLogic, useSpecialWorkflowActivities, workflowEditorActivitie
247245
import { getWorkflowInputs } from "./modules/inputs";
248246
import { fromSteps } from "./modules/labels";
249247
import { fromSimple } from "./modules/model";
250-
import { getModule, getVersions, loadWorkflow, saveWorkflow } from "./modules/services";
248+
import { getModule, getVersions, saveWorkflow } from "./modules/services";
251249
import { getStateUpgradeMessages } from "./modules/utilities";
252250
import reportDefault from "./reportDefault";
253251
@@ -305,14 +303,6 @@ export default {
305303
type: Array,
306304
default: () => [],
307305
},
308-
moduleSections: {
309-
type: Array,
310-
required: true,
311-
},
312-
dataManagers: {
313-
type: Array,
314-
required: true,
315-
},
316306
},
317307
setup(props, { emit }) {
318308
const { datatypes, datatypesMapper, datatypesMapperLoading } = useDatatypesMapper();
@@ -475,14 +465,6 @@ export default {
475465
476466
const tags = ref([]);
477467
478-
watch(
479-
() => props.workflowTags,
480-
(newTags) => {
481-
tags.value = [...newTags];
482-
},
483-
{ immediate: true }
484-
);
485-
486468
const setTagsHandler = new SetValueActionHandler(
487469
undoRedoStore,
488470
(value) => (tags.value = structuredClone(value)),
@@ -492,6 +474,7 @@ export default {
492474
/** user set tags. queues an undo/redo action */
493475
function setTags(newTags) {
494476
setTagsHandler.set(tags.value, newTags);
477+
hasChanges.value = true;
495478
}
496479
497480
watch(
@@ -850,7 +833,7 @@ export default {
850833
copyIntoWorkflow(id) {
851834
// Load workflow definition
852835
this.onWorkflowMessage("Importing workflow", "progress");
853-
loadWorkflow({ id }).then((data) => {
836+
getWorkflowFull(id).then((data) => {
854837
const action = new CopyIntoWorkflowAction(
855838
this.id,
856839
data,
@@ -1157,6 +1140,7 @@ export default {
11571140
this.hideModal();
11581141
this.stateMessages = getStateUpgradeMessages(data);
11591142
const has_changes = this.stateMessages.length > 0;
1143+
this.tags = data.tags;
11601144
this.license = data.license;
11611145
this.creator = data.creator;
11621146
this.doi = data.doi;
@@ -1172,7 +1156,7 @@ export default {
11721156
this.onWorkflowMessage("Loading workflow...", "progress");
11731157
11741158
try {
1175-
const data = await this.lastQueue.enqueue(loadWorkflow, { id, version });
1159+
const data = await this.lastQueue.enqueue(() => getWorkflowFull(id, version));
11761160
await fromSimple(id, data);
11771161
await this._loadEditorData(data);
11781162
} catch (e) {

client/src/components/Workflow/Editor/modules/services.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,6 @@ export async function refactor(id, actions, dryRun = false) {
4040
}
4141
}
4242

43-
export async function loadWorkflow({ id, version = null }) {
44-
try {
45-
const versionQuery = Number.isInteger(version) ? `version=${version}` : "";
46-
const { data } = await axios.get(`${getAppRoot()}workflow/load_workflow?_=true&id=${id}&${versionQuery}`);
47-
return data;
48-
} catch (e) {
49-
console.debug(e);
50-
rethrowSimple(e);
51-
}
52-
}
53-
5443
export async function saveWorkflow(workflow) {
5544
if (workflow.hasChanges) {
5645
try {

client/src/components/Workflow/workflows.services.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ export async function createWorkflow(workflowName: string, workflowAnnotation: s
4141
}
4242

4343
export async function getWorkflowFull(workflowId: string, version?: number) {
44-
let url = `/workflow/load_workflow?_=true&id=${workflowId}`;
45-
if (version !== undefined) {
46-
url += `&version=${version}`;
44+
const params: { style: string; version?: number } = { style: "editor" };
45+
if (Number.isInteger(version)) {
46+
params.version = version;
4747
}
48-
const { data } = await axios.get(withPrefix(url));
48+
const { data } = await axios.get(withPrefix(`/api/workflows/${workflowId}/download`), { params });
4949
return data;
5050
}

client/src/entry/analysis/modules/WorkflowEditor.vue

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
<template>
22
<Editor
3-
v-if="editorConfig"
3+
v-if="storedWorkflowId || newWorkflow"
44
:key="editorReloadKey"
5-
:workflow-id="editorConfig.id"
6-
:data-managers="editorConfig.dataManagers"
7-
:initial-version="editorConfig.initialVersion"
8-
:module-sections="editorConfig.moduleSections"
9-
:workflow-tags="editorConfig.tags"
5+
:workflow-id="storedWorkflowId"
6+
:initial-version="version"
107
@update:confirmation="$emit('update:confirmation', $event)"
118
@skipNextReload="() => (skipNextReload = true)" />
129
</template>
1310
<script>
1411
import Editor from "components/Workflow/Editor/Index";
1512
import Query from "utils/query-string-parsing";
16-
import { urlData } from "utils/url";
13+
14+
import { getWorkflowInfo } from "@/api/workflows";
1715
1816
export default {
1917
components: {
@@ -24,9 +22,10 @@ export default {
2422
storedWorkflowId: null,
2523
workflowId: null,
2624
version: null,
27-
editorConfig: null,
25+
storedWorkflow: null,
2826
editorReloadKey: 0,
2927
skipNextReload: false,
28+
newWorkflow: false,
3029
};
3130
},
3231
watch: {
@@ -40,32 +39,25 @@ export default {
4039
methods: {
4140
async getEditorConfig() {
4241
let reloadEditor = true;
43-
4442
if (this.skipNextReload) {
4543
reloadEditor = false;
4644
this.skipNextReload = false;
4745
}
46+
if (reloadEditor) {
47+
this.editorReloadKey += 1;
48+
}
4849
50+
this.version = Query.get("version");
4951
this.storedWorkflowId = Query.get("id");
5052
this.workflowId = Query.get("workflow_id");
51-
this.version = Query.get("version");
52-
this.previousHistoryLength = window.history.length;
53-
54-
const params = {};
55-
56-
if (this.workflowId) {
57-
params.workflow_id = this.workflowId;
58-
} else if (this.storedWorkflowId) {
59-
params.id = this.storedWorkflowId;
53+
const workflowId = this.workflowId || this.storedWorkflowId;
54+
if (!workflowId) {
55+
this.newWorkflow = true;
56+
return;
6057
}
61-
if (this.version) {
62-
params.version = this.version;
63-
}
64-
65-
this.editorConfig = await urlData({ url: "/workflow/editor", params });
66-
67-
if (reloadEditor) {
68-
this.editorReloadKey += 1;
58+
if (this.workflowId) {
59+
const { id: storedWorkflowId } = await getWorkflowInfo(workflowId, this.version, true);
60+
this.storedWorkflowId = storedWorkflowId;
6961
}
7062
},
7163
},

lib/galaxy/managers/workflows.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,7 @@ def _workflow_to_dict_editor(self, trans, stored, workflow, tooltip=True, is_sub
12611261
data["source_metadata"] = workflow.source_metadata
12621262
data["annotation"] = self.get_item_annotation_str(trans.sa_session, trans.user, stored) or ""
12631263
data["comments"] = [comment.to_dict() for comment in workflow.comments]
1264+
data["tags"] = stored.make_tag_string_list()
12641265

12651266
output_label_index = set()
12661267
input_step_types = set(workflow.input_step_types)

0 commit comments

Comments
 (0)