Skip to content

Commit d6c8a49

Browse files
feat/add issue tracker (#11)
* feat: introduce repository issues * feat: update web-vitals and vite dependencies; refactor reportWebVitals function * feat: add AsyncChip component and refactor PullRequestCard and RepositoryCard imports
1 parent 1a617a5 commit d6c8a49

File tree

7 files changed

+44
-17
lines changed

7 files changed

+44
-17
lines changed

src/components/AsyncChip.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import Chip, { ChipOwnProps } from "@mui/material/Chip";
2+
import CircularProgress from "@mui/material/CircularProgress";
3+
4+
export type AsyncChipProps = {
5+
isLoading: boolean;
6+
loaderColor?:
7+
| "primary"
8+
| "secondary"
9+
| "error"
10+
| "info"
11+
| "success"
12+
| "warning"
13+
| "inherit";
14+
};
15+
16+
export const AsyncChip: React.FC<AsyncChipProps & ChipOwnProps> = ({
17+
isLoading,
18+
loaderColor = "primary",
19+
...props
20+
}) => {
21+
return isLoading ? (
22+
<CircularProgress size={24} color={loaderColor} />
23+
) : (
24+
<Chip {...props} />
25+
);
26+
};
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ import {
99
Box,
1010
Tooltip,
1111
} from "@mui/material";
12-
import { PullRequest } from "../models/PullRequest";
12+
import { PullRequest } from "../../models/PullRequest";
1313
import {
1414
DesignServices,
1515
FileOpen,
1616
GitHub,
1717
Lock,
1818
Visibility,
1919
} from "@mui/icons-material";
20-
import { PullRequestChecks } from "./PullRequestChecks";
21-
import { PullRequestsApprovals } from "./PullRequestsApprovals";
22-
import { PullRequestMergeCheck } from "./PullRequestMergeCheck";
23-
import getContrastColor from "../utils/getContractColor";
24-
import replaceEmoticons from "../utils/replaceEmoticons";
25-
import { getColorForDaysInReview } from "../utils/getColorsForDaysInReview";
20+
import { PullRequestChecks } from "../PullRequestChecks";
21+
import { PullRequestsApprovals } from "../PullRequestsApprovals";
22+
import { PullRequestMergeCheck } from "../PullRequestMergeCheck";
23+
import getContrastColor from "../../utils/getContractColor";
24+
import replaceEmoticons from "../../utils/replaceEmoticons";
25+
import { getColorForDaysInReview } from "../../utils/getColorsForDaysInReview";
2626

2727
interface PullRequestCardProps {
2828
pr: PullRequest;

src/components/Repositories/RepositoryCard.tsx renamed to src/components/Cards/RepositoryCard.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import React from "react";
1818
import { ConfigContext } from "../../context/ConfigContext";
1919
import { useQuery } from "@tanstack/react-query";
2020
import { Link as RouterLink } from "react-router";
21+
import { AsyncChip } from "../AsyncChip";
2122

2223
export type RepositoryCardProps = {
2324
name: string;
@@ -103,26 +104,26 @@ export const RepositoryCard: React.FC<RepositoryCardProps> = ({ name }) => {
103104
<Stack direction="row" justifyContent={"space-between"}>
104105
<Stack direction="row" spacing={1} alignItems={"center"}>
105106
<Typography color="text.secondary">Max Days: </Typography>
106-
<Chip
107+
<AsyncChip
108+
isLoading={loadingPulls}
107109
label={date}
108110
size="small"
109111
sx={{ bgcolor: badgeColor }}
110-
icon={loadingPulls ? <CircularProgress /> : undefined}
111112
/>
112113
<Typography color="text.secondary">PRs: </Typography>
113-
<Chip
114+
<AsyncChip
115+
isLoading={loadingPulls}
114116
label={pulls?.length || 0}
115117
size="small"
116118
color="primary"
117-
icon={loadingPulls ? <CircularProgress /> : undefined}
118119
/>
119120
<Typography color="text.secondary">Issues: </Typography>
120-
<Chip
121+
<AsyncChip
121122
label={issues?.length || 0}
122123
size="small"
123124
color="primary"
124125
sx={{ bgcolor: loadingIssues ? "grey.300" : "" }}
125-
icon={loadingIssues ? <CircularProgress /> : undefined}
126+
isLoading={loadingIssues}
126127
/>
127128
</Stack>
128129
<Stack direction="row" spacing={1} sx={{ alignItems: "center" }}>

src/pages/Dashboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect } from "react";
22
import { ConfigContext } from "../context/ConfigContext";
33
import { PullRequest } from "../models/PullRequest";
4-
import PullRequestCard from "../components/PullRequestCard";
4+
import PullRequestCard from "../components/Cards/PullRequestCard";
55
import {
66
Box,
77
Button,

src/pages/MyPullRequests.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { PullRequest } from "../models/PullRequest";
55
import Box from "@mui/material/Box";
66
import Grid from "@mui/material/Grid2";
77

8-
import PullRequestCard from "../components/PullRequestCard";
8+
import PullRequestCard from "../components/Cards/PullRequestCard";
99
import { Typography } from "@mui/material";
1010

1111
export const MyPullRequests: React.FC = () => {

src/pages/RepositoriesPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Grid from "@mui/material/Grid2";
77

88
// import PullRequestCard from "../components/PullRequestCard";
99
import { Typography } from "@mui/material";
10-
import { RepositoryCard } from "../components/Repositories/RepositoryCard";
10+
import { RepositoryCard } from "../components/Cards/RepositoryCard";
1111

1212
export const RepositoriesPage: React.FC = () => {
1313
const { octokit, repositorySettings, user } = React.useContext(ConfigContext);

src/pages/RepositoryItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useQuery } from "@tanstack/react-query";
22
import React, { useMemo } from "react";
33
import { ConfigContext } from "../context/ConfigContext";
44
import { Link, useParams } from "react-router";
5-
import PullRequestCard from "../components/PullRequestCard";
5+
import PullRequestCard from "../components/Cards/PullRequestCard";
66
import { IssueCard } from "../components/Cards/IssueCard";
77
import { Grid2, Stack, Tab, Tabs, Tooltip, Typography } from "@mui/material";
88
import ArrowBackIcon from "@mui/icons-material/ArrowBack";

0 commit comments

Comments
 (0)