Skip to content

Commit 201d749

Browse files
committed
#203 : show partial repo activity
1 parent 60d6757 commit 201d749

File tree

6 files changed

+89
-9
lines changed

6 files changed

+89
-9
lines changed

web/src/core/usecases/softwareDetails/state.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export namespace State {
102102
referencePublications?: ApiTypes.SILL.ScholarlyArticle[];
103103
softwareType: ApiTypes.SoftwareType;
104104
identifiers: ApiTypes.SILL.Identification[];
105+
repoMetadata?: ApiTypes.SILL.RepoMetadata;
105106
};
106107
}
107108

web/src/core/usecases/softwareDetails/thunks.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ function apiSoftwareToSoftware(params: {
196196
keywords,
197197
referencePublications,
198198
applicationCategories,
199-
identifiers
199+
identifiers,
200+
repoMetadata
200201
} = apiSoftware;
201202

202203
const { resolveLocalizedString } = createResolveLocalizedString({
@@ -337,6 +338,7 @@ function apiSoftwareToSoftware(params: {
337338
applicationCategories,
338339
referencePublications,
339340
softwareType,
340-
identifiers: identifiers ?? []
341+
identifiers: identifiers ?? [],
342+
repoMetadata
341343
};
342344
}

web/src/ui/i18n/sill_en.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,11 @@
270270
"softwareType-desktop/mobile": "Software / mobile app",
271271
"softwareType-stack": "Stack",
272272
"softwareType-cloud": "Cloud Hosted App",
273-
"supportedOS": "Supported OS"
273+
"supportedOS": "Supported OS",
274+
"repoMetadata": "Medata From Repository",
275+
"repoLastCommit": "Last Commit",
276+
"repoLastClosedIssuePullRequest": "Last Merged Request",
277+
"repoLastClosedIssue": "Last Close Issue"
274278
},
275279
"referencedInstancesTab": {
276280
"publicInstanceCount": "{{instanceCount}} maintained public $t(referencedInstancesTab.instance, {\"count\": {{instanceCount}} }) by {{organizationCount}} public $t(referencedInstancesTab.organization, {\"count\": {{organizationCount}} })",

web/src/ui/i18n/sill_fr.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,11 @@
273273
"softwareType-desktop/mobile": "Logiciel Ordinateur / Application mobile",
274274
"softwareType-stack": "Stack",
275275
"softwareType-cloud": "Application cloud",
276-
"supportedOS": "Système d'exploitation supporté"
276+
"supportedOS": "Système d'exploitation supporté",
277+
"repoMetadata": "Meta données de la forge logicielle",
278+
"repoLastCommit": "Denier Commit",
279+
"repoLastClosedIssuePullRequest": "Dernier merge",
280+
"repoLastClosedIssue": "Dernière issue fermé"
277281
},
278282
"referencedInstancesTab": {
279283
"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}} }",

web/src/ui/pages/softwareDetails/PreviewTab.tsx

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import { useLang } from "ui/i18n";
22
import { Trans, useTranslation } from "react-i18next";
33
import { fr } from "@codegouvfr/react-dsfr";
44
import { tss } from "tss-react";
5-
import { shortEndMonthDate, monthDate } from "ui/useMoment";
5+
import { shortEndMonthDate, monthDate, useFormattedDate } from "ui/useMoment";
66
import Tooltip from "@mui/material/Tooltip";
77
import { capitalize } from "tsafe/capitalize";
88
import { CnllServiceProviderModal } from "./CnllServiceProviderModal";
99
import { assert, type Equals } from "tsafe/assert";
1010
import config from "../../config-ui.json";
11-
import { SILL, SoftwareType } from "api/dist/src/lib/ApiTypes";
11+
import type { ApiTypes } from "api";
1212
import { SoftwareTypeTable } from "ui/shared/SoftwareTypeTable";
1313
import { LogoURLButton } from "ui/shared/LogoURLButton";
14+
import { Chip } from "@mui/material";
1415

1516
//TODO: Do not use optional props (?) use ( | undefined ) instead
1617
// so we are sure that we don't forget to provide some props
@@ -39,8 +40,9 @@ export type Props = {
3940
programmingLanguages: string[];
4041
keywords?: string[];
4142
applicationCategories: string[];
42-
softwareType: SoftwareType;
43-
identifiers: SILL.Identification[];
43+
softwareType: ApiTypes.SoftwareType;
44+
identifiers: ApiTypes.SILL.Identification[];
45+
repoMetadata?: ApiTypes.SILL.RepoMetadata;
4446
};
4547
export const PreviewTab = (props: Props) => {
4648
const {
@@ -64,14 +66,22 @@ export const PreviewTab = (props: Props) => {
6466
keywords,
6567
applicationCategories,
6668
softwareType,
67-
identifiers
69+
identifiers,
70+
repoMetadata
6871
} = props;
6972

7073
const { classes, cx } = useStyles();
7174

7275
const { t } = useTranslation();
7376
const { lang } = useLang();
7477

78+
const scoreToLabel = (score: number) => {
79+
if (score < 0.1) return "error";
80+
if (score < 0.34) return "warning";
81+
if (score < 0.67) return "info";
82+
return "success";
83+
};
84+
7585
return (
7686
<>
7787
<section className={classes.tabContainer}>
@@ -387,6 +397,64 @@ export const PreviewTab = (props: Props) => {
387397
)}
388398
</div>
389399
)}
400+
{repoMetadata && (
401+
<div className={classes.section}>
402+
<p className={cx(fr.cx("fr-text--bold"), classes.item)}>
403+
{t("previewTab.repoMetadata")}
404+
{repoMetadata?.healthCheck?.score && (
405+
<Chip
406+
label={
407+
(
408+
Math.round(
409+
repoMetadata.healthCheck.score * 10000
410+
) / 100
411+
).toFixed(2) + " %"
412+
}
413+
color={scoreToLabel(repoMetadata.healthCheck.score)}
414+
style={{ marginLeft: "10px" }}
415+
/>
416+
)}
417+
</p>
418+
{repoMetadata?.healthCheck?.lastClosedIssue && (
419+
<p className={cx(fr.cx("fr-text--regular"), classes.item)}>
420+
<span className={classes.labelDetail}>
421+
{t("previewTab.repoLastClosedIssue")} :{" "}
422+
</span>
423+
<span>
424+
{useFormattedDate({
425+
time: repoMetadata.healthCheck.lastClosedIssue
426+
})}
427+
</span>
428+
</p>
429+
)}
430+
{repoMetadata?.healthCheck?.lastClosedIssuePullRequest && (
431+
<p className={cx(fr.cx("fr-text--regular"), classes.item)}>
432+
<span className={classes.labelDetail}>
433+
{t("previewTab.repoLastClosedIssuePullRequest")}{" "}
434+
:{" "}
435+
</span>
436+
<span>
437+
{useFormattedDate({
438+
time: repoMetadata.healthCheck
439+
.lastClosedIssuePullRequest
440+
})}
441+
</span>
442+
</p>
443+
)}
444+
{repoMetadata?.healthCheck?.lastCommit && (
445+
<p className={cx(fr.cx("fr-text--regular"), classes.item)}>
446+
<span className={classes.labelDetail}>
447+
{t("previewTab.repoLastCommit")} :{" "}
448+
</span>
449+
<span>
450+
{useFormattedDate({
451+
time: repoMetadata.healthCheck.lastCommit
452+
})}
453+
</span>
454+
</p>
455+
)}
456+
</div>
457+
)}
390458
</section>
391459
<CnllServiceProviderModal
392460
softwareName={softwareName}

web/src/ui/pages/softwareDetails/SoftwareDetails.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export default function SoftwareDetails(props: Props) {
153153
}
154154
softwareType={software?.softwareType}
155155
identifiers={software.identifiers}
156+
repoMetadata={software.repoMetadata}
156157
/>
157158
)
158159
},

0 commit comments

Comments
 (0)