diff --git a/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/detail.html b/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/detail.html index a8110f6f1..3c7695aca 100644 --- a/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/detail.html +++ b/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/detail.html @@ -72,7 +72,8 @@ href="{{ url_for('invenio_app_rdm_communities.communities_detail', pid_value=community.slug) }}" class="ui small header"> {{ community.metadata.title }} - {% if community.parent and community.parent.is_verified %} + + {% if community.parent %}

{% endif %} {% if community.parent %} 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 index 1ab671932..f90a16af5 100644 --- 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 @@ -13,9 +13,31 @@ export const DisplayPartOfCommunities = ({ communities }) => { const PartOfCommunities = () => { // FIXME: Uncomment to enable themed banner // const communitiesEntries = communities.entries?.filter((community) => !(community.id === communities?.default && community?.theme)); - const communitiesEntries = communities.entries; + let communitiesEntries = communities.entries; if (communitiesEntries?.length > 0) { + communitiesEntries = communitiesEntries.sort((a, b) => { + // Put parent communities before other communities. + if ( + a.children !== undefined && + b.children !== undefined && + a.children.allow !== b.children.allow + ) { + return a.children.allow ? -1 : 1; + } + // Put subcommunities before regular communities. + if ((a.parent !== undefined) !== (b.parent !== undefined)) { + return a.parent !== undefined ? -1 : 1; + } + // Then sort communities by their title. + const titleCompare = a.metadata?.title.localeCompare(b.metadata?.title); + if (titleCompare !== undefined && titleCompare !== 0) { + return titleCompare; + } + // Finally if all else is equal, sort by slug (which is unique). + return a.slug.localeCompare(b.slug); + }); + return ( <> {i18next.t("Part of ")} @@ -26,7 +48,8 @@ export const DisplayPartOfCommunities = ({ communities }) => { {community.metadata?.title}   - {community.parent?.is_verified && ( + {/* Show the icon for communities allowing children, and for subcommunities */} + {(community.children?.allow || community.parent !== undefined) && ( } content="Verified community" diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/RecordCommunitiesList.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/RecordCommunitiesList.js index 3218326e1..4c539ab0d 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/RecordCommunitiesList.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/RecordCommunitiesList.js @@ -67,7 +67,9 @@ export class RecordCommunitiesList extends Component {
{community.metadata.title} - {community.parent?.is_verified && ( + {/* Show the icon for communities allowing children, and for subcommunities */} + {(community.children?.allow || + community.parent !== undefined) && (