import type { ReactView } from "@ethicdevs/react-monolith";
import React from "react";
import type { Organization } from "@prisma/client";
import type {
CommonProps,
RepositoryLog,
RepositoryWithForkedFromRepo,
} from "../../types";
import {
Card,
Grid,
IslandWrapper,
Layout,
PageWrapper,
} from "../../components";
import RepositoryCommitSummaryLine from "../../islands/RepositoryCommitSummaryLine";
import RepositoryHero from "../../islands/RepositoryHero";
export interface RepositoryCommitsLogViewProps extends CommonProps {
currentRef: string;
history: RepositoryLog[];
parentOrg: Organization;
repo: RepositoryWithForkedFromRepo;
}
const RepositoryCommitsLogView: ReactView<RepositoryCommitsLogViewProps> = ({
commonProps,
currentRef,
history,
parentOrg,
repo,
}) => {
return (
<Layout
{...commonProps}
showDrawerPrimary
orgSlug={parentOrg.slug}
repoSlug={repo.slug}
currentRef={currentRef}
>
<PageWrapper>
<IslandWrapper data-islandid={`${RepositoryHero.name}$$0`}>
<RepositoryHero
forkedFromRepo={repo.forkedFromRepo}
forksCount={repo.forks.length}
parentOrg={parentOrg}
path={`Commits (${history.length})`}
repo={repo}
/>
</IslandWrapper>
<Grid.Col style={{ width: "100%", marginTop: 0 }}>
{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>
))}
</Grid.Col>
</PageWrapper>
</Layout>
);
};
RepositoryCommitsLogView.displayName = "RepositoryCommitsLogView";
export default RepositoryCommitsLogView;