@@ -5,6 +5,7 @@ import { BAlert, BButton, BButtonGroup, BCard, BFormCheckbox, BOverlay } from "b
55import { storeToRefs } from " pinia" ;
66import { computed , ref , watch } from " vue" ;
77
8+ import type { WorkflowInvocationRequestInputs } from " @/api/invocations" ;
89import { isWorkflowInput } from " @/components/Workflow/constants" ;
910import { useConfig } from " @/composables/config" ;
1011import { useMarkdown } from " @/composables/markdown" ;
@@ -29,13 +30,15 @@ interface Props {
2930 targetHistory? : string ;
3031 useJobCache? : boolean ;
3132 canMutateCurrentHistory: boolean ;
32- requestState? : Record <string , any >;
33+ requestState? : WorkflowInvocationRequestInputs ;
34+ appendStepLabelsForRequest? : boolean ;
3335}
3436
3537const props = withDefaults (defineProps <Props >(), {
3638 targetHistory: " current" ,
3739 useJobCache: false ,
3840 requestState: undefined ,
41+ appendStepLabelsForRequest: true ,
3942});
4043
4144const emit = defineEmits <{
@@ -107,6 +110,12 @@ const formInputs = computed(() => {
107110 if (isWorkflowInput (step .step_type )) {
108111 const stepName = new String (step .step_index ) as any ;
109112 const stepLabel = step .step_label || new String (step .step_index + 1 );
113+
114+ // For the `WorkflowInvocationRequestModel`, (used in `WorkflowRerun`) if there is no step_label, it does not have
115+ // `step.step_index + 1` as a label, and has `step.step_index` instead.
116+ const requestStateIndex =
117+ ! props .appendStepLabelsForRequest && ! step .step_label ? new String (step .step_index ) : stepLabel ;
118+
110119 const stepType = step .step_type ;
111120 const help = step .annotation ;
112121 const longFormInput = step .inputs [0 ];
@@ -115,9 +124,17 @@ const formInputs = computed(() => {
115124 help: help ,
116125 label: stepLabel ,
117126 });
118- if (props .requestState && props .requestState [stepLabel ]) {
119- const value = props .requestState [stepLabel ];
120- stepAsInput .value = value ;
127+ if (props .requestState && props .requestState [requestStateIndex ]) {
128+ const value = props .requestState [requestStateIndex ];
129+ // TODO: Will this break workflow landings? Done for `WorkflowRereun` since
130+ // `WorkflowInvocationRequestModel` does not provide an object with `values` property.
131+ if (stepType === " data_input" || stepType === " data_collection_input" ) {
132+ stepAsInput .value = {
133+ values: ! Array .isArray (value ) ? [value ] : value ,
134+ };
135+ } else {
136+ stepAsInput .value = value ;
137+ }
121138 }
122139 // disable collection mapping...
123140 stepAsInput .flavor = " module" ;
0 commit comments