mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-08-31 01:02:04 +08:00
Refresh workflow versions when the editor switches workflows
Both onCreate and the save-as handler clear hasChanges before calling
routeToWorkflow, so the onSave() in there hits its early return and never
reaches the getVersions() call below it. onCreate got a compensating fetch
in b592a0f, but save-as didn't, so saving-as leaves you editing the new
workflow with the previous one's version list still in the dropdown.
id only ever changes in routeToWorkflow, so refreshing there covers both
paths and lets the onCreate copy go away.
This commit is contained in:
@@ -834,6 +834,18 @@ function onAnnotation(nodeId: string, newAnnotation: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Refreshes the version list for the current `id`. `versions` is derived from `id`,
|
||||
* so it has to be refetched whenever the editor switches to a different workflow. */
|
||||
async function refreshVersions() {
|
||||
try {
|
||||
versions.value = await getVersions(id.value);
|
||||
version.value = versions.value[versions.value.length - 1]?.version ?? null;
|
||||
} catch (e) {
|
||||
// A missing version list shouldn't block the user from working on the workflow.
|
||||
console.error("Failed to fetch workflow versions:", e);
|
||||
}
|
||||
}
|
||||
|
||||
async function routeToWorkflow(workflowId: string) {
|
||||
// map scoped stores to existing stores, before updating the id
|
||||
const { addScopePointer } = useScopePointerStore();
|
||||
@@ -841,6 +853,10 @@ async function routeToWorkflow(workflowId: string) {
|
||||
|
||||
id.value = workflowId;
|
||||
|
||||
// Callers clear `hasChanges` before routing, so the `onSave()` below short-circuits
|
||||
// and never refreshes these. Do it here, where the id actually changes.
|
||||
await refreshVersions();
|
||||
|
||||
if (await onSave()) {
|
||||
hasChanges.value = false;
|
||||
router.replace({ query: { id: workflowId } });
|
||||
@@ -889,15 +905,6 @@ async function onCreate(): Promise<boolean> {
|
||||
|
||||
await routeToWorkflow(createdId);
|
||||
|
||||
try {
|
||||
versions.value = await getVersions(id.value);
|
||||
version.value = versions.value[versions.value.length - 1]?.version ?? null;
|
||||
} catch (e) {
|
||||
// If fetching versions fails, we don't want to block the user from using the workflow.
|
||||
// Just log the error and continue.
|
||||
console.error("Failed to fetch versions after creating workflow:", e);
|
||||
}
|
||||
|
||||
Toast.success(message);
|
||||
} catch (e) {
|
||||
onWorkflowError("Creating workflow failed", errorMessageAsString(e, "Please contact an administrator."));
|
||||
|
||||
Reference in New Issue
Block a user