Skip to content

Commit 574988d

Browse files
only fetch invocations for job (to get ID) if ID is not provided as prop
This prevents us fetching `/api/invocations?job_id` needlessly, when we already have the invocation ID in the parent components.
1 parent cb2ab2b commit 574988d

5 files changed

Lines changed: 26 additions & 19 deletions

File tree

client/src/components/JobInformation/JobDetails.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import JobParameters from "components/JobParameters/JobParameters.vue";
1212
const props = defineProps<{
1313
job?: JobBaseModel;
1414
jobId?: string;
15+
invocationId?: string;
1516
}>();
1617
1718
const id = computed(() => props.job?.id || props.jobId);
@@ -25,7 +26,7 @@ const remoteHost = computed(() => (props.job && "remote_host" in props.job ? (pr
2526

2627
<template>
2728
<div v-if="id">
28-
<JobInformation :job-id="id" :include-times="true">
29+
<JobInformation :job-id="id" :include-times="true" :invocation-id="invocationId">
2930
<!-- only needed for admin job component -->
3031
<tr v-if="traceback">
3132
<td>Traceback</td>

client/src/components/JobInformation/JobInformation.vue

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ import CopyToClipboard from "@/components/CopyToClipboard.vue";
1616
import HelpText from "@/components/Help/HelpText.vue";
1717
import UtcDate from "@/components/UtcDate.vue";
1818
19-
const job = ref<ShowFullJobResponse | null>(null);
20-
const invocationId = ref<string | null | undefined>(undefined);
21-
2219
const props = defineProps<{
2320
jobId: string;
21+
/** If `true`, the job's update and create times, as well as time to finish are shown. */
2422
includeTimes?: boolean;
23+
/** If provided, this component will skip fetching the invocation ID for the job. */
24+
invocationId?: string;
2525
}>();
2626
27+
const job = ref<ShowFullJobResponse | null>(null);
28+
const fetchedInvocationId = ref<string | null | undefined>(props.invocationId);
29+
2730
const stdout_length = ref(50000);
2831
const stdout_text = ref("");
2932
const stderr_length = ref(50000);
@@ -42,7 +45,7 @@ function jobStateIsRunning(jobState: string) {
4245
4346
const jobIsTerminal = computed(() => (job.value?.state ? jobStateIsTerminal(job.value?.state) : false));
4447
const jobIsRunning = computed(() => (job.value?.state ? jobStateIsRunning(job.value.state) : false));
45-
const routeToInvocation = computed(() => `/workflows/invocations/${invocationId.value}`);
48+
const routeToInvocation = computed(() => `/workflows/invocations/${fetchedInvocationId.value}`);
4649
4750
// Curious as to why we're trying to access tool_version and traceback like this, when they don't exist on
4851
// `ShowFullJobResponse`? Possibly historical reasons or maybe the `JobProvider` can return different types (doesn't seem like it)?
@@ -113,12 +116,15 @@ async function fetchInvocationForJob(jobId: string) {
113116
watch(
114117
() => props.jobId,
115118
async (newId, oldId) => {
116-
if (newId && (invocationId.value === undefined || newId !== oldId)) {
119+
if (
120+
newId &&
121+
(fetchedInvocationId.value === undefined || (fetchedInvocationId.value === null && newId !== oldId))
122+
) {
117123
const invocation = await fetchInvocationForJob(newId);
118124
if (invocation) {
119-
invocationId.value = invocation.id;
125+
fetchedInvocationId.value = invocation.id;
120126
} else {
121-
invocationId.value = null;
127+
fetchedInvocationId.value = null;
122128
}
123129
}
124130
},
@@ -245,10 +251,10 @@ watch(
245251
{{ job.copied_from_job_id }} <DecodedId :id="job.copied_from_job_id" />
246252
</td>
247253
</tr>
248-
<tr v-if="invocationId">
254+
<tr v-if="fetchedInvocationId">
249255
<td>Workflow Invocation</td>
250256
<td>
251-
<router-link :to="routeToInvocation">{{ invocationId }}</router-link>
257+
<router-link :to="routeToInvocation">{{ fetchedInvocationId }}</router-link>
252258
</td>
253259
</tr>
254260
</tbody>

client/src/components/WorkflowInvocationState/JobStep.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@ import JobStepJobs from "./JobStepJobs.vue";
1212
1313
const PER_PAGE = 10;
1414
15-
interface Props {
15+
const props = defineProps<{
1616
jobs: JobBaseModel[];
17-
}
18-
19-
const props = withDefaults(defineProps<Props>(), {
20-
jobs: () => [],
21-
});
17+
invocationId: string;
18+
}>();
2219
2320
const firstJob = computed(() => props.jobs[0]);
2421
const jobCount = computed(() => props.jobs.length);
@@ -75,7 +72,7 @@ watch(
7572
<template>
7673
<BAlert v-if="!jobCount" variant="info" show> No jobs found for this step. </BAlert>
7774
<div v-else-if="jobCount === 1 && firstJob">
78-
<JobDetailsDisplayed :job-id="firstJob.id" />
75+
<JobDetailsDisplayed :job-id="firstJob.id" :invocation-id="props.invocationId" />
7976
</div>
8077
<div v-else>
8178
<div class="mb-2 p-2 d-flex justify-content-between align-items-center flex-wrap">
@@ -107,6 +104,7 @@ watch(
107104
<JobStepJobs
108105
v-else
109106
:jobs="currentStateJobs"
107+
:invocation-id="props.invocationId"
110108
:current-page.sync="currentPage"
111109
:sort-desc.sync="sortDesc"
112110
:per-page="PER_PAGE" />

client/src/components/WorkflowInvocationState/JobStepJobs.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import UtcDate from "../UtcDate.vue";
1818
1919
const props = defineProps<{
2020
jobs: JobBaseModel[];
21+
invocationId: string;
2122
currentPage: number;
2223
sortDesc: boolean;
2324
perPage: number;
@@ -187,7 +188,7 @@ watch(
187188
</div>
188189
</div>
189190
</template>
190-
<JobDetails v-if="viewedJob" :job-id="viewedJob.id" />
191+
<JobDetails v-if="viewedJob" :job-id="viewedJob.id" :invocation-id="invocationId" />
191192
</GModal>
192193
</div>
193194
</template>

client/src/components/WorkflowInvocationState/WorkflowInvocationStep.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ onUnmounted(() => {
254254
<JobStep
255255
v-if="stepDetails.jobs?.length"
256256
class="mt-1"
257-
:jobs="stepDetails.jobs" />
257+
:jobs="stepDetails.jobs"
258+
:invocation-id="props.invocation.id" />
258259
<BAlert v-else v-localize variant="info" show>This step has no jobs</BAlert>
259260
</div>
260261
</BTab>

0 commit comments

Comments
 (0)