-
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.
feat: show archived repo status, start and forks count
- Loading branch information
1 parent
5442ca6
commit 477c9b7
Showing
8 changed files
with
168 additions
and
37 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 |
---|---|---|
|
@@ -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 | ||
|
||
|
@@ -12,14 +14,58 @@ import {prepareDataForSoftwarePage} from '~/components/charts/d3LineChart/format | |
import NoDataAvailableChart from '~/components/charts/d3LineChart/NoDataAvailableChart' | ||
import SingleLineChart from '~/components/charts/d3LineChart/SingleLineChart' | ||
|
||
export type CommitsChartProps = { | ||
export type CommitsChartProps = Readonly<{ | ||
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 function ArchivedRepo({archived}:Readonly<{archived:boolean|null}>){ | ||
if (!archived) return null | ||
return ( | ||
<span data-testid="archived-repository"> | ||
<b className="text-warning uppercase">archived repository</b> | ||
</span> | ||
) | ||
} | ||
|
||
export function StarCount({star_count}:Readonly<{star_count:number|null}>){ | ||
if (star_count===null || star_count===undefined) return null | ||
return ( | ||
<span data-testid="star-count"> | ||
{star_count===1 ? `${star_count} star`:`${star_count} stars`} | ||
</span> | ||
) | ||
} | ||
|
||
export function ForkCount({fork_count}:Readonly<{fork_count:number|null}>){ | ||
if (fork_count===null || fork_count===undefined) return null | ||
return ( | ||
<span data-testid="fork-count"> | ||
{fork_count===1 ? `${fork_count} fork` : `${fork_count} forks`} | ||
</span> | ||
) | ||
} | ||
|
||
export function Commits({commits,lastCommitDate}:Readonly<{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, className}: CommitsChartProps) { | ||
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 +74,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,25 +2,23 @@ | |
// 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) { | ||
// if no get_started_url and repository_url we do not render this section | ||
if (!get_started_url && !repository_url) return null | ||
if (!get_started_url && !repositoryInfo?.url) return null | ||
|
||
function renderGetStartedUrl() { | ||
if (get_started_url) { | ||
|
@@ -45,9 +43,12 @@ export default function GetStartedSection(props:GetStartedSectionProps) { | |
return ( | ||
<CommitsChart | ||
className={classes} | ||
repository_url={repository_url} | ||
commit_history={commit_history} | ||
commit_history_scraped_at={commit_history_scraped_at} | ||
repository_url={repositoryInfo?.url} | ||
commit_history={repositoryInfo?.commit_history} | ||
commit_history_scraped_at={repositoryInfo?.commit_history_scraped_at} | ||
archived={repositoryInfo?.archived} | ||
star_count={repositoryInfo?.star_count} | ||
fork_count={repositoryInfo?.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