Skip to content

Commit

Permalink
Merge pull request #79 from oarepo/stojanovic/fe-265-remove-dependenc…
Browse files Browse the repository at this point in the history
…y-between-oarepo_dashboard-and

Stojanovic/fe 265 remove dependency between oarepo dashboard and
  • Loading branch information
mirekys authored Oct 22, 2024
2 parents 4eae3e6 + fc28b9c commit 7787ac9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 17 deletions.
7 changes: 7 additions & 0 deletions oarepo_communities/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -60,3 +61,9 @@
],
}
]

COMMUNITIES_ROUTES = {**INVENIO_COMMUNITIES_ROUTES, "my_communities": "/me/communities"}

DISPLAY_USER_COMMUNITIES = True

DISPLAY_NEW_COMMUNITIES = True
9 changes: 9 additions & 0 deletions oarepo_communities/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,22 @@ 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"]:
app.config["OAREPO_PERMISSIONS_PRESETS"][k] = (
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,23 @@
{% endblock searchbar %}

{%- block user_communities %}
{% if current_user.is_authenticated %}
<div class="flex">
<h2 class="ui header mb-0 align-self-center">{{_('My communities')}}</h2>
<a class="align-self-center rel-ml-1 " href="{{url_for('communities_dashboard.search')}}">
{{ _('See all')}}
</a>
</div>
<div class="ui divider hidden"></div>
<div id="user-communities" class="rel-mb-2"></div>
{% if config.DISPLAY_USER_COMMUNITIES %}
{% if current_user.is_authenticated %}
<div class="flex">
<h2 class="ui header mb-0 align-self-center">{{_('My communities')}}</h2>
<a class="align-self-center rel-ml-1 " href="{{config.COMMUNITIES_ROUTES['my_communities'] }}">
{{ _('See all')}}
</a>
</div>
<div class="ui divider hidden"></div>
<div id="user-communities" class="rel-mb-2"></div>
{% endif %}
{% endif %}
{%- endblock user_communities %}


{%- block new_communities %}
{% if config.DISPLAY_NEW_COMMUNITIES %}
<div class="ui divider"></div>
<div class="flex">
<h2 class="ui header mb-0 align-self-center">{{ _('New communities') }}</h2>
Expand All @@ -57,4 +61,5 @@ <h2 class="ui header mb-0 align-self-center">{{ _('New communities') }}</h2>
</div>
<div class="ui divider hidden"></div>
<div id="new-communities"></div>
{% endif %}
{%- endblock new_communities %}
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -30,7 +28,7 @@ export const componentOverrides = {
[`${overridableIdPrefix}.ResultsList.item`]: DynamicResultsListItem,
[`${overridableIdPrefix}.SearchBar.element`]: SearchappSearchbarElement,
[`${overridableIdPrefix}.SearchApp.results`]:
UserDashboardSearchAppResultViewWAppName,
SearchAppResultViewWithSearchbarWAppName,
[`${overridableIdPrefix}.SearchApp.layout`]: DashboardUploadsSearchLayout,
};

Expand Down

0 comments on commit 7787ac9

Please sign in to comment.