-
Notifications
You must be signed in to change notification settings - Fork 137
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
eb8953b
commit 45bdade
Showing
5 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
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 displayCommunity = (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 = displayCommunity(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