-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
show archived repo status, start and forks count
- Loading branch information
1 parent
5442ca6
commit 850f552
Showing
6 changed files
with
65 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
// SPDX-FileCopyrightText: 2022 Christian Meeßen (GFZ) <[email protected]> | ||
// SPDX-FileCopyrightText: 2022 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences | ||
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all) (dv4all) | ||
// SPDX-FileCopyrightText: 2024 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2024 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
@@ -14,12 +16,50 @@ import SingleLineChart from '~/components/charts/d3LineChart/SingleLineChart' | |
|
||
export type CommitsChartProps = { | ||
repository_url: string | null, | ||
archived: boolean | null, | ||
star_count: number | null, | ||
fork_count: number | null, | ||
commit_history?: CommitHistory | ||
commit_history_scraped_at?: string | ||
className?: string | ||
} | ||
|
||
export default function CommitsChart({repository_url, commit_history, commit_history_scraped_at, className}: CommitsChartProps) { | ||
function ArchivedRepo({archived}:{archived:boolean|null}){ | ||
if (!archived) return null | ||
return ( | ||
<span><b className="text-warning uppercase">archived repository</b></span> | ||
) | ||
} | ||
|
||
function StarCount({star_count}:{star_count:number|null}){ | ||
if (!star_count) return null | ||
return ( | ||
<span>{star_count===1 ? `${star_count} star`:`${star_count} stars`}</span> | ||
) | ||
} | ||
|
||
function ForkCount({fork_count}:{fork_count:number|null}){ | ||
if (!fork_count) return null | ||
return ( | ||
<span>{fork_count===1 ? `${fork_count} fork` : `${fork_count} forks`}</span> | ||
) | ||
} | ||
|
||
function Commits({commits,lastCommitDate}:{commits:number|null,lastCommitDate?:Date}){ | ||
return ( | ||
<> | ||
<span><b>{commits===1 ? `${commits} commit` : `${commits} commits`}</b></span> | ||
<span>Last commit <b>≈ { | ||
getTimeAgoSince(new Date(), lastCommitDate?.toISOString() ?? null) | ||
}</b></span> | ||
</> | ||
) | ||
} | ||
|
||
export default function CommitsChart({ | ||
repository_url, commit_history, commit_history_scraped_at, | ||
archived, star_count, fork_count, className | ||
}: CommitsChartProps) { | ||
// if there is commit_history | ||
if (commit_history && Object.keys(commit_history).length > 0) { | ||
// format commits data for chart and calculate other stats | ||
|
@@ -28,10 +68,11 @@ export default function CommitsChart({repository_url, commit_history, commit_his | |
return ( | ||
<div className={`flex-1 w-full ${className ?? ''}`}> | ||
<SingleLineChart data={lineData} /> | ||
<div className="software_commitsStat pt-4" id="commitsStat"> | ||
<b>{totalCountY} commits</b> | Last commit <b>≈ { | ||
getTimeAgoSince(new Date(), lastCommitDate?.toISOString() ?? null) | ||
}</b> | ||
<div className="flex pt-4 px-2 [&>*]:border-l [&>*]:border-base-700 [&>*]:px-2 [&>*]:text-center" id="commitsStat"> | ||
<ArchivedRepo archived={archived} /> | ||
<Commits commits={totalCountY} lastCommitDate={lastCommitDate}/> | ||
<StarCount star_count={star_count} /> | ||
<ForkCount fork_count={fork_count} /> | ||
</div> | ||
</div> | ||
) | ||
|
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 |
---|---|---|
|
@@ -2,22 +2,22 @@ | |
// SPDX-FileCopyrightText: 2021 - 2022 dv4all | ||
// SPDX-FileCopyrightText: 2022 Christian Meeßen (GFZ) <[email protected]> | ||
// SPDX-FileCopyrightText: 2022 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences | ||
// SPDX-FileCopyrightText: 2024 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2024 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import LinkIcon from '@mui/icons-material/Link' | ||
import CommitsChart from './CommitsChart' | ||
import {CommitHistory} from '../../types/SoftwareTypes' | ||
import {RepositoryInfo} from '../../types/SoftwareTypes' | ||
|
||
type GetStartedSectionProps = { | ||
get_started_url: string | null, | ||
repository_url: string | null, | ||
commit_history: CommitHistory, | ||
commit_history_scraped_at: string | ||
repositoryInfo: RepositoryInfo | ||
} | ||
|
||
export default function GetStartedSection(props:GetStartedSectionProps) { | ||
const {repository_url, get_started_url, commit_history, commit_history_scraped_at} = props | ||
export default function GetStartedSection({get_started_url,repositoryInfo}:GetStartedSectionProps) { | ||
const {url:repository_url, commit_history, commit_history_scraped_at, archived, star_count,fork_count} = repositoryInfo | ||
|
||
// if no get_started_url and repository_url we do not render this section | ||
if (!get_started_url && !repository_url) return null | ||
|
@@ -48,6 +48,9 @@ export default function GetStartedSection(props:GetStartedSectionProps) { | |
repository_url={repository_url} | ||
commit_history={commit_history} | ||
commit_history_scraped_at={commit_history_scraped_at} | ||
archived={archived} | ||
star_count={star_count} | ||
fork_count={fork_count} | ||
/> | ||
) | ||
} | ||
|
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