Skip to content

Commit

Permalink
bug: add message to browse page when no subcoms
Browse files Browse the repository at this point in the history
  • Loading branch information
carlinmack committed Sep 30, 2024
1 parent ca315e5 commit 95c9faa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{% set active_community_header_menu_item= 'browse' %}
{% set subcommunities_endpoint = community["links"]["subcommunities"] %}
{% set community_slug = community["slug"] %}
{% set children_allowed = community["children"]["allow"] %}

{%- block javascript %}
{{ super() }}
Expand All @@ -24,9 +25,11 @@
class="ui container communities-frontpage rel-mt-3 rel-mb-2">
<div class="flex">
<h2 class="ui header mb-0 align-self-center">{{ _('Subcommunities') }}</h2>
{% if children_allowed %}
<a class="align-self-center rel-ml-1" href="{{url_for('invenio_communities.communities_subcommunities', pid_value=community_slug)}}">
{{ _('See all')}}
</a>
{% endif %}
</div>
<div class="ui divider hidden"></div>
<div id="subcommunities-container"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,30 @@

import React from "react";
import ReactDOM from "react-dom";
import { i18next } from "@translations/invenio_app_rdm/i18next";
import _get from "lodash/get";

import { CommunitiesCardGroup } from "@js/invenio_communities/community";
import { Message } from "semantic-ui-react";

const subCommunitiesContainer = document.getElementById("subcommunities-container");
const domContainer = document.getElementById("invenio-browse-config");
const apiEndpoint = _get(domContainer.dataset, "apiEndpoint");

if (subCommunitiesContainer) {
ReactDOM.render(
<CommunitiesCardGroup
fetchDataUrl={apiEndpoint}
emptyMessage="There are no child communities."
defaultLogo="/static/images/square-placeholder.png"
/>,
subCommunitiesContainer
);
if (apiEndpoint.length) {
ReactDOM.render(
<CommunitiesCardGroup
fetchDataUrl={apiEndpoint}
emptyMessage={i18next.t("This community has no subcommunities")}
defaultLogo="/static/images/square-placeholder.png"
/>,
subCommunitiesContainer
);
} else {
ReactDOM.render(
<Message icon="info" header={i18next.t("This community has no subcommunities")} />,

Check failure on line 33 in invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/subcommunity/browse.js

View workflow job for this annotation

GitHub Actions / JS / Tests (18.x)

Replace `·icon="info"·header={i18next.t("This·community·has·no·subcommunities")}` with `⏎········icon="info"⏎········header={i18next.t("This·community·has·no·subcommunities")}⏎·····`

Check failure on line 33 in invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/subcommunity/browse.js

View workflow job for this annotation

GitHub Actions / JS / Tests (20.x)

Replace `·icon="info"·header={i18next.t("This·community·has·no·subcommunities")}` with `⏎········icon="info"⏎········header={i18next.t("This·community·has·no·subcommunities")}⏎·····`
subCommunitiesContainer
);
}
}

0 comments on commit 95c9faa

Please sign in to comment.