Skip to content

Commit

Permalink
change router.push -> window.location to scope wf stores to new id
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Nov 3, 2023
1 parent b80216e commit b00a94c
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 50 deletions.
2 changes: 1 addition & 1 deletion client/src/components/Workflow/Editor/Attributes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
:state="!nameCurrent ? false : null"
@keyup="$emit('update:nameCurrent', nameCurrent)" />
</div>
<div id="workflow-version-area" class="mt-2">
<div v-if="versionCurrent !== null" id="workflow-version-area" class="mt-2">
<b>Version</b>
<b-form-select v-model="versionCurrent" @change="onVersion">
<b-form-select-option v-for="v in versionOptions" :key="v.version" :value="v.version">
Expand Down
70 changes: 27 additions & 43 deletions client/src/components/Workflow/Editor/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ import { provideScopedWorkflowStores } from "@/composables/workflowStores";
import { hide_modal } from "@/layout/modal";
import { getAppRoot } from "@/onload/loadConfig";
import { LastQueue } from "@/utils/promise-queue";
import { withPrefix } from "@/utils/redirect";
import { defaultPosition } from "./composables/useDefaultStepPosition";
import { fromSimple, toSimple } from "./modules/model";
Expand Down Expand Up @@ -219,7 +218,7 @@ export default {
},
initialVersion: {
type: Number,
default: 0,
default: undefined,
},
workflowTags: {
type: Array,
Expand Down Expand Up @@ -350,7 +349,7 @@ export default {
},
watch: {
id(newId, oldId) {
if (oldId && !this.isNewTempWorkflow) {
if (oldId) {
this._loadCurrent(newId);
}
},
Expand All @@ -370,9 +369,7 @@ export default {
},
created() {
this.lastQueue = new LastQueue();
if (!this.isNewTempWorkflow) {
this._loadCurrent(this.id, this.version);
}
this._loadCurrent(this.id, this.version);
hide_modal();
},
methods: {
Expand Down Expand Up @@ -521,9 +518,9 @@ export default {
onDownload() {
window.location = `${getAppRoot()}api/workflows/${this.id}/download?format=json-download`;
},
doSaveAs() {
const rename_name = this.saveAsName ?? `SavedAs_${this.name}`;
const rename_annotation = this.saveAsAnnotation ?? "";
doSaveAs(create = false) {
const rename_name = this.saveAsName ?? create ? this.name : `SavedAs_${this.name}`;
const rename_annotation = this.saveAsAnnotation ?? create ? this.annotation : "";
// This is an old web controller endpoint that wants form data posted...
const formData = new FormData();
Expand All @@ -537,7 +534,11 @@ export default {
.then((response) => {
this.onWorkflowMessage("Workflow saved as", "success");
this.hideModal();
this.onNavigate(`${getAppRoot()}workflows/edit?id=${response.data}`, true);
if (create) {
window.location = `${getAppRoot()}workflows/edit?id=${response.data}`;
} else {
this.onNavigate(`${getAppRoot()}workflows/edit?id=${response.data}`);
}
})
.catch((response) => {
this.onWorkflowError("Saving workflow failed, please contact an administrator.");
Expand Down Expand Up @@ -566,7 +567,7 @@ export default {
const step = { ...this.steps[nodeId], annotation: newAnnotation };
this.onUpdateStep(step);
},
async onCreate() {
onCreate() {
if (!this.name) {
const response = "Please provide a name for your workflow.";
this.onWorkflowError("Creating workflow failed", response, {
Expand All @@ -577,27 +578,8 @@ export default {
this.onAttributes();
return;
}
const payload = {
workflow_name: this.name,
workflow_annotation: this.annotation || "",
};
try {
const { data } = await axios.put(withPrefix("/workflow/create"), payload);
const { id, message } = data;
this.id = id;
this.onWorkflowMessage("Success", message);
const editUrl = `/workflows/edit?id=${id}`;
this.onNavigate(editUrl);
} catch (e) {
this.onWorkflowError("Creating workflow failed"),
e,
{
Ok: () => {
this.hideModal();
},
};
}
this.hasChanges = false;
this.doSaveAs(true);
},
onSetData(stepId, newData) {
this.lastQueue
Expand Down Expand Up @@ -745,17 +727,19 @@ export default {
this.hasChanges = has_changes;
},
_loadCurrent(id, version) {
this.resetStores();
this.onWorkflowMessage("Loading workflow...", "progress");
this.lastQueue
.enqueue(loadWorkflow, { id, version })
.then((data) => {
fromSimple(id, data);
this._loadEditorData(data);
})
.catch((response) => {
this.onWorkflowError("Loading workflow failed...", response);
});
if (!this.isNewTempWorkflow) {
this.resetStores();
this.onWorkflowMessage("Loading workflow...", "progress");
this.lastQueue
.enqueue(loadWorkflow, { id, version })
.then((data) => {
fromSimple(id, data);
this._loadEditorData(data);
})
.catch((response) => {
this.onWorkflowError("Loading workflow failed...", response);
});
}
},
onTags(tags) {
if (this.tags != tags) {
Expand Down
4 changes: 3 additions & 1 deletion client/src/components/Workflow/Editor/modules/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface Workflow {
report: any;
steps: Steps;
comments: WorkflowComment[];
tags: string[];
}

/**
Expand Down Expand Up @@ -80,12 +81,13 @@ export function toSimple(id: string, workflow: Workflow): Omit<Workflow, "versio
const creator = workflow.creator;
const annotation = workflow.annotation;
const name = workflow.name;
const tags = workflow.tags;

const commentStore = useWorkflowCommentStore(id);
commentStore.resolveCommentsInFrames();
commentStore.resolveStepsInFrames();

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

return { steps, report, license, creator, annotation, name, comments };
return { steps, report, license, creator, annotation, name, comments, tags };
}
6 changes: 1 addition & 5 deletions client/src/components/Workflow/Editor/modules/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ 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,
tags: workflow.tags,
};
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;
Expand Down
10 changes: 10 additions & 0 deletions lib/galaxy/managers/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,16 @@ def update_workflow_from_raw_description(
stored_workflow.latest_workflow = workflow
workflow.stored_workflow = stored_workflow

data = raw_workflow_description.as_dict
if isinstance(data, str):
data = json.loads(data)
if "tags" in data:
trans.tag_handler.set_tags_from_list(
trans.user,
stored_workflow,
data.get("tags", []),
)

if workflow_update_options.update_stored_workflow_attributes:
update_dict = raw_workflow_description.as_dict
if "name" in update_dict:
Expand Down

0 comments on commit b00a94c

Please sign in to comment.