Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into medhavi
Browse files Browse the repository at this point in the history
  • Loading branch information
Med16-11 committed Aug 22, 2023
2 parents 9612121 + f13de77 commit 38aa1f9
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 23 deletions.
1 change: 1 addition & 0 deletions public/_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* /index.html 200
6 changes: 5 additions & 1 deletion src/components/Link/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import MuiLink from "@mui/material/Link";

export default function Link(props) {
return (
<MuiLink href={props.to} target="_blank">
<MuiLink
href={props.to}
target="_blank"
sx={props.sx}
>
{props.children}
</MuiLink>
);
Expand Down
3 changes: 1 addition & 2 deletions src/lib/paddles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import type { UseQueryResult } from "@tanstack/react-query";
import type { GetURLParams, Run, Job } from "./paddles.d";

const PADDLES_SERVER =
import.meta.env.REACT_APP_PADDLES_SERVER ||
"https://paddles.front.sepia.ceph.com";
import.meta.env.VITE_PADDLES_SERVER || "https://paddles.front.sepia.ceph.com";

function getURL(endpoint: string, params?: GetURLParams) {
// Because paddles' API is clunky, we have to do extra work. If it were
Expand Down
19 changes: 16 additions & 3 deletions src/pages/Job/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import PlayCircleOutlineIcon from "@mui/icons-material/PlayCircleOutline";
import CheckCircleOutlineIcon from "@mui/icons-material/CheckCircleOutline";
import HighlightOffIcon from "@mui/icons-material/HighlightOff";
import formatDuration from "date-fns/formatDuration";
import { isValid, parse } from "date-fns";
import Editor from "react-simple-code-editor";
import { highlight, languages } from "prismjs/components/prism-core";
import "prismjs/components/prism-yaml";
Expand Down Expand Up @@ -43,6 +44,11 @@ function StatusIcon({ status }) {
}

function timeSince(date) {
const parsedDate = parse(date, "yyyy-MM-dd HH:mm:ss", new Date());
if (!isValid(parsedDate)) {
return 'N/A';
}

let minute = 60;
let hour = minute * 60;
let day = hour * 24;
Expand Down Expand Up @@ -93,9 +99,16 @@ function JobHeader({ query }) {
<Grid item xs={4}>
<Typography>
Nodes:&nbsp;
{Object.keys(query.data.targets || []).map((item) => {
return <Link to={`/nodes/${item}`}>{item.split(".")[0]}</Link>;
})}
{Object.keys(query.data.targets || []).map((item) => (
<span key={item}>
<Link
to={`/nodes/${item}`}
>
{item.split(".")[0]}
</Link>
&nbsp;
</span>
))}
</Typography>
<Typography>
OS: {query.data.os_type} {query.data.os_version}
Expand Down
39 changes: 22 additions & 17 deletions src/pages/Run/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { PropsWithChildren } from 'react'
import { useQueryParams, StringParam, NumberParam } from "use-query-params";
import { styled, useTheme } from "@mui/material/styles";
import { styled } from "@mui/material/styles";
import { useParams } from "react-router-dom";
import Typography from "@mui/material/Typography";
import Button from "@mui/material/Button";
import ButtonGroup from "@mui/material/ButtonGroup";
import { format } from "date-fns";
import SourceBranch from "mdi-material-ui/SourceBranch";
import { Helmet } from "react-helmet";

import type { Run, RunParams } from "../../lib/paddles.d";
Expand All @@ -28,8 +28,17 @@ const Root = styled("div")(() => ({
},
}));

type FilterLinkProps = {
to: string
}

const FilterLink = (props: PropsWithChildren<FilterLinkProps>) => (
<Link sx={{mx: 0.33}} to={props.to}>
{props.children}
</Link>
);

export default function Run() {
const theme = useTheme();
const [params, setParams] = useQueryParams({
status: StringParam,
page: NumberParam,
Expand All @@ -55,20 +64,16 @@ export default function Run() {
{name}
</Typography>
<div style={{ margin: "20px 0px" }}>
<Typography>See similar runs:</Typography>
<Link to={`/runs/?suite=${suite}&branch=${branch}`}>
<Typography>
suite {suite} and branch {branch}
</Typography>
</Link>
<Link to={`/runs/?branch=${branch}`}>
<Typography>
<SourceBranch style={{ color: theme.palette.text.primary }} />
</Typography>
</Link>
<Link to={`/runs/?date=${date}`}>
<Typography>scheduled on {date}</Typography>
</Link>
See runs with the same:
<FilterLink to={`/runs/?branch=${branch}`}>
branch
</FilterLink>
<FilterLink to={`/runs/?suite=${suite}&branch=${branch}`}>
suite and branch
</FilterLink>
<FilterLink to={`/runs/?date=${date}`}>
date
</FilterLink>
</div>
<ButtonGroup style={{ display: "flex", justifyContent: "center" }}>
<Button
Expand Down

0 comments on commit 38aa1f9

Please sign in to comment.