Skip to content

Commit

Permalink
Refactors saveWorkflow function signature
Browse files Browse the repository at this point in the history
Changes saveWorkflow to accept id and workflow separately
Simplifies request data construction and error handling
  • Loading branch information
itisAliRH committed Dec 4, 2024
1 parent 5d005f7 commit accb04e
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions client/src/components/Workflow/Editor/modules/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { toSimple } from "./model";
export async function getVersions(id) {
try {
const { data } = await axios.get(`${getAppRoot()}api/workflows/${id}/versions`);

return data;
} catch (e) {
rethrowSimple(e);
Expand Down Expand Up @@ -51,24 +52,24 @@ export async function loadWorkflow({ id, version = null }) {
}
}

export async function saveWorkflow(workflow) {
if (workflow.hasChanges) {
try {
const requestData = { workflow: toSimple(workflow.id, workflow), from_tool_form: true };
const { data } = await axios.put(`${getAppRoot()}api/workflows/${workflow.id}`, requestData);
workflow.name = data.name;
workflow.hasChanges = false;
workflow.stored = true;
workflow.version = data.version;
if (workflow.annotation || data.annotation) {
workflow.annotation = data.annotation;
}
return data;
} catch (e) {
rethrowSimple(e);
export async function saveWorkflow(id, workflow) {
try {
const requestData = { workflow, from_tool_form: true };
const { data } = await axios.put(`${getAppRoot()}api/workflows/${id}`, requestData);

workflow.name = data.name;
workflow.hasChanges = false;
workflow.stored = true;
workflow.version = data.version;

if (workflow.annotation || data.annotation) {
workflow.annotation = data.annotation;
}

return data;
} catch (e) {
rethrowSimple(e);
}
return {};
}

export async function getToolPredictions(requestData) {
Expand Down

0 comments on commit accb04e

Please sign in to comment.