-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,125 additions
and
583 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import CommitHistory from "./Commits/CommitHistory"; | ||
|
||
export default () => { | ||
return <CommitHistory />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { operations } from "@octokit/openapi-types"; | ||
import { common } from "replugged"; | ||
import { Box, Link, Text } from "@primer/react"; | ||
import { SxProp } from "@primer/react/lib-esm/sx"; | ||
import { useState } from "react"; | ||
import { ChevronDownIcon, ChevronRightIcon } from "@primer/styled-octicons"; | ||
const { parser } = common; | ||
|
||
export default ({ | ||
commit, | ||
sx, | ||
}: { | ||
commit: operations["pulls/list-files"]["responses"]["200"]["content"]["application/json"][0]; | ||
sx?: SxProp["sx"]; | ||
}) => { | ||
const [expanded, setExpanded] = useState(true); | ||
|
||
return ( | ||
<Box | ||
borderStyle="solid" | ||
borderColor="border.default" | ||
borderWidth={1} | ||
borderRadius={2} | ||
{...(sx || {})}> | ||
<Box | ||
px={3} | ||
py={2} | ||
bg="canvas.subtle" | ||
borderTopLeftRadius={2} | ||
borderTopRightRadius={2} | ||
display="flex" | ||
alignItems="center"> | ||
<Link muted sx={{ display: "flex" }} onClick={() => setExpanded(!expanded)}> | ||
{expanded ? <ChevronDownIcon /> : <ChevronRightIcon />} | ||
</Link> | ||
<Text ml={1}>{commit.filename}</Text> | ||
</Box> | ||
{expanded && ( | ||
<Box | ||
borderColor="border.muted" | ||
borderTopWidth={1} | ||
borderStyle="solid" | ||
sx={{ userSelect: "text", code: { bg: "inherit" } }}> | ||
{parser.defaultRules.codeBlock.react( | ||
{ content: commit.patch?.trimEnd(), lang: "patch" }, | ||
// @ts-expect-error better types need butttttttttttttttttt i wont pr :) | ||
null, | ||
{}, | ||
)} | ||
</Box> | ||
)} | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { | ||
Avatar, | ||
Box, | ||
Link, | ||
Pagination, | ||
RelativeTime, | ||
Text, | ||
Timeline, | ||
Truncate, | ||
} from "@primer/react"; | ||
import { CommitIcon } from "@primer/styled-octicons"; | ||
import { useContext, useEffect, useState } from "react"; | ||
import { Context } from "../../context"; | ||
import { useCommits } from "../../paginate"; | ||
import { Issue, TreeWithContent } from "../../utils"; | ||
import Spinner from "../Spinner"; | ||
import CommitsView from "./CommitView"; | ||
|
||
export default ({ pr }: { pr?: NonNullable<Issue["pull"]> }) => { | ||
const { url } = useContext(Context)!.data!; | ||
const commits = pr ? useCommits(url, { pr: pr.number }) : useContext(Context)?.data?.commits; | ||
const [commit, setCommit] = useState<NonNullable<TreeWithContent["latestCommit"]> | null>(null); | ||
|
||
useEffect(() => { | ||
void commits?.fetch(); | ||
}, []); | ||
|
||
if (!commits?.data?.page || !commits?.data?.info) return <Spinner>Fetching commits...</Spinner>; | ||
|
||
if (commit) return <CommitsView commit={commit} onClose={() => setCommit(null)} />; | ||
|
||
const page = commits.data.page[commits.data.info.currentPage - 1]; | ||
|
||
return ( | ||
<Timeline clipSidebar> | ||
{page.map((p) => ( | ||
<Timeline.Item condensed> | ||
<Timeline.Badge> | ||
<CommitIcon /> | ||
</Timeline.Badge> | ||
<Timeline.Body> | ||
<Text> | ||
Commits <RelativeTime datetime={p[0].commit.author?.date} format="datetime" /> | ||
</Text> | ||
<Box | ||
borderStyle="solid" | ||
borderWidth={1} | ||
borderColor="border.default" | ||
borderRadius={2} | ||
mt={3}> | ||
{p.map((c, i) => ( | ||
<Box | ||
borderStyle="solid" | ||
borderTopWidth={i ? 1 : 0} | ||
borderColor="border.muted" | ||
px={3} | ||
py={2}> | ||
<Truncate maxWidth={"100%"} title={`${c.commit.message}`}> | ||
<Text as="p" m={0} mb={1}> | ||
<Link | ||
muted | ||
sx={{ fontWeight: "bold", color: "fg.default" }} | ||
onClick={() => setCommit(c)}> | ||
{c.commit.message.split("\n\n")[0]} | ||
</Link> | ||
</Text> | ||
</Truncate> | ||
<Box> | ||
<Avatar src={c.author?.avatar_url || ""} alt={`${c.author?.login}'s profile`} /> | ||
<Text> | ||
<Text fontWeight="bold" ml={1} color="fg.default"> | ||
{c.author?.login} | ||
</Text>{" "} | ||
committed <RelativeTime datetime={c.commit.author?.date} /> | ||
</Text> | ||
</Box> | ||
</Box> | ||
))} | ||
</Box> | ||
</Timeline.Body> | ||
</Timeline.Item> | ||
))} | ||
{commits.data.info.lastPage && ( | ||
<Pagination | ||
currentPage={commits.data.info.currentPage} | ||
pageCount={commits.data.info.lastPage} | ||
showPages={false} | ||
onPageChange={(_, page) => { | ||
if (page > commits.data.info!.currentPage) void commits.nextPage(); | ||
else void commits.previousPage(); | ||
}} | ||
/> | ||
)} | ||
</Timeline> | ||
); | ||
}; |
Oops, something went wrong.