Skip to content

Commit ac778d8

Browse files
use invocation graph composable in steps view, no need for store ref
1 parent 6920b2c commit ac778d8

5 files changed

Lines changed: 34 additions & 41 deletions

File tree

client/src/components/Workflow/Invocation/Graph/InvocationGraph.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,13 @@ const stepCard = ref<BCard | null>(null);
7171
const loadedJobInfo = ref<typeof WorkflowInvocationStep | null>(null);
7272
const workflowGraph = ref<InstanceType<typeof WorkflowGraph> | null>(null);
7373
74-
const invocationRef = computed(() => props.invocation);
75-
7674
const { datatypesMapper } = useDatatypesMapper();
7775
7876
const workflowId = computed(() => props.workflow?.id);
7977
const workflowVersion = computed(() => props.workflow?.version);
8078
8179
const { steps, storeId, loadInvocationGraph, loading } = useInvocationGraph(
82-
invocationRef,
80+
computed(() => props.invocation),
8381
computed(() => props.stepsJobsSummary),
8482
workflowId.value,
8583
workflowVersion.value

client/src/components/Workflow/Invocation/Graph/WorkflowInvocationSteps.vue

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,26 @@
11
<script setup lang="ts">
2-
import { library } from "@fortawesome/fontawesome-svg-core";
32
import { faChevronDown, faChevronUp, faSignInAlt } from "@fortawesome/free-solid-svg-icons";
43
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
54
import { BAlert } from "bootstrap-vue";
6-
import { storeToRefs } from "pinia";
75
import { computed, ref } from "vue";
86
9-
import type { WorkflowInvocationElementView } from "@/api/invocations";
7+
import type { StepJobSummary, WorkflowInvocationElementView } from "@/api/invocations";
108
import { isWorkflowInput } from "@/components/Workflow/constants";
9+
import { useInvocationGraph } from "@/composables/useInvocationGraph";
1110
import { useWorkflowInstance } from "@/composables/useWorkflowInstance";
12-
import { useInvocationStore } from "@/stores/invocationStore";
1311
1412
import LoadingSpan from "@/components/LoadingSpan.vue";
1513
import WorkflowInvocationStep from "@/components/WorkflowInvocationState/WorkflowInvocationStep.vue";
1614
17-
library.add(faChevronDown, faChevronUp, faSignInAlt);
18-
1915
const props = defineProps<{
20-
/** The store id for the invocation graph */
21-
storeId: string;
2216
/** The invocation to display */
2317
invocation: WorkflowInvocationElementView;
2418
/** Whether the steps are being rendered on the dedicated invocation page/route */
2519
isFullPage?: boolean;
20+
/** The job summary for each step in the invocation */
21+
stepsJobsSummary: StepJobSummary[];
2622
}>();
2723
28-
const invocationStore = useInvocationStore();
29-
const { graphStepsByStoreId } = storeToRefs(invocationStore);
30-
const graphSteps = computed(() => graphStepsByStoreId.value[props.storeId]);
31-
3224
const stepsDiv = ref<HTMLDivElement>();
3325
3426
const { workflow, loading, error } = useWorkflowInstance(props.invocation.workflow_id);
@@ -38,11 +30,24 @@ const workflowInputSteps = workflow.value
3830
: [];
3931
const oneOrNoInput = computed(() => workflowInputSteps.length <= 1);
4032
const expandInvocationInputs = ref(oneOrNoInput.value);
33+
34+
const {
35+
steps: graphSteps,
36+
loadInvocationGraph,
37+
loading: graphLoading,
38+
} = useInvocationGraph(
39+
computed(() => props.invocation),
40+
computed(() => props.stepsJobsSummary),
41+
workflow.value?.id,
42+
workflow.value?.version
43+
);
44+
45+
loadInvocationGraph(false);
4146
</script>
4247

4348
<template>
44-
<BAlert v-if="loading" variant="info" show>
45-
<LoadingSpan message="Loading workflow" />
49+
<BAlert v-if="loading || graphLoading" variant="info" show>
50+
<LoadingSpan message="Loading invocation steps" />
4651
</BAlert>
4752
<BAlert v-else-if="error" variant="danger" show>
4853
{{ error }}

client/src/components/WorkflowInvocationState/WorkflowInvocationState.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,6 @@ watch(
201201
{ immediate: true }
202202
);
203203
204-
const storeId = computed(() => (invocation.value ? `invocation-${invocation.value.id}` : undefined));
205-
206204
watch(
207205
() => invocationSchedulingTerminal.value,
208206
async (newVal, oldVal) => {
@@ -412,9 +410,9 @@ async function onCancel() {
412410
<span v-localize>Subworkflow steps are not available.</span>
413411
</BAlert>
414412
<WorkflowInvocationSteps
415-
v-else-if="invocation && storeId"
413+
v-else-if="invocation && stepsJobsSummary"
416414
:invocation="invocation"
417-
:store-id="storeId"
415+
:steps-jobs-summary="stepsJobsSummary"
418416
:is-full-page="props.isFullPage" />
419417
</div>
420418
<WorkflowInvocationInputOutputTabs

client/src/composables/useInvocationGraph.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
faSpinner,
99
faTrash,
1010
} from "@fortawesome/free-solid-svg-icons";
11-
import { storeToRefs } from "pinia";
1211
import { computed, type Ref, ref, set } from "vue";
1312

1413
import { fetchCollectionDetails } from "@/api/datasetCollections";
@@ -18,9 +17,8 @@ import type { StoredWorkflowDetailed } from "@/api/workflows";
1817
import { getContentItemState } from "@/components/History/Content/model/states";
1918
import { isWorkflowInput } from "@/components/Workflow/constants";
2019
import { fromSimple } from "@/components/Workflow/Editor/modules/model";
21-
import { getWorkflowFull } from "@/components/Workflow/workflows.services";
22-
import { useInvocationStore } from "@/stores/invocationStore";
2320
import type { Step } from "@/stores/workflowStepStore";
21+
import { useWorkflowStore } from "@/stores/workflowStore";
2422
import { rethrowSimple } from "@/utils/simple-error";
2523

2624
import { provideScopedWorkflowStores } from "./workflowStores";
@@ -89,20 +87,25 @@ export function useInvocationGraph(
8987
const storeId = computed(() => `invocation-${invocation.value.id}`);
9088

9189
const lastStepsJobsSummary = ref<StepJobSummary[]>([]);
92-
const invocationStore = useInvocationStore();
93-
const { graphStepsByStoreId } = storeToRefs(invocationStore);
9490

95-
/** The full invocation mapped onto the original workflow */
91+
/** The full invocation mapped onto the original workflow.
92+
* _(Needed to map the invocation onto the workflow editor graph.)_
93+
*/
9694
const invocationGraph = ref<InvocationGraph | null>(null);
9795

9896
/** The workflow that was invoked */
9997
const loadedWorkflow = ref<any>(null);
10098

99+
const workflowStore = useWorkflowStore();
100+
101101
const loading = ref(true);
102102

103103
provideScopedWorkflowStores(storeId);
104104

105-
async function loadInvocationGraph() {
105+
/** Load the invocation graph and steps onto the editor canvas.
106+
* @param loadOntoEditor - If set to false, initializes graph steps but does not load them onto the editor.
107+
*/
108+
async function loadInvocationGraph(loadOntoEditor = true) {
106109
loading.value = true;
107110

108111
try {
@@ -115,7 +118,7 @@ export function useInvocationGraph(
115118

116119
// initialize the original full workflow and invocation graph refs (only on the first load)
117120
if (!loadedWorkflow.value) {
118-
loadedWorkflow.value = await getWorkflowFull(workflowId, workflowVersion);
121+
loadedWorkflow.value = await workflowStore.getFullWorkflowCached(workflowId, workflowVersion);
119122
}
120123
if (!invocationGraph.value) {
121124
invocationGraph.value = {
@@ -130,7 +133,7 @@ export function useInvocationGraph(
130133
}
131134

132135
// Load the invocation graph into the editor the first time
133-
if (!stepsPopulated.value) {
136+
if (!stepsPopulated.value && loadOntoEditor) {
134137
invocationGraph.value!.steps = { ...steps.value };
135138
await fromSimple(storeId.value, invocationGraph.value as any);
136139
stepsPopulated.value = true;
@@ -191,10 +194,6 @@ export function useInvocationGraph(
191194
if (!steps.value[i]) {
192195
set(steps.value, i, graphStepFromWfStep);
193196
}
194-
195-
// update the invocation store's graph steps object
196-
// TODO: Find a better way of doing this, instead of using two separate objects...?
197-
set(graphStepsByStoreId.value, storeId.value, steps.value);
198197
}
199198

200199
lastStepsJobsSummary.value = stepsJobsSummary;

client/src/stores/invocationStore.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { defineStore } from "pinia";
2-
import { ref } from "vue";
32

43
import { GalaxyApi } from "@/api";
54
import type {
@@ -10,14 +9,9 @@ import type {
109
WorkflowInvocationRequest,
1110
} from "@/api/invocations";
1211
import { type FetchParams, useKeyedCache } from "@/composables/keyedCache";
13-
import type { GraphStep } from "@/composables/useInvocationGraph";
1412
import { rethrowSimple } from "@/utils/simple-error";
1513

16-
type GraphSteps = { [index: string]: GraphStep };
17-
1814
export const useInvocationStore = defineStore("invocationStore", () => {
19-
const graphStepsByStoreId = ref<{ [index: string]: GraphSteps }>({});
20-
2115
async function fetchInvocationDetails(params: FetchParams): Promise<WorkflowInvocation> {
2216
const { data, error } = await GalaxyApi().GET("/api/invocations/{invocation_id}", {
2317
params: { path: { invocation_id: params.id } },
@@ -136,7 +130,6 @@ export const useInvocationStore = defineStore("invocationStore", () => {
136130
getInvocationStepById,
137131
getInvocationRequestById,
138132
getInvocationCountByWorkflowId,
139-
graphStepsByStoreId,
140133
isLoadingInvocation,
141134
};
142135
});

0 commit comments

Comments
 (0)