Skip to content

Commit 54dcae6

Browse files
use newly updated PUT /api/workflows/{workflow_id} in client
1 parent 0c2238c commit 54dcae6

9 files changed

Lines changed: 463 additions & 36 deletions

File tree

client/src/api/schema/schema.ts

Lines changed: 387 additions & 8 deletions
Large diffs are not rendered by default.

client/src/api/workflows.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { GalaxyApi } from "./client";
55

66
export type Creator = components["schemas"]["Person"] | components["schemas"]["galaxy__schema__schema__Organization"];
77
export type StoredWorkflowDetailed = components["schemas"]["StoredWorkflowDetailed"];
8+
export type UpdateWorkflowPayload = components["schemas"]["UpdateWorkflowPayload"];
89

910
//TODO: replace with generated schema model when available
1011
export type WorkflowSummary = {
@@ -118,6 +119,23 @@ export async function undeleteWorkflow(id: string): Promise<WorkflowSummary> {
118119
return data as WorkflowSummary;
119120
}
120121

122+
export async function updateWorkflow(id: string, payload: UpdateWorkflowPayload): Promise<WorkflowSummary> {
123+
const { data, error } = await GalaxyApi().PUT("/api/workflows/{workflow_id}", {
124+
params: {
125+
path: {
126+
workflow_id: id,
127+
},
128+
},
129+
body: payload,
130+
});
131+
132+
if (error) {
133+
rethrowSimple(error);
134+
}
135+
136+
return data as WorkflowSummary;
137+
}
138+
121139
export function hasCreator(entry?: AnyWorkflow): entry is StoredWorkflowDetailed {
122140
return entry !== undefined && "creator" in entry && !!entry.creator;
123141
}

client/src/components/Workflow/Editor/modules/model.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { UpdateWorkflowPayload } from "@/api/workflows";
12
import reportDefault from "@/components/Workflow/Editor/reportDefault";
23
import { useWorkflowCommentStore, type WorkflowComment } from "@/stores/workflowEditorCommentStore";
34
import { useWorkflowStateStore } from "@/stores/workflowEditorStateStore";
@@ -134,8 +135,9 @@ export async function fromSimple(
134135
toolbarStore.currentTool = "pointer";
135136
}
136137

137-
export function toSimple(id: string, workflow: Workflow): Omit<Workflow, "version"> {
138-
const steps = workflow.steps;
138+
export function toSimple(id: string, workflow: Workflow): UpdateWorkflowPayload {
139+
// TODO: This is a temporary workaround; we need to use the backend types for `Steps` in the stores.
140+
const steps = workflow.steps as any;
139141
const report = workflow.report;
140142
const license = workflow.license;
141143
const creator = workflow.creator;
@@ -146,12 +148,29 @@ export function toSimple(id: string, workflow: Workflow): Omit<Workflow, "versio
146148
const readme = workflow.readme;
147149
const help = workflow.help;
148150
const doi = workflow.doi;
151+
const update_stored_workflow_attributes = true;
152+
const exact_tools = true;
149153

150154
const commentStore = useWorkflowCommentStore(id);
151155
commentStore.resolveCommentsInFrames();
152156
commentStore.resolveStepsInFrames();
153157

154158
const comments = workflow.comments.filter((comment) => !(comment.type === "text" && comment.data.text === ""));
155159

156-
return { steps, report, license, creator, annotation, name, comments, tags, readme, help, logo_url, doi };
160+
return {
161+
steps,
162+
report,
163+
license,
164+
creator,
165+
annotation,
166+
name,
167+
comments,
168+
tags,
169+
readme,
170+
help,
171+
logo_url,
172+
doi,
173+
update_stored_workflow_attributes,
174+
exact_tools,
175+
};
157176
}

client/src/components/Workflow/Editor/modules/services.js renamed to client/src/components/Workflow/Editor/modules/services.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import axios from "axios";
2-
import { getAppRoot } from "onload/loadConfig";
3-
import { errorMessageAsString, rethrowSimple } from "utils/simple-error";
42

5-
import { toSimple } from "./model";
3+
import { updateWorkflow, type WorkflowSummary } from "@/api/workflows";
4+
import { getAppRoot } from "@/onload/loadConfig";
5+
import { errorMessageAsString, rethrowSimple } from "@/utils/simple-error";
6+
7+
import { toSimple, type Workflow } from "./model";
68

79
/** Workflow data request helper **/
8-
export async function getVersions(id) {
10+
export async function getVersions(id: string) {
911
try {
1012
const { data } = await axios.get(`${getAppRoot()}api/workflows/${id}/versions`);
1113
return data;
@@ -14,7 +16,11 @@ export async function getVersions(id) {
1416
}
1517
}
1618

17-
export async function getModule(request_data, stepId, setLoadingState) {
19+
export async function getModule(
20+
request_data: Record<string, any>,
21+
stepId: number,
22+
setLoadingState: (stepId: number, loading: boolean, error?: string) => void
23+
) {
1824
setLoadingState(stepId, true);
1925
try {
2026
const { data } = await axios.post(`${getAppRoot()}api/workflows/build_module`, request_data);
@@ -26,7 +32,7 @@ export async function getModule(request_data, stepId, setLoadingState) {
2632
}
2733
}
2834

29-
export async function refactor(id, actions, dryRun = false) {
35+
export async function refactor(id: string, actions: Record<string, any>, dryRun = false) {
3036
try {
3137
const requestData = {
3238
actions: actions,
@@ -40,7 +46,7 @@ export async function refactor(id, actions, dryRun = false) {
4046
}
4147
}
4248

43-
export async function loadWorkflow({ id, version = null }) {
49+
export async function loadWorkflow({ id, version = null }: { id: string; version?: number | null }) {
4450
try {
4551
const versionQuery = Number.isInteger(version) ? `version=${version}` : "";
4652
const { data } = await axios.get(`${getAppRoot()}workflow/load_workflow?_=true&id=${id}&${versionQuery}`);
@@ -51,11 +57,16 @@ export async function loadWorkflow({ id, version = null }) {
5157
}
5258
}
5359

54-
export async function saveWorkflow(workflow) {
60+
// TODO: The backend return will be typed as the update response
61+
type WorkflowSummaryExtended = WorkflowSummary & {
62+
version: number;
63+
annotation: string;
64+
};
65+
export async function saveWorkflow(workflow: Record<string, any>) {
5566
if (workflow.hasChanges) {
5667
try {
57-
const requestData = { workflow: toSimple(workflow.id, workflow), from_tool_form: true };
58-
const { data } = await axios.put(`${getAppRoot()}api/workflows/${workflow.id}`, requestData);
68+
const requestData = { ...toSimple(workflow.id, workflow as Workflow), from_tool_form: true };
69+
const data = (await updateWorkflow(workflow.id, requestData)) as WorkflowSummaryExtended;
5970
workflow.name = data.name;
6071
workflow.hasChanges = false;
6172
workflow.stored = true;
@@ -71,7 +82,7 @@ export async function saveWorkflow(workflow) {
7182
return {};
7283
}
7384

74-
export async function getToolPredictions(requestData) {
85+
export async function getToolPredictions(requestData: Record<string, any>) {
7586
try {
7687
const { data } = await axios.post(`${getAppRoot()}api/workflows/get_tool_predictions`, requestData);
7788
return data;

client/src/components/Workflow/List/WorkflowCard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { storeToRefs } from "pinia";
33
import { computed } from "vue";
44
55
import type { WorkflowSummary } from "@/api/workflows";
6+
import { updateWorkflow } from "@/api/workflows";
67
import { useWorkflowCardActions } from "@/components/Workflow/List/useWorkflowCardActions";
78
import { useWorkflowCardBadges } from "@/components/Workflow/List/useWorkflowCardBadges";
89
import { useWorkflowCardIndicators } from "@/components/Workflow/List/useWorkflowCardIndicators";
9-
import { updateWorkflow } from "@/components/Workflow/workflows.services";
1010
import { useUserStore } from "@/stores/userStore";
1111
1212
import GCard from "@/components/Common/GCard.vue";
@@ -65,7 +65,7 @@ const description = computed(() => {
6565
6666
async function onTagsUpdate(tags: string[]) {
6767
workflow.value.tags = tags;
68-
await updateWorkflow(workflow.value.id, { tags });
68+
await updateWorkflow(workflow.value.id, { tags, update_stored_workflow_attributes: true, exact_tools: true });
6969
emit("refreshList", true, true);
7070
}
7171

client/src/components/Workflow/List/WorkflowList.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { filter } from "underscore";
77
import { computed, onMounted, ref, watch } from "vue";
88
import { useRouter } from "vue-router/composables";
99
10-
import { loadWorkflows, undeleteWorkflow, type WorkflowSummary } from "@/api/workflows";
10+
import { loadWorkflows, undeleteWorkflow, updateWorkflow, type WorkflowSummary } from "@/api/workflows";
1111
import { getWorkflowFilters, helpHtml } from "@/components/Workflow/List/workflowFilters";
12-
import { deleteWorkflow, updateWorkflow } from "@/components/Workflow/workflows.services";
12+
import { deleteWorkflow } from "@/components/Workflow/workflows.services";
1313
import { useConfirmDialog } from "@/composables/confirmDialog";
1414
import { Toast } from "@/composables/toast";
1515
import { useUserStore } from "@/stores/userStore";
@@ -306,7 +306,11 @@ async function onBulkTagsAdd(tags: string[]) {
306306
for (const w of selectedWorkflowIds.value) {
307307
const prevTags = workflowsLoaded.value.find((workflow) => workflow.id === w.id)?.tags || [];
308308
309-
await updateWorkflow(w.id, { tags: [...new Set([...prevTags, ...tags])] });
309+
await updateWorkflow(w.id, {
310+
tags: [...new Set([...prevTags, ...tags])],
311+
update_stored_workflow_attributes: true,
312+
exact_tools: true,
313+
});
310314
311315
tmpSelected.splice(
312316
tmpSelected.findIndex((s) => s.id === w.id),

client/src/components/Workflow/List/WorkflowRename.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { BForm, BFormInput, BModal } from "bootstrap-vue";
33
import { ref } from "vue";
44
5-
import { updateWorkflow } from "@/components/Workflow/workflows.services";
5+
import { updateWorkflow } from "@/api/workflows";
66
import { Toast } from "@/composables/toast";
77
import localize from "@/utils/localization";
88
@@ -26,7 +26,7 @@ const workflowNameInput = ref<HTMLInputElement | null>(null);
2626
2727
async function onRename(newName: string) {
2828
try {
29-
await updateWorkflow(props.id, { name: newName });
29+
await updateWorkflow(props.id, { name: newName, update_stored_workflow_attributes: true, exact_tools: true });
3030
Toast.success("Workflow renamed");
3131
} catch (e) {
3232
Toast.error("Failed to rename workflow");

client/src/components/Workflow/List/useWorkflowCardActions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ import { storeToRefs } from "pinia";
1616
import { computed, type Ref } from "vue";
1717

1818
import type { WorkflowSummary } from "@/api/workflows";
19-
import { undeleteWorkflow } from "@/api/workflows";
19+
import { undeleteWorkflow, updateWorkflow as updateWorkflowService } from "@/api/workflows";
2020
import { getFullAppUrl } from "@/app/utils";
2121
import type { CardAttributes } from "@/components/Common/GCard.types";
2222
import {
2323
copyWorkflow as copyWorkflowService,
2424
deleteWorkflow as deleteWorkflowService,
25-
updateWorkflow as updateWorkflowService,
2625
} from "@/components/Workflow/workflows.services";
2726
import { useConfirmDialog } from "@/composables/confirmDialog";
2827
import { useToast } from "@/composables/toast";
@@ -109,6 +108,8 @@ export function useWorkflowCardActions(
109108
try {
110109
await updateWorkflowService(workflow.value.id, {
111110
show_in_tool_panel: checked,
111+
update_stored_workflow_attributes: true,
112+
exact_tools: true,
112113
});
113114

114115
toast.info(`Workflow ${checked ? "added to" : "removed from"} bookmarks`);

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ import type { WorkflowSummary } from "@/api/workflows";
44
import { useUserStore } from "@/stores/userStore";
55
import { withPrefix } from "@/utils/redirect";
66

7-
export async function updateWorkflow(id: string, changes: object): Promise<WorkflowSummary> {
8-
const { data } = await axios.put(withPrefix(`/api/workflows/${id}`), changes);
9-
return data;
10-
}
11-
127
export async function copyWorkflow(id: string, currentOwner?: string, version?: string): Promise<WorkflowSummary> {
138
let path = `/api/workflows/${id}/download`;
149
if (version) {

0 commit comments

Comments
 (0)