Refactor and more linking
This commit is contained in:
parent
f17c7e01f5
commit
2db11ac3dd
24 changed files with 197 additions and 177 deletions
|
@ -1,13 +1,14 @@
|
|||
import { useEffect, useContext } from "react";
|
||||
import StoreContext from "../../ctx/StoreContext.jsx";
|
||||
import JobContext from "../../ctx/JobContext.jsx";
|
||||
import StoreContext from "@qltr/store";
|
||||
import JobContext from "@qltr/jobs";
|
||||
import CatalogBox from "./CatalogBox.jsx";
|
||||
import CatalogSearch from "./CatalogSearch.jsx";
|
||||
import { useCatalogTests } from "../../Queries.jsx";
|
||||
import { useCatalogTests } from "@qltr/queries";
|
||||
import TextField from "@mui/material/TextField";
|
||||
|
||||
export default function Catalog() {
|
||||
const { state: store, updateStore } = useContext(StoreContext);
|
||||
const { state: jobState } = useContext(JobContext);
|
||||
const { isLoading, data: tests } = useCatalogTests();
|
||||
const handleSearchChange = (e) =>
|
||||
updateStore({ catalogSearch: e.target.value });
|
||||
|
@ -20,6 +21,31 @@ export default function Catalog() {
|
|||
};
|
||||
}, []);
|
||||
|
||||
const catalogWithJobs = () => {
|
||||
for (var test of tests) {
|
||||
if (test.isPipeline) {
|
||||
const pipeline = jobState.pipelines.find((p) =>
|
||||
p.selectedBranches.includes(test.name)
|
||||
);
|
||||
if (!pipeline) continue;
|
||||
const pipelineJob = jobState.jobs.find(
|
||||
(j) =>
|
||||
j.isPipeline &&
|
||||
j.pipelineId === pipeline.id &&
|
||||
j.branchId === test.name
|
||||
);
|
||||
if (!pipelineJob) test.pipeline = pipeline;
|
||||
test.job = pipelineJob;
|
||||
continue;
|
||||
}
|
||||
const job = jobState.jobs.find(
|
||||
(j) => !j.isPipeline && j.builderCache.testNames.includes(test.name)
|
||||
);
|
||||
if (job) test.job = job;
|
||||
}
|
||||
return tests;
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="catalog">
|
||||
<CatalogSearch
|
||||
|
@ -30,7 +56,9 @@ export default function Catalog() {
|
|||
<h6>{store.catalogSearch}</h6>
|
||||
{isLoading
|
||||
? null
|
||||
: tests.map((v, i) => <CatalogBox key={i} catalogTest={v} />)}
|
||||
: catalogWithJobs().map((v, i) => (
|
||||
<CatalogBox key={i} catalogTest={v} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue