Skip to content

Commit

Permalink
#203 : show partial repo activity
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermau committed Mar 7, 2025
1 parent 6ea0ca1 commit 50068bc
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 9 deletions.
1 change: 1 addition & 0 deletions web/src/core/usecases/softwareDetails/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export namespace State {
referencePublications?: ApiTypes.SILL.ScholarlyArticle[];
softwareType: ApiTypes.SoftwareType;
identifiers: ApiTypes.SILL.Identification[];
repoMetadata?: ApiTypes.SILL.RepoMetadata;
};
}

Expand Down
6 changes: 4 additions & 2 deletions web/src/core/usecases/softwareDetails/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ function apiSoftwareToSoftware(params: {
keywords,
referencePublications,
applicationCategories,
identifiers
identifiers,
repoMetadata
} = apiSoftware;

const { resolveLocalizedString } = createResolveLocalizedString({
Expand Down Expand Up @@ -337,6 +338,7 @@ function apiSoftwareToSoftware(params: {
applicationCategories,
referencePublications,
softwareType,
identifiers: identifiers ?? []
identifiers: identifiers ?? [],
repoMetadata
};
}
6 changes: 5 additions & 1 deletion web/src/ui/i18n/sill_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,11 @@
"softwareType-desktop/mobile": "Software / mobile app",
"softwareType-stack": "Stack",
"softwareType-cloud": "Cloud Hosted App",
"supportedOS": "Supported OS"
"supportedOS": "Supported OS",
"repoMetadata": "Medata From Repository",
"repoLastCommit": "Last Commit",
"repoLastClosedIssuePullRequest": "Last Merged Request",
"repoLastClosedIssue": "Last Close Issue"
},
"referencedInstancesTab": {
"publicInstanceCount": "{{instanceCount}} maintained public $t(referencedInstancesTab.instance, {\"count\": {{instanceCount}} }) by {{organizationCount}} public $t(referencedInstancesTab.organization, {\"count\": {{organizationCount}} })",
Expand Down
6 changes: 5 additions & 1 deletion web/src/ui/i18n/sill_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,11 @@
"softwareType-desktop/mobile": "Logiciel Ordinateur / Application mobile",
"softwareType-stack": "Stack",
"softwareType-cloud": "Application cloud",
"supportedOS": "Système d'exploitation supporté"
"supportedOS": "Système d'exploitation supporté",
"repoMetadata": "Meta données de la forge logicielle",
"repoLastCommit": "Denier Commit",
"repoLastClosedIssuePullRequest": "Dernier merge",
"repoLastClosedIssue": "Dernière issue fermé"
},
"referencedInstancesTab": {
"publicInstanceCount": "{{instanceCount}} $t(referencedInstancesTab.instance, {\"count\": {{instanceCount}} }) web $t(referencedInstancesTab.maintain, {\"count\": {{instanceCount}} }) par {{organizationCount}} $t(referencedInstancesTab.organization, {\"count\": {{organizationCount}} }) $t(referencedInstancesTab.public, {\"count\": {{organizationCount}} }",
Expand Down
78 changes: 73 additions & 5 deletions web/src/ui/pages/softwareDetails/PreviewTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import { useLang } from "ui/i18n";
import { Trans, useTranslation } from "react-i18next";
import { fr } from "@codegouvfr/react-dsfr";
import { tss } from "tss-react";
import { shortEndMonthDate, monthDate } from "ui/useMoment";
import { shortEndMonthDate, monthDate, useFormattedDate } from "ui/useMoment";
import Tooltip from "@mui/material/Tooltip";
import { capitalize } from "tsafe/capitalize";
import { CnllServiceProviderModal } from "./CnllServiceProviderModal";
import { assert, type Equals } from "tsafe/assert";
import config from "../../config-ui.json";
import { SILL, SoftwareType } from "api/dist/src/lib/ApiTypes";
import type { ApiTypes } from "api";
import { SoftwareTypeTable } from "ui/shared/SoftwareTypeTable";
import { LogoURLButton } from "ui/shared/LogoURLButton";
import { Chip } from "@mui/material";

//TODO: Do not use optional props (?) use ( | undefined ) instead
// so we are sure that we don't forget to provide some props
Expand Down Expand Up @@ -39,8 +40,9 @@ export type Props = {
programmingLanguages: string[];
keywords?: string[];
applicationCategories: string[];
softwareType: SoftwareType;
identifiers: SILL.Identification[];
softwareType: ApiTypes.SoftwareType;
identifiers: ApiTypes.SILL.Identification[];
repoMetadata?: ApiTypes.SILL.RepoMetadata;
};
export const PreviewTab = (props: Props) => {
const {
Expand All @@ -64,14 +66,22 @@ export const PreviewTab = (props: Props) => {
keywords,
applicationCategories,
softwareType,
identifiers
identifiers,
repoMetadata
} = props;

const { classes, cx } = useStyles();

const { t } = useTranslation();
const { lang } = useLang();

const scoreToLabel = (score: number) => {
if (score < 0.1) return "error";
if (score < 0.34) return "warning";
if (score < 0.67) return "info";
return "success";
};

return (
<>
<section className={classes.tabContainer}>
Expand Down Expand Up @@ -387,6 +397,64 @@ export const PreviewTab = (props: Props) => {
)}
</div>
)}
{repoMetadata && (
<div className={classes.section}>
<p className={cx(fr.cx("fr-text--bold"), classes.item)}>
{t("previewTab.repoMetadata")}
{repoMetadata?.healthCheck?.score && (
<Chip
label={
(
Math.round(
repoMetadata.healthCheck.score * 10000
) / 100
).toFixed(2) + " %"
}
color={scoreToLabel(repoMetadata.healthCheck.score)}
style={{ marginLeft: "10px" }}
/>
)}
</p>
{repoMetadata?.healthCheck?.lastClosedIssue && (
<p className={cx(fr.cx("fr-text--regular"), classes.item)}>
<span className={classes.labelDetail}>
{t("previewTab.repoLastClosedIssue")} :{" "}
</span>
<span>
{useFormattedDate({
time: repoMetadata.healthCheck.lastClosedIssue
})}
</span>
</p>
)}
{repoMetadata?.healthCheck?.lastClosedIssuePullRequest && (
<p className={cx(fr.cx("fr-text--regular"), classes.item)}>
<span className={classes.labelDetail}>
{t("previewTab.repoLastClosedIssuePullRequest")}{" "}
:{" "}
</span>
<span>
{useFormattedDate({
time: repoMetadata.healthCheck
.lastClosedIssuePullRequest
})}
</span>
</p>
)}
{repoMetadata?.healthCheck?.lastCommit && (
<p className={cx(fr.cx("fr-text--regular"), classes.item)}>
<span className={classes.labelDetail}>
{t("previewTab.repoLastCommit")} :{" "}
</span>
<span>
{useFormattedDate({
time: repoMetadata.healthCheck.lastCommit
})}
</span>
</p>
)}
</div>
)}
</section>
<CnllServiceProviderModal
softwareName={softwareName}
Expand Down
1 change: 1 addition & 0 deletions web/src/ui/pages/softwareDetails/SoftwareDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export default function SoftwareDetails(props: Props) {
}
softwareType={software?.softwareType}
identifiers={software.identifiers}
repoMetadata={software.repoMetadata}
/>
)
},
Expand Down

0 comments on commit 50068bc

Please sign in to comment.