Skip to content

Commit 505ec12

Browse files
add a specific isRerun prop to make these changes specific to reruns
This separates the implementation of setting the `requestState` for workflow landings and workflow reruns. Also adds indication on the workflow execute button on whether a rerun will be done or not.
1 parent f4b0797 commit 505ec12

5 files changed

Lines changed: 45 additions & 22 deletions

File tree

client/src/components/Form/Elements/FormInputMismatchBadge.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const emit = defineEmits(["stop-flagging"]);
1313
<span
1414
v-localize
1515
v-b-tooltip.hover.noninteractive
16-
title="The value of this input does not match the original/expected request">
16+
title="This input has a different value than in the original run">
1717
Changed Input
1818
</span>
1919
<GButton
@@ -22,7 +22,7 @@ const emit = defineEmits(["stop-flagging"]);
2222
size="small"
2323
icon-only
2424
pill
25-
title="Stop flagging inputs that do not match the request"
25+
title="Stop flagging inputs that do not match the original run"
2626
tooltip
2727
@click="emit('stop-flagging')">
2828
<FontAwesomeIcon :icon="faTimes" fixed-width />

client/src/components/Workflow/Run/WorkflowRerun.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ watch(
4242
:workflow-id="requestData.workflow_id"
4343
:instance="requestData.instance"
4444
:request-state="requestData.inputs"
45-
:append-step-labels-for-request="false"
4645
prefer-simple-form
46+
is-rerun
4747
:simple-form-use-job-cache="requestData.use_cached_job" />
4848
</template>

client/src/components/Workflow/Run/WorkflowRun.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ interface Props {
3535
simpleFormUseJobCache?: boolean;
3636
requestState?: WorkflowInvocationRequestInputs;
3737
instance?: boolean;
38-
appendStepLabelsForRequest?: boolean;
38+
isRerun?: boolean;
3939
}
4040
4141
const props = withDefaults(defineProps<Props>(), {
@@ -45,7 +45,7 @@ const props = withDefaults(defineProps<Props>(), {
4545
simpleFormUseJobCache: false,
4646
requestState: undefined,
4747
instance: false,
48-
appendStepLabelsForRequest: true,
48+
isRerun: false,
4949
});
5050
5151
const loading = ref(true);
@@ -251,7 +251,7 @@ defineExpose({
251251
:use-job-cache="simpleFormUseJobCache"
252252
:can-mutate-current-history="canRunOnHistory"
253253
:request-state="requestState"
254-
:append-step-labels-for-request="appendStepLabelsForRequest"
254+
:is-rerun="props.isRerun"
255255
@submissionSuccess="handleInvocations"
256256
@submissionError="handleSubmissionError"
257257
@showAdvanced="showAdvanced" />

client/src/components/Workflow/Run/WorkflowRunFormSimple.vue

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ interface Props {
3838
useJobCache?: boolean;
3939
canMutateCurrentHistory: boolean;
4040
requestState?: WorkflowInvocationRequestInputs;
41-
appendStepLabelsForRequest?: boolean;
41+
isRerun?: boolean;
4242
}
4343
4444
const props = withDefaults(defineProps<Props>(), {
4545
targetHistory: "current",
4646
useJobCache: false,
4747
requestState: undefined,
48-
appendStepLabelsForRequest: true,
48+
isRerun: false,
4949
});
5050
5151
const emit = defineEmits<{
@@ -128,8 +128,7 @@ const formInputs = computed(() => {
128128
129129
// For the `WorkflowInvocationRequestModel`, (used in `WorkflowRerun`) if there is no step_label, it does not have
130130
// `step.step_index + 1` as a label, and has `step.step_index` instead.
131-
const requestStateIndex =
132-
!props.appendStepLabelsForRequest && !step.step_label ? new String(step.step_index) : stepLabel;
131+
const rerunStateIndex = !step.step_label ? new String(step.step_index) : stepLabel;
133132
134133
const stepType = step.step_type;
135134
const help = step.annotation;
@@ -139,18 +138,25 @@ const formInputs = computed(() => {
139138
help: help,
140139
label: stepLabel,
141140
});
142-
if (props.requestState && props.requestState[requestStateIndex]) {
143-
const value = props.requestState[requestStateIndex];
144-
// TODO: Will this break workflow landings? Done for `WorkflowRereun` since
145-
// `WorkflowInvocationRequestModel` does not provide an object with `values` property.
146-
if (stepType === "data_input" || stepType === "data_collection_input") {
147-
stepAsInput.value = {
148-
values: !Array.isArray(value) ? [value] : value,
149-
};
150-
} else {
141+
142+
if (props.requestState) {
143+
if (props.isRerun && props.requestState[rerunStateIndex]) {
144+
const value = props.requestState[rerunStateIndex];
145+
if (stepType === "data_input" || stepType === "data_collection_input") {
146+
// Note: This is different from workflow landings because `WorkflowInvocationRequestModel`
147+
// does not provide an object with `values` property.
148+
stepAsInput.value = {
149+
values: !Array.isArray(value) ? [value] : value,
150+
};
151+
} else {
152+
stepAsInput.value = value;
153+
}
154+
} else if (props.requestState[stepLabel]) {
155+
const value = props.requestState[stepLabel];
151156
stepAsInput.value = value;
152157
}
153158
}
159+
154160
// disable collection mapping...
155161
stepAsInput.flavor = "module";
156162
inputs.push(stepAsInput);
@@ -161,15 +167,15 @@ const formInputs = computed(() => {
161167
});
162168
163169
/**
164-
* Returns the list of steps that do not match the `props.requestState`.
170+
* Returns the list of steps that do not match the workflow rerun `props.requestState`.
165171
*
166172
* TODO: Until form elements are typed better, this is a little shady.
167173
* We do not compare values for the types in the last `else if` statement.
168174
* And for the `select` type, we assume that the values are arrays of strings or numbers.
169175
* @returns {string[]} The list of steps indices that do not match the request state.
170176
*/
171177
const stepsNotMatchingRequest = computed<string[]>(() => {
172-
if (!checkInputMatching.value || !props.requestState) {
178+
if (!props.isRerun || !checkInputMatching.value || !props.requestState) {
173179
return [];
174180
}
175181
@@ -226,6 +232,10 @@ const stepsNotMatchingRequest = computed<string[]>(() => {
226232
return notMatching;
227233
});
228234
235+
const isValidRerun = computed(
236+
() => Boolean(props.isRerun) && checkInputMatching.value && stepsNotMatchingRequest.value.length === 0
237+
);
238+
229239
const hasValidationErrors = computed(() => stepValidation.value !== null);
230240
231241
const canRunOnHistory = computed(() => props.canMutateCurrentHistory || sendToNewHistory.value);
@@ -317,6 +327,7 @@ async function onExecute() {
317327
:workflow-id="model.runData.workflow_id"
318328
:run-disabled="hasValidationErrors || !canRunOnHistory"
319329
:run-waiting="waitingForRequest"
330+
:valid-rerun="isValidRerun"
320331
@on-execute="onExecute">
321332
<template v-slot:workflow-title-actions>
322333
<GButtonGroup>

client/src/components/Workflow/WorkflowNavigationTitle.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ interface Props {
2727
runDisabled?: boolean;
2828
runWaiting?: boolean;
2929
success?: boolean;
30+
validRerun?: boolean;
3031
}
3132
3233
const props = withDefaults(defineProps<Props>(), {
@@ -74,6 +75,16 @@ const workflowImportTitle = computed(() => {
7475
return localize("Import this workflow");
7576
}
7677
});
78+
79+
const executeButtonTooltip = computed(() => {
80+
if (props.runDisabled) {
81+
return localize("Fix the errors in the workflow before running it");
82+
} else if (props.validRerun) {
83+
return localize("Rerun this workflow with the original inputs");
84+
} else {
85+
return localize("Execute this workflow");
86+
}
87+
});
7788
</script>
7889

7990
<template>
@@ -136,7 +147,8 @@ const workflowImportTitle = computed(() => {
136147
:wait="runWaiting"
137148
:disabled="runDisabled"
138149
size="small"
139-
title="Run Workflow"
150+
:tooltip="executeButtonTooltip"
151+
:title="!props.validRerun ? 'Run Workflow' : 'Rerun Workflow'"
140152
@onClick="emit('on-execute')" />
141153
<GButton
142154
v-else

0 commit comments

Comments
 (0)