Skip to content

Commit 7618afc

Browse files
committed
Handled empty job list for a workflow
1 parent 0ffc3c2 commit 7618afc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/routes/projects/[projectId]/workflows/[workflowId]/jobs/+page.server.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { removeDuplicatedItems } from '$lib/common/component_utilities';
2-
import { getProject } from '$lib/server/api/v1/project_api';
2+
import { getProject, getWorkflow } from '$lib/server/api/v1/project_api';
33
import { getWorkflowJobs } from '$lib/server/api/v1/workflow_api';
44

55
export async function load({ fetch, params }) {
@@ -16,6 +16,13 @@ export async function load({ fetch, params }) {
1616
jobs.filter((j) => j.workflow_dump).map((j) => j.workflow_dump)
1717
)
1818
);
19+
let workflow;
20+
if (workflows.length > 0) {
21+
workflow = workflows[0];
22+
} else {
23+
workflow = await getWorkflow(fetch, projectId, workflowId);
24+
}
25+
1926
const inputDatasets = removeDuplicatedItems(
2027
/** @type {{id: number, name: string}[]} */
2128
(jobs.filter((j) => j.input_dataset_dump).map((j) => j.input_dataset_dump))
@@ -28,7 +35,7 @@ export async function load({ fetch, params }) {
2835
return {
2936
project: project,
3037
projects: [project],
31-
workflow: workflows[0],
38+
workflow,
3239
workflows,
3340
inputDatasets,
3441
outputDatasets,

0 commit comments

Comments
 (0)