Skip to content

Commit

Permalink
#265 : add reference scholar publication tab
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermau committed Jan 17, 2025
1 parent 40f686a commit 55eef34
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 3 deletions.
2 changes: 2 additions & 0 deletions api/src/core/usecases/readWriteSillData/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ScholarlyArticle } from "../../../types/codemeta";
import type {
AuthStructure,
ExternalDataOrigin,
Expand Down Expand Up @@ -66,6 +67,7 @@ export type Software = {
similarSoftwares: Software.SimilarSoftware[];
keywords: string[];
programmingLanguages: string[];
referencePublication?: ScholarlyArticle[];
};

export namespace Software {
Expand Down
1 change: 1 addition & 0 deletions api/src/lib/ApiTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export type { ExternalDataOrigin } from "../core/ports/GetSoftwareExternalData";
export type { SoftwareExternalDataOption } from "../core/ports/GetSoftwareExternalDataOptions";
export type { GetSoftwareExternalDataOptions } from "../core/ports/GetSoftwareExternalDataOptions";
export type { AuthStructure } from "../core/ports/GetSoftwareExternalData";
export type { ScholarlyArticle } from "../types/codemeta";

export type {
Agent,
Expand Down
10 changes: 7 additions & 3 deletions web/src/core/usecases/softwareCatalog/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,8 @@ function apiSoftwareToInternalSoftware(params: {
userAndReferentCountByOrganization,
similarSoftwares,
keywords,
programmingLanguages
programmingLanguages,
referencePublication
} = apiSoftware;

assert<
Expand Down Expand Up @@ -975,7 +976,8 @@ function apiSoftwareToInternalSoftware(params: {
return search;
})(),
userDeclaration,
programmingLanguages
programmingLanguages,
referencePublication
};
}

Expand Down Expand Up @@ -1007,6 +1009,7 @@ function internalSoftwareToExternalSoftware(params: {
softwareType,
userDeclaration,
programmingLanguages,
referencePublication,
...rest
} = internalSoftware;

Expand Down Expand Up @@ -1042,7 +1045,8 @@ function internalSoftwareToExternalSoftware(params: {
},
userDeclaration,
programmingLanguages,
applicationCategories
applicationCategories,
referencePublication
};
}

Expand Down
1 change: 1 addition & 0 deletions web/src/core/usecases/softwareCatalog/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export namespace State {
| undefined;
programmingLanguages: string[];
applicationCategories: string[];
referencePublication?: ApiTypes.ScholarlyArticle[];
};

export type External = Common & {
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 @@ -104,6 +104,7 @@ export namespace State {
programmingLanguages: string[];
keywords: string[];
applicationCategories: string[];
referencePublication?: ApiTypes.ScholarlyArticle[];
softwareType: ApiTypes.SoftwareType;
};
}
Expand Down
2 changes: 2 additions & 0 deletions web/src/core/usecases/softwareDetails/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ function apiSoftwareToSoftware(params: {
serviceProviders,
programmingLanguages,
keywords,
referencePublication,
applicationCategories
} = apiSoftware;

Expand Down Expand Up @@ -336,6 +337,7 @@ function apiSoftwareToSoftware(params: {
programmingLanguages,
keywords,
applicationCategories,
referencePublication,
softwareType
};
}
2 changes: 2 additions & 0 deletions web/src/ui/i18n/sill_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@
},
"softwareDetails": {
"catalog breadcrumb": "Software catalog",
"tabReferencePublication": "Related Scholar Articles",
"tabReferencePublicationTitle": "Scholar Articles",
"tab title overview": "Overview",
"tab title instance": "Referenced instance {{instanceCount}}",
"tab service providers": "Service providers {{serviceProvidersCount}}",
Expand Down
2 changes: 2 additions & 0 deletions web/src/ui/i18n/sill_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@
},
"softwareDetails": {
"catalog breadcrumb": "Le catalogue de logiciels",
"tabReferencePublication": "Articles de recherche associés",
"tabReferencePublicationTitle": "Articles de recherche",
"tab title overview": "Aperçu",
"tab title instance": "Instances référencées {{instanceCount}}",
"tab service providers": "Prestataires de services {{serviceProvidersCount}}",
Expand Down
40 changes: 40 additions & 0 deletions web/src/ui/pages/softwareDetails/PublicationTab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { ScholarlyArticle } from "api/dist/src/types/codemeta";
import { fr } from "@codegouvfr/react-dsfr";
import { useTranslation } from "react-i18next";

export type Props = {
referencePublication?: ScholarlyArticle[];
};

export const PublicationTab = (props: Props) => {
const { referencePublication } = props;

const { t } = useTranslation();

return (
<>
<h6>{t("softwareDetails.tabReferencePublicationTitle")}</h6>
<ul>
{referencePublication?.map(article => {
return (
<li>
<a
href={article.identifier?.url?.toString()}
target="_blank"
rel="noreferrer"
style={{
"marginRight": fr.spacing("2v"),
"color":
fr.colors.decisions.text.actionHigh.blueFrance
.default
}}
>
{article["@id"]}
</a>
</li>
);
})}
</ul>
</>
);
};
17 changes: 17 additions & 0 deletions web/src/ui/pages/softwareDetails/SoftwareDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { PreviewTab } from "ui/pages/softwareDetails/PreviewTab";
import { ReferencedInstancesTab } from "ui/pages/softwareDetails/ReferencedInstancesTab";
import { Tabs } from "@codegouvfr/react-dsfr/Tabs";
import { SimilarSoftwareTab } from "ui/pages/softwareDetails/AlikeSoftwareTab";
import { PublicationTab } from "./PublicationTab";
import { ActionsFooter } from "ui/shared/ActionsFooter";
import { DetailUsersAndReferents } from "ui/shared/DetailUsersAndReferents";
import { Button } from "@codegouvfr/react-dsfr/Button";
Expand Down Expand Up @@ -259,6 +260,22 @@ export default function SoftwareDetails(props: Props) {
/>
)
}
]),
...(software.referencePublication === undefined
? []
: [
{
"label": t(
"softwareDetails.tabReferencePublication"
),
"content": (
<PublicationTab
referencePublication={
software.referencePublication
}
></PublicationTab>
)
}
])
]}
/>
Expand Down

0 comments on commit 55eef34

Please sign in to comment.