Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#270 : beaufity links and add identifers link #281

Merged
merged 4 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/src/types/SILL.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export namespace SILL {
export type Sources = "GitLab" | "HAL" | "WikiData" | "SWH" | "Orcid" | "doi" | "GitHub";
export type Sources = "GitLab" | "HAL" | "WikiData" | "SWH" | "Orcid" | "doi" | "GitHub" | "ComptoirDuLibre";

// from https://schema.org/PropertyValue
export type Identification = {
Expand Down
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 {
applicationCategories: string[];
referencePublications?: ApiTypes.SILL.ScholarlyArticle[];
softwareType: ApiTypes.SoftwareType;
identifiers: ApiTypes.SILL.Identification[];
};
}

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: {
programmingLanguages,
keywords,
referencePublications,
applicationCategories
applicationCategories,
identifiers
} = apiSoftware;

const { resolveLocalizedString } = createResolveLocalizedString({
Expand Down Expand Up @@ -338,6 +339,7 @@ function apiSoftwareToSoftware(params: {
keywords,
applicationCategories,
referencePublications,
softwareType
softwareType,
identifiers: identifiers ?? []
};
}
72 changes: 23 additions & 49 deletions web/src/ui/pages/softwareDetails/HeaderDetailCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Popover } from "@mui/material";
import React from "react";
import { AuthorCard } from "ui/shared/AuthorCard";
import config from "../../config-ui.json";
import { LogoURLButton } from "ui/shared/LogoURLButton";

export type Props = {
className?: string;
Expand Down Expand Up @@ -180,7 +181,7 @@ export const HeaderDetailCard = memo((props: Props) => {
handleClose={
handlePopoverClose
}
></AuthorCard>
/>
</Popover>
</>
)}
Expand Down Expand Up @@ -218,58 +219,31 @@ export const HeaderDetailCard = memo((props: Props) => {
</div>
<div className={classes.externalLinkButtons}>
{officialWebsite && (
<a
target="_blank"
rel="noreferrer"
href={officialWebsite}
className={cx(
fr.cx(
"fr-icon-global-line",
"fr-btn",
"fr-btn--secondary",
"fr-btn--icon-left",
"fr-my-2v"
)
)}
>
{t("headerDetailCard.website")}
</a>
<LogoURLButton
iconId={"fr-icon-global-line"}
className={cx(fr.cx("fr-ml-4v", "fr-my-2v"))}
priority="secondary"
url={officialWebsite}
label={t("headerDetailCard.website")}
/>
)}
{documentationWebsite && (
<a
target="_blank"
rel="noreferrer"
href={documentationWebsite}
className={cx(
fr.cx(
"fr-icon-global-line",
"fr-btn",
"fr-btn--secondary",
"fr-btn--icon-left",
"fr-ml-4v",
"fr-my-2v"
)
)}
>
{t("headerDetailCard.documentation")}
</a>
<LogoURLButton
iconId={"fr-icon-book-2-line"}
className={cx(fr.cx("fr-ml-4v", "fr-my-2v"))}
priority="secondary"
url={documentationWebsite}
label={t("headerDetailCard.documentation")}
/>
)}
{sourceCodeRepository && (
<a
target="_blank"
rel="noreferrer"
href={sourceCodeRepository}
className={fr.cx(
"fr-icon-code-s-slash-line",
"fr-btn",
"fr-btn--secondary",
"fr-btn--icon-left",
"fr-ml-4v",
"fr-my-2v"
)}
>
{t("headerDetailCard.repository")}
</a>
<LogoURLButton
iconId={"fr-icon-code-s-slash-line"}
className={cx(fr.cx("fr-ml-4v", "fr-my-2v"))}
priority="secondary"
url={sourceCodeRepository}
label={t("headerDetailCard.repository")}
/>
)}
</div>
</div>
Expand Down
84 changes: 48 additions & 36 deletions web/src/ui/pages/softwareDetails/PreviewTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import { capitalize } from "tsafe/capitalize";
import { CnllServiceProviderModal } from "./CnllServiceProviderModal";
import { assert, type Equals } from "tsafe/assert";
import config from "../../config-ui.json";
import { SoftwareType } from "api/dist/src/lib/ApiTypes";
import { SILL, SoftwareType } from "api/dist/src/lib/ApiTypes";
import { SoftwareTypeTable } from "ui/shared/SoftwareTypeTable";
import { LogoURLButton } from "ui/shared/LogoURLButton";

//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,6 +40,7 @@ export type Props = {
keywords?: string[];
applicationCategories: string[];
softwareType: SoftwareType;
identifiers: SILL.Identification[];
};
export const PreviewTab = (props: Props) => {
const {
Expand All @@ -61,7 +63,8 @@ export const PreviewTab = (props: Props) => {
programmingLanguages,
keywords,
applicationCategories,
softwareType
softwareType,
identifiers
} = props;

const { classes, cx } = useStyles();
Expand Down Expand Up @@ -337,46 +340,55 @@ export const PreviewTab = (props: Props) => {
<SoftwareTypeTable
title="Test"
softwareType={softwareType}
></SoftwareTypeTable>
/>
)}
</p>
)}
</div>
)}

{config.softwareDetails.links.enabled &&
(comptoirDuLibreServiceProvidersUrl !== undefined ||
comptoireDuLibreUrl !== undefined ||
annuaireCnllServiceProviders.length !== 0 ||
wikiDataUrl !== undefined) && (
<div className={classes.section}>
<p className={cx(fr.cx("fr-text--bold"), classes.item)}>
{t("previewTab.use full links")}
</p>
{comptoireDuLibreUrl !== undefined && (
<a
href={comptoireDuLibreUrl}
target="_blank"
rel="noreferrer"
title={t("previewTab.comptoire du libre sheet")}
className={cx(classes.externalLink, classes.item)}
>
{t("previewTab.comptoire du libre sheet")}
</a>
)}
{wikiDataUrl !== undefined && (
<a
href={wikiDataUrl}
target="_blank"
rel="noreferrer"
title={t("previewTab.wikiData sheet")}
className={cx(classes.externalLink, classes.item)}
>
{t("previewTab.wikiData sheet")}
</a>
)}
</div>
)}
{config.softwareDetails.links.enabled && (
<div className={classes.section}>
<p className={cx(fr.cx("fr-text--bold"), classes.item)}>
{t("previewTab.use full links")}
</p>
{(comptoirDuLibreServiceProvidersUrl !== undefined ||
comptoireDuLibreUrl !== undefined ||
annuaireCnllServiceProviders.length !== 0 ||
wikiDataUrl !== undefined) && (
<>
{comptoireDuLibreUrl !== undefined && (
<LogoURLButton
className={cx(classes.externalLink, classes.item)}
priority="secondary"
url={comptoireDuLibreUrl}
label={t("previewTab.comptoire du libre sheet")}
/>
)}
{wikiDataUrl !== undefined && (
<LogoURLButton
className={cx(classes.externalLink, classes.item)}
priority="secondary"
url={wikiDataUrl}
label={t("previewTab.wikiData sheet")}
/>
)}
</>
)}
{identifiers && (
<>
{identifiers.map(identifier => (
<LogoURLButton
className={cx(fr.cx("fr-ml-4v", "fr-my-2v"))}
priority="secondary"
url={identifier.url}
labelFromURL={true}
/>
))}
</>
)}
</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 @@ -152,6 +152,7 @@ export default function SoftwareDetails(props: Props) {
software?.applicationCategories
}
softwareType={software?.softwareType}
identifiers={software.identifiers}
/>
)
},
Expand Down
43 changes: 2 additions & 41 deletions web/src/ui/shared/AuthorCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { tss } from "tss-react";
import { MouseEventHandler } from "react";
import { useTranslation } from "react-i18next";
import Button from "@codegouvfr/react-dsfr/Button";
import { LogoURLButton } from "./LogoURLButton";

export type Props = {
author: ApiTypes.SILL.Person;
Expand Down Expand Up @@ -80,53 +81,13 @@ export function AuthorCard(props: Props) {
);
})}
<div className={classes.externalLinkButtons}>
<Button
linkProps={{
target: "_blank",
rel: "noreferrer",
href: author.url
}}
>
{author?.url?.includes("hal.science") && (
<>
<img
alt="HAL logo"
src="https://hal.science/assets/favicon/apple-touch-icon.png"
height="20px"
></img>
<p className={classes.linkContent}>HAL</p>
</>
)}
{author?.url?.includes("orcid") && (
<>
<img
alt="ORCID logo"
src="https://homepage-prod.orcid.org/assets/iD_icon_1-9cfee7d6c7.png"
height="20px"
></img>
<p className={classes.linkContent}>ORCID</p>
</>
)}
{author?.url?.includes("wikidata") && (
<>
<img
alt="Wikidata logo"
src="https://www.wikidata.org/static/apple-touch/wikidata.png"
height="20px"
></img>
<p className={classes.linkContent}>Wikidata</p>
</>
)}
</Button>
<LogoURLButton url={author.url} labelFromURL={true}></LogoURLButton>
</div>
</Card>
);
}

const useStyles = tss.withName({ AuthorCard }).create({
"linkContent": {
"marginLeft": "7px"
},
"externalLinkButtons": {
"display": "flex",
"alignItems": "center",
Expand Down
Loading