forked from inveniosoftware/invenio-app-rdm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
search, my dashboard: highlight verified community
* Add "Part of" to the global search and user dashboard * closes zenodo/zenodo-rdm#716
- Loading branch information
1 parent
a41b8cc
commit 426e2d2
Showing
6 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...pp_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/DisplayPartOfCommunities.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<> | ||
<a href={`/communities/${community.slug}`}> | ||
{community.metadata?.title} | ||
</a> | ||
{index !== communitiesEntries.length - 1 && ", "} | ||
</> | ||
); | ||
} | ||
})} | ||
</> | ||
); | ||
} | ||
}; | ||
return ( | ||
<p> | ||
<b>{PartOfCommunities()}</b> | ||
</p> | ||
); | ||
}; | ||
|
||
DisplayPartOfCommunities.propTypes = { | ||
communities: PropTypes.object.isRequired, | ||
}; |
53 changes: 53 additions & 0 deletions
53
...pp_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/DisplayVerifiedCommunity.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 && ( | ||
<Label | ||
as="a" | ||
href={`/communities/${verifiedCommunity.id}`} | ||
style={{ backgroundColor: verifiedCommunity?.theme?.style?.primaryColor }} | ||
className="themed-community-label" | ||
> | ||
{verifiedCommunity.metadata.title} | ||
<Image | ||
className="themed-community-logo right-floated" | ||
src={`/api/communities/${verifiedCommunity.id}/logo`} | ||
alt="" | ||
/> | ||
</Label> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
DisplayVerifiedCommunity.propTypes = { | ||
communities: PropTypes.object.isRequired, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters