diff --git a/oarepo_communities/config.py b/oarepo_communities/config.py index f598704..e3e3013 100644 --- a/oarepo_communities/config.py +++ b/oarepo_communities/config.py @@ -8,6 +8,7 @@ from .requests.remove_secondary import RemoveSecondaryCommunityRequestType from .requests.submission_secondary import SecondaryCommunitySubmissionRequestType from .resolvers.ui import CommunityRoleUIResolver +from invenio_communities.config import COMMUNITIES_ROUTES as INVENIO_COMMUNITIES_ROUTES REQUESTS_REGISTERED_TYPES = [ InitiateCommunityMigrationRequestType(), @@ -60,3 +61,9 @@ ], } ] + +COMMUNITIES_ROUTES = {**INVENIO_COMMUNITIES_ROUTES, "my_communities": "/me/communities"} + +DISPLAY_USER_COMMUNITIES = True + +DISPLAY_NEW_COMMUNITIES = True diff --git a/oarepo_communities/ext.py b/oarepo_communities/ext.py index 4e62a32..a724e04 100644 --- a/oarepo_communities/ext.py +++ b/oarepo_communities/ext.py @@ -52,6 +52,10 @@ def init_config(self, app): ) if "OAREPO_PERMISSIONS_PRESETS" not in app.config: app.config["OAREPO_PERMISSIONS_PRESETS"] = {} + app.config.setdefault( + "DISPLAY_USER_COMMUNITIES", config.DISPLAY_USER_COMMUNITIES + ) + app.config.setdefault("DISPLAY_NEW_COMMUNITIES", config.DISPLAY_NEW_COMMUNITIES) for k in ext_config.OAREPO_PERMISSIONS_PRESETS: if k not in app.config["OAREPO_PERMISSIONS_PRESETS"]: @@ -59,6 +63,11 @@ def init_config(self, app): ext_config.OAREPO_PERMISSIONS_PRESETS[k] ) + app.config["COMMUNITIES_ROUTES"] = { + **config.COMMUNITIES_ROUTES, + **app.config.get("COMMUNITIES_ROUTES", {}), + } + @cached_property def urlprefix_serviceid_mapping(self): return get_urlprefix_service_id_mapping() diff --git a/oarepo_communities/ui/communities_components/templates/oarepo/invenio_communities/frontpage.html b/oarepo_communities/ui/communities_components/templates/oarepo/invenio_communities/frontpage.html index 50153b4..5225d2b 100644 --- a/oarepo_communities/ui/communities_components/templates/oarepo/invenio_communities/frontpage.html +++ b/oarepo_communities/ui/communities_components/templates/oarepo/invenio_communities/frontpage.html @@ -35,19 +35,23 @@ {% endblock searchbar %} {%- block user_communities %} -{% if current_user.is_authenticated %} -
-

{{_('My communities')}}

- - {{ _('See all')}} - -
- -
+{% if config.DISPLAY_USER_COMMUNITIES %} + {% if current_user.is_authenticated %} +
+

{{_('My communities')}}

+ + {{ _('See all')}} + +
+ +
+ {% endif %} {% endif %} {%- endblock user_communities %} + {%- block new_communities %} +{% if config.DISPLAY_NEW_COMMUNITIES %}

{{ _('New communities') }}

@@ -57,4 +61,5 @@

{{ _('New communities') }}

+{% endif %} {%- endblock new_communities %} \ No newline at end of file diff --git a/oarepo_communities/ui/oarepo_communities/semantic-ui/js/oarepo_communities/search/index.js b/oarepo_communities/ui/oarepo_communities/semantic-ui/js/oarepo_communities/search/index.js index 2405a2f..3546520 100644 --- a/oarepo_communities/ui/oarepo_communities/semantic-ui/js/oarepo_communities/search/index.js +++ b/oarepo_communities/ui/oarepo_communities/semantic-ui/js/oarepo_communities/search/index.js @@ -1,27 +1,25 @@ import React from "react"; import { parametrize } from "react-overridable"; import { i18next } from "@translations/oarepo_communities"; -import { - UserDashboardSearchAppLayoutHOC, - UserDashboardSearchAppResultView, -} from "@js/dashboard_components"; import { createSearchAppsInit, parseSearchAppConfigs, SearchappSearchbarElement, DynamicResultsListItem, + SearchAppLayoutWithSearchbarHOC, + SearchAppResultViewWithSearchbar, } from "@js/oarepo_ui"; const [{ overridableIdPrefix }] = parseSearchAppConfigs(); -const UserDashboardSearchAppResultViewWAppName = parametrize( - UserDashboardSearchAppResultView, +const SearchAppResultViewWithSearchbarWAppName = parametrize( + SearchAppResultViewWithSearchbar, { appName: overridableIdPrefix, } ); -export const DashboardUploadsSearchLayout = UserDashboardSearchAppLayoutHOC({ +export const DashboardUploadsSearchLayout = SearchAppLayoutWithSearchbarHOC({ placeholder: i18next.t("Search inside the community..."), appName: overridableIdPrefix, @@ -30,7 +28,7 @@ export const componentOverrides = { [`${overridableIdPrefix}.ResultsList.item`]: DynamicResultsListItem, [`${overridableIdPrefix}.SearchBar.element`]: SearchappSearchbarElement, [`${overridableIdPrefix}.SearchApp.results`]: - UserDashboardSearchAppResultViewWAppName, + SearchAppResultViewWithSearchbarWAppName, [`${overridableIdPrefix}.SearchApp.layout`]: DashboardUploadsSearchLayout, };