diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/DisplayPartOfCommunities.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/DisplayPartOfCommunities.js new file mode 100644 index 000000000..68ce4b35a --- /dev/null +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/DisplayPartOfCommunities.js @@ -0,0 +1,43 @@ +// This file is part of InvenioRDM +// Copyright (C) 2024 CERN. +// +// Invenio App RDM is free software; you can redistribute it and/or modify it +// under the terms of the MIT License; see LICENSE file for more details. + +import React from "react"; +import PropTypes from "prop-types"; +import { i18next } from "@translations/invenio_app_rdm/i18next"; + +export const DisplayPartOfCommunities = ({ communities }) => { + const PartOfCommunities = () => { + const communitiesEntries = communities.entries; + if (communitiesEntries) { + return ( + <> + {i18next.t("Part of ")} + {communitiesEntries.map((community, index) => { + if (!(community.id === communities?.default && community?.theme)) { + return ( + <> + + {community.metadata?.title} + + {index !== communitiesEntries.length - 1 && ", "} + > + ); + } + })} + > + ); + } + }; + return ( +
+ {PartOfCommunities()} +
+ ); +}; + +DisplayPartOfCommunities.propTypes = { + communities: PropTypes.object.isRequired, +}; diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/DisplayVerifiedCommunity.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/DisplayVerifiedCommunity.js new file mode 100644 index 000000000..eebb6f016 --- /dev/null +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/DisplayVerifiedCommunity.js @@ -0,0 +1,53 @@ +// This file is part of InvenioRDM +// Copyright (C) 2024 CERN. +// +// Invenio App RDM is free software; you can redistribute it and/or modify it +// under the terms of the MIT License; see LICENSE file for more details. + +import React from "react"; +import PropTypes from "prop-types"; +import { Label, Image } from "semantic-ui-react"; + +export const DisplayVerifiedCommunity = ({ communities }) => { + const filterBrandedCommunity = (parentCommunities) => { + const brandedCommunityId = parentCommunities?.default; + const communities = parentCommunities?.entries; + let displayCommunity = null; + + if (communities) { + communities.map((community) => { + if (community.id === brandedCommunityId && community?.theme) { + displayCommunity = community; + } + return displayCommunity; + }); + } + + return displayCommunity; + }; + + const verifiedCommunity = filterBrandedCommunity(communities); + return ( + <> + {verifiedCommunity && ( + + )} + > + ); +}; + +DisplayVerifiedCommunity.propTypes = { + communities: PropTypes.object.isRequired, +}; diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/RecordsResultsListItem.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/RecordsResultsListItem.js index c7c0be50b..1498408d0 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/RecordsResultsListItem.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/RecordsResultsListItem.js @@ -14,6 +14,8 @@ import PropTypes from "prop-types"; import { Item, Label, Icon } from "semantic-ui-react"; import { buildUID } from "react-searchkit"; import { CompactStats } from "./CompactStats"; +import { DisplayVerifiedCommunity } from "./DisplayVerifiedCommunity"; +import { DisplayPartOfCommunities } from "./DisplayPartOfCommunities"; class RecordsResultsListItem extends Component { render() { @@ -117,6 +119,7 @@ class RecordsResultsListItem extends Component {{createdDate && ( <> @@ -154,6 +157,7 @@ class RecordsResultsListItem extends Component { />