scopePointerStore always checks for existing scope

This commit is contained in:
Ahmed Awan
2023-11-07 16:55:40 -06:00
parent bbd004d74e
commit 901e3bb01f
2 changed files with 9 additions and 13 deletions
@@ -546,6 +546,12 @@ export default {
const response = await axios.post(`${getAppRoot()}workflow/save_workflow_as`, formData);
const newId = response.data;
if (!create) {
this.name = rename_name;
this.annotation = rename_annotation;
}
this.hasChanges = false;
await this.routeToWorkflow(newId);
} catch (e) {
this.onWorkflowError("Saving workflow failed, please contact an administrator.");
@@ -575,18 +581,9 @@ export default {
this.onUpdateStep(step);
},
async routeToWorkflow(id) {
const { addScopePointer, scope } = useScopePointerStore();
let pointedTo;
// the current workflow id might be pointing to existing stores
const originalPointed = scope(this.id);
if (originalPointed !== this.id) {
pointedTo = originalPointed;
} else {
pointedTo = this.id;
}
// map scoped stores to existing stores, before updating the id
addScopePointer(id, pointedTo);
const { addScopePointer } = useScopePointerStore();
addScopePointer(id, this.id);
this.id = id;
await this.onSave();
@@ -618,7 +615,6 @@ export default {
await this.routeToWorkflow(id);
} else {
// otherwise, use `save_as` endpoint to include steps, etc.
this.hasChanges = false;
await this.doSaveAs(true);
}
} catch (e) {
+1 -1
View File
@@ -11,7 +11,7 @@ export const useScopePointerStore = defineStore("scopePointerStore", () => {
const scopePointers = ref<Record<FromScopeId, ToScopeId | undefined>>({});
function addScopePointer(from: FromScopeId, to: ToScopeId) {
scopePointers.value[from] = to;
scopePointers.value[from] = scope.value(to);
}
const scope = computed(() => (scopeId: string) => scopePointers.value[scopeId] ?? scopeId);