Linked pipeline autoselect
This commit is contained in:
parent
90d9bc3fcc
commit
f17c7e01f5
9 changed files with 312 additions and 40 deletions
|
@ -1,5 +1,6 @@
|
|||
import React, { useState, useContext } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { usePipelineMappings } from "../../Queries.jsx";
|
||||
import StoreContext from "../../ctx/StoreContext.jsx";
|
||||
import JobContext, { jobStatus } from "../../ctx/JobContext.jsx";
|
||||
|
||||
|
@ -32,6 +33,13 @@ import Badge from "@mui/material/Badge";
|
|||
import Stack from "@mui/material/Stack";
|
||||
import Box from "@mui/material/Box";
|
||||
|
||||
import {
|
||||
selectBranch,
|
||||
asTree,
|
||||
asBranches,
|
||||
as1d,
|
||||
} from "../../../lib/jobs/pipelines.js";
|
||||
|
||||
const stopPropagation = (e) => e.stopPropagation() && e.preventDefault();
|
||||
|
||||
export default function FailingBox(props) {
|
||||
|
@ -46,14 +54,15 @@ export default function FailingBox(props) {
|
|||
screenshot: screenshotUrl,
|
||||
recentResults,
|
||||
failedMessage,
|
||||
isCompound,
|
||||
isPipeline,
|
||||
jobStatus: testJobStatus,
|
||||
job,
|
||||
pipeline,
|
||||
} = failingTest;
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { state: jobState, jobFactory } = useContext(JobContext);
|
||||
const { data: pipelineMappings, isLoading } = usePipelineMappings();
|
||||
const { jobFactory } = useContext(JobContext);
|
||||
|
||||
const { state: store, updateStore, removeFailure } = useContext(StoreContext);
|
||||
|
||||
|
@ -77,32 +86,54 @@ export default function FailingBox(props) {
|
|||
return "error";
|
||||
}
|
||||
|
||||
const retryPipelineTest = () => {
|
||||
const primaries = pipelineMappings.filter((m) => m.includes(testName));
|
||||
const builderCache = {
|
||||
branches: asBranches(primaries),
|
||||
tree: asTree(primaries),
|
||||
selectedBranches: as1d(primaries),
|
||||
isTriage: true,
|
||||
};
|
||||
const pipeline = jobFactory(builderCache);
|
||||
if (store.focusJob) navigate(`/qualiteer/jobs#p${pipeline.id}`);
|
||||
};
|
||||
|
||||
const retryTest = () => {
|
||||
if (isPipeline) return retryPipelineTest();
|
||||
const jobId = jobFactory({ testNames: [testName], isTriage: true });
|
||||
if (store.focusJob) navigate(`/qualiteer/jobs#${jobId}`);
|
||||
};
|
||||
|
||||
const navigateToJob = () => {
|
||||
if (pipeline) return navigate(`/qualiteer/jobs#p${pipeline.id}`);
|
||||
navigate(`/qualiteer/jobs#${job.jobId}`);
|
||||
};
|
||||
|
||||
const jobOnClick = () => {
|
||||
if (pipeline) return navigateToJob;
|
||||
if (!job) return retryTest;
|
||||
switch (job.status) {
|
||||
case jobStatus.OK:
|
||||
return null;
|
||||
return navigateToJob;
|
||||
case jobStatus.ERROR:
|
||||
return retryTest;
|
||||
case jobStatus.PENDING:
|
||||
return null;
|
||||
return navigateToJob;
|
||||
case jobStatus.ACTIVE:
|
||||
return null;
|
||||
return navigateToJob;
|
||||
case jobStatus.CANCELED:
|
||||
return retryTest;
|
||||
return navigateToJob;
|
||||
case jobStatus.QUEUED:
|
||||
return null;
|
||||
return navigateToJob;
|
||||
default:
|
||||
return retryTest;
|
||||
}
|
||||
};
|
||||
|
||||
function jobIcon() {
|
||||
if (pipeline && pipeline.isCanceled)
|
||||
return <DoNotDisturbIcon color="warning" />;
|
||||
if (pipeline) return <ViewColumnIcon color="secondary" />;
|
||||
if (!job) return <ReplayIcon />;
|
||||
switch (job.status) {
|
||||
case jobStatus.OK:
|
||||
|
@ -221,7 +252,7 @@ export default function FailingBox(props) {
|
|||
)
|
||||
)}
|
||||
</span>
|
||||
{isCompound && <ViewColumnIcon />}
|
||||
{isPipeline && <ViewColumnIcon />}
|
||||
</div>
|
||||
</Typography>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue