Skip to content

Commit

Permalink
Cleanup root page
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisJamesC committed Sep 11, 2023
1 parent b2096fd commit e10c7e1
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
30 changes: 20 additions & 10 deletions reports/src/capability/CapabilityTable.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, Breadcrumbs, Typography } from "@mui/material";
import { Capability } from "./capabilityTypes";
import { useMatches } from "react-router-dom";
import { Fragment, ReactNode } from "react";
import { ReactNode } from "react";
import { Report } from "./capabilityTypes";
import { CapabilityTableHeader } from "./CapabilityTableHeader";
import { RequirementTable } from "./RequirementTable";
Expand All @@ -10,6 +10,7 @@ import { ChildCapabilityTable } from "./ChildCapabilityTable";
type CapabilityTableProps = {
capability: Capability;
report: Report;
empty?: boolean;
};

type CrumbHandle = { crumb: () => ReactNode };
Expand All @@ -35,6 +36,7 @@ function CapabilityBreadcrumbs({ capability }: { capability: Capability }) {
export const CapabilityTable = ({
capability,
report,
empty,
}: CapabilityTableProps) => {
if (!capability) {
return <span>Capability not found</span>;
Expand All @@ -54,15 +56,23 @@ export const CapabilityTable = ({
paddingTop: 10,
}}
>
<CapabilityBreadcrumbs capability={capability} />
<Typography variant="h3" gutterBottom sx={{ marginTop: 1 }}>
Requirements
</Typography>
<RequirementTable capability={capability} />
<Typography variant="h3" gutterBottom sx={{ marginTop: 1 }}>
Child capabilities
</Typography>
<ChildCapabilityTable capability={capability} />
{empty ? (
<Typography variant="overline">
Select a participant in the top bar
</Typography>
) : (
<>
<CapabilityBreadcrumbs capability={capability} />
<Typography variant="h3" gutterBottom sx={{ marginTop: 1 }}>
Requirements
</Typography>
<RequirementTable capability={capability} />
<Typography variant="h3" gutterBottom sx={{ marginTop: 1 }}>
Child capabilities
</Typography>
<ChildCapabilityTable capability={capability} />
</>
)}
</Box>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion reports/src/capability/ChildCapabilityTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const ChildCapabilityRow = ({
<TableRow>
<TableCell>
<Link to={path} component={RouterLink}>
{capability.name} ({capability.participant_id})
{capability.name}
</Link>
</TableCell>
<TableCell>
Expand Down
10 changes: 8 additions & 2 deletions reports/src/capability/reportNavigation.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link } from "@mui/material";
import { Link, Typography } from "@mui/material";
import { Link as RouterLink, RouteObject } from "react-router-dom";
import { Capability } from "./capabilityTypes";
import { CapabilityTable } from "./CapabilityTable";
Expand Down Expand Up @@ -47,7 +47,13 @@ export const getNavFromCapability = (
children: [
{
index: true,
element: <CapabilityTable capability={capability} report={report} />,
element: (
<CapabilityTable
capability={capability}
report={report}
empty={path === "/"}
/>
),
},
...children,
],
Expand Down
12 changes: 4 additions & 8 deletions reports/src/capability/useReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { useState, useEffect, useMemo } from "react";
import { ReportsReportTestRunReport } from "../types/TestRunReport";
import { RouteObject } from "react-router-dom";
import { parseReport } from "./reportParser";
import { getNavFromCapability } from "./reportNavigation";
import { getNavFromCapability, getNavFromReport } from "./reportNavigation";
import { parse } from "jsonpath";

const reportUrl = "/report_uspace.json";

Expand All @@ -20,20 +21,15 @@ type UseReportReturn = {
export const useReport = ({
report: _report,
}: UseReportProps): UseReportReturn => {
const [loading, setLoading] = useState<boolean>(true);
const [loading, setLoading] = useState<boolean>(false);
const [error, setError] = useState<string>();
const [report, setReport] = useState<ReportsReportTestRunReport | undefined>(
_report
);

useEffect(() => {
if (_report) {
setReport(_report as ReportsReportTestRunReport);
setLoading(false);
return;
}

const fetchReport = async () => {
setLoading(true);
try {
const res = await fetch(reportUrl);
if (res.status === 404) {
Expand Down

0 comments on commit e10c7e1

Please sign in to comment.