import type { ReactView } from "@ethicdevs/react-monolith";
import React from "react";
import type { Organization, Repository } from "@prisma/client";
import type { CommonProps, RepositoryLog } from "../../types";
import { Card, Layout, PageWrapper } from "../../components";
import RepositoryCommitSummaryLine from "../../islands/RepositoryCommitSummaryLine";
export interface RepositoryCommitsLogViewProps extends CommonProps {
currentRef: string;
history: RepositoryLog[];
parentOrg: Organization;
repo: Repository;
}
const RepositoryCommitsLogView: ReactView<RepositoryCommitsLogViewProps> = ({
commonProps,
currentRef,
history,
parentOrg,
repo,
}) => {
return (
<Layout {...commonProps}>
<PageWrapper>
<h1>
<a href={`/${parentOrg.slug}`}>
{parentOrg.displayName || parentOrg.slug}
</a>
{" / "}
<a href={`/${parentOrg.slug}/${repo.slug}`}>
{repo.displayName || repo.slug}
</a>
{`/ ${currentRef} / Commits`}
</h1>
<Card
style={{ width: "100%", marginTop: 32 }}
themeScheme={commonProps.themeScheme}
>
{history.map((commit, idx) => (
<Card
key={commit.commit}
data-islandid={`${RepositoryCommitSummaryLine.name}$$${idx}`}
style={{
width: "100%",
marginTop: idx >= 1 ? 4 : 32,
padding: 8,
}}
themeScheme={commonProps.themeScheme}
>
<RepositoryCommitSummaryLine
commit={commit}
currentRef={currentRef}
orgSlug={parentOrg.slug}
repoSlug={repo.slug}
/>
</Card>
))}
</Card>
</PageWrapper>
</Layout>
);
};
RepositoryCommitsLogView.displayName = "RepositoryCommitsLogView";
export default RepositoryCommitsLogView;