Skip to content

Commit

Permalink
Merge pull request #239 from oarepo/stojanovic/fe-262-community-item
Browse files Browse the repository at this point in the history
possible to not show links in community selector:
  • Loading branch information
mirekys authored Oct 22, 2024
2 parents 461b16a + 64a5f6d commit b6a2797
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import Overridable from "react-overridable";
import PropTypes from "prop-types";
import { Image } from "react-invenio-forms";

export const CommunityItem = ({ community, handleClick }) => {
export const CommunityItem = ({ community, handleClick, renderLinks }) => {
const { id, title, website, logo, organizations } = community;
return (
<Overridable
id="record-community-selection-item"
community={community}
handleClick={handleClick}
renderLinks={renderLinks}
>
<List.Item
onClick={() => handleClick(id)}
Expand All @@ -21,16 +22,22 @@ export const CommunityItem = ({ community, handleClick }) => {
</div>
<List.Content>
<Header size="small">
<a
onClick={(e) => e.stopPropagation()}
href={community.links.self_html}
target="_blank"
rel="noopener noreferrer"
>
{title}
</a>
{renderLinks ? (
<a
onClick={(e) => {
e.stopPropagation();
}}
href={community.links.self_html}
target="_blank"
rel="noopener noreferrer"
>
{title}
</a>
) : (
title
)}
</Header>
{website && (
{website && renderLinks && (
<React.Fragment>
<Icon name="linkify" />
<a
Expand Down Expand Up @@ -58,4 +65,9 @@ export const CommunityItem = ({ community, handleClick }) => {
CommunityItem.propTypes = {
community: PropTypes.object.isRequired,
handleClick: PropTypes.func,
renderLinks: PropTypes.bool,
};

CommunityItem.defaultProps = {
renderLinks: true,
};
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const CommunitySelector = ({ fieldPath }) => {
key={c.id}
community={c}
handleClick={handleClick}
renderLinks={false}
/>
))}
</List>
Expand All @@ -97,6 +98,7 @@ export const CommunitySelector = ({ fieldPath }) => {
<CommunityItem
community={generic_community}
handleClick={handleClick}
renderLinks={false}
/>
</List>
</React.Fragment>
Expand Down

0 comments on commit b6a2797

Please sign in to comment.