From 6c4e176b00888f44fb4fe4bfed05c9ba76fa998a Mon Sep 17 00:00:00 2001 From: Javier Romero Castro Date: Fri, 20 Jan 2023 13:50:26 +0100 Subject: [PATCH] overrideStore: add global mapping for overriden components * closes https://github.com/inveniosoftware/invenio-app-rdm/issues/2018 --- .../invenio_communities/details/index.html | 2 +- .../invenio_app_rdm/records/search.html | 2 +- .../components/RecordsResultsListItem.js | 7 +- .../invenio_app_rdm/deposit/RDMDepositForm.js | 42 +++++----- .../js/invenio_app_rdm/deposit/index.js | 5 +- .../invenio_app_rdm/frontpage/RecordsList.js | 80 ++++++++++++------- .../js/invenio_app_rdm/frontpage/index.js | 9 ++- .../js/invenio_app_rdm/frontpage/override.js | 7 -- .../overridableRegistry/index.js | 13 +++ .../mapping.js} | 2 +- .../js/invenio_app_rdm/search/components.js | 18 +++-- .../js/invenio_app_rdm/search/index.js | 48 ++++++++--- .../js/invenio_app_rdm/user_dashboard/base.js | 42 ++++++++-- .../user_dashboard/communities.js | 34 +++++--- .../user_dashboard/requests.js | 67 +++++++++------- .../invenio_app_rdm/user_dashboard/uploads.js | 39 ++++++--- .../invenio_app_rdm/javascript.html | 1 + invenio_app_rdm/theme/webpack.py | 1 + .../invenio_app_rdm/users/communities.html | 2 +- .../invenio_app_rdm/users/requests.html | 2 +- .../invenio_app_rdm/users/uploads.html | 2 +- 21 files changed, 279 insertions(+), 146 deletions(-) delete mode 100644 invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/override.js create mode 100644 invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/overridableRegistry/index.js rename invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/{deposit/override.js => overridableRegistry/mapping.js} (89%) diff --git a/invenio_app_rdm/communities_ui/templates/semantic-ui/invenio_communities/details/index.html b/invenio_app_rdm/communities_ui/templates/semantic-ui/invenio_communities/details/index.html index f5f1a99ca..d5856c27d 100644 --- a/invenio_app_rdm/communities_ui/templates/semantic-ui/invenio_communities/details/index.html +++ b/invenio_app_rdm/communities_ui/templates/semantic-ui/invenio_communities/details/index.html @@ -19,6 +19,6 @@ {%- block page_body %} {{ super() }}
{%- endblock page_body %} diff --git a/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/search.html b/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/search.html index 6f1d84728..4cd5af1ba 100644 --- a/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/search.html +++ b/invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/search.html @@ -15,6 +15,6 @@ {%- block page_body %}
-
+
{%- endblock page_body %} diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/RecordsResultsListItem.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/RecordsResultsListItem.js index b87e62a6a..1d684cd97 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/RecordsResultsListItem.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/RecordsResultsListItem.js @@ -12,10 +12,11 @@ import Overridable from "react-overridable"; import { SearchItemCreators } from "../utils"; import PropTypes from "prop-types"; import { Item, Label, Icon } from "semantic-ui-react"; +import { buildUID } from "react-searchkit"; class RecordsResultsListItem extends Component { render() { - const { currentQueryState, result, key } = this.props; + const { currentQueryState, result, key, appName } = this.props; const accessStatusId = _get(result, "ui.access_status.id", "open"); const accessStatus = _get(result, "ui.access_status.title_l10n", "Open"); @@ -56,7 +57,7 @@ class RecordsResultsListItem extends Component { const viewLink = `/records/${result.id}`; return ( - + @@ -132,7 +132,7 @@ export class RDMDepositForm extends Component { )} @@ -161,7 +161,7 @@ export class RDMDepositForm extends Component { {this.config.pids.map((pid) => ( @@ -187,7 +187,7 @@ export class RDMDepositForm extends Component { ))} - + @@ -233,7 +233,7 @@ export class RDMDepositForm extends Component { @@ -258,7 +258,7 @@ export class RDMDepositForm extends Component { /> - + @@ -318,7 +318,7 @@ export class RDMDepositForm extends Component { @@ -330,7 +330,7 @@ export class RDMDepositForm extends Component { - + - + @@ -374,7 +374,7 @@ export class RDMDepositForm extends Component { label="Funding" ui={this.accordionStyle} > - + {!_isEmpty(customFieldsUI) && ( - + diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/RecordsList.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/RecordsList.js index a25935803..3ef2ca48b 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/RecordsList.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/RecordsList.js @@ -12,8 +12,9 @@ import { Loader, Container, Header, Item, Button, Message } from "semantic-ui-re import Overridable from "react-overridable"; import RecordsResultsListItem from "@js/invenio_app_rdm/components/RecordsResultsListItem"; import isEmpty from "lodash/isEmpty"; +import { buildUID } from "react-searchkit"; -class RecordsList extends Component { +export class RecordsList extends Component { constructor(props) { super(props); @@ -55,47 +56,70 @@ class RecordsList extends Component { render() { const { isLoading, data, error } = this.state; - const { title } = this.props; + const { title, appName } = this.props; const listItems = data.hits?.map((record) => { - return ; + return ( + + ); }); + return ( + !isEmpty(listItems) && ( + + {isLoading && } + + {!isLoading && !error && ( + <> +
{title}
+ + {listItems} + + + + + + )} + + {error && } +
+ ) + ); + } +} + +RecordsList.propTypes = { + title: PropTypes.string.isRequired, + fetchUrl: PropTypes.string.isRequired, + appName: PropTypes.string, +}; + +RecordsList.defaultProps = { + appName: "", +}; + +export class RecordsListOverridable extends Component { + render() { + const { title, fetchUrl, appName } = this.props; return ( - {!isEmpty(listItems) && ( - - {isLoading && } - - {!isLoading && !error && ( - <> -
{title}
- - {listItems} - - - - - - )} - - {error && } -
- )} +
); } } -RecordsList.propTypes = { +RecordsListOverridable.propTypes = { title: PropTypes.string.isRequired, fetchUrl: PropTypes.string.isRequired, + appName: PropTypes.string, }; -export default Overridable.component("RecordsList", RecordsList); +RecordsListOverridable.defaultProps = { + appName: "", +}; diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/index.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/index.js index 5810b405d..cf3076fd8 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/index.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/index.js @@ -6,17 +6,18 @@ import React from "react"; import ReactDOM from "react-dom"; -import RecordsList from "./RecordsList"; -import { OverridableContext } from "react-overridable"; -import { overriddenComponents } from "./override"; +import { RecordsListOverridable } from "./RecordsList"; +import { OverridableContext, overrideStore } from "react-overridable"; +const overriddenComponents = overrideStore.getAll(); const recordsListContainer = document.getElementById("records-list"); const title = recordsListContainer.dataset.title; const fetchUrl = recordsListContainer.dataset.fetchUrl; +const appName = "InvenioAppRDM.RecordsList"; ReactDOM.render( - + , recordsListContainer ); diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/override.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/override.js deleted file mode 100644 index 23acda895..000000000 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/override.js +++ /dev/null @@ -1,7 +0,0 @@ -// This file is part of InvenioRDM -// Copyright (C) 2022 CERN. -// -// Invenio App RDM is free software; you can redistribute it and/or modify it -// under the terms of the MIT License; see LICENSE file for more details. - -export const overriddenComponents = {}; diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/overridableRegistry/index.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/overridableRegistry/index.js new file mode 100644 index 000000000..35ec57b71 --- /dev/null +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/overridableRegistry/index.js @@ -0,0 +1,13 @@ +// This file is part of InvenioRDM +// Copyright (C) 2023 CERN. +// +// Invenio App RDM is free software; you can redistribute it and/or modify it +// under the terms of the MIT License; see LICENSE file for more details. + +import { overriddenComponents } from "./mapping"; + +import { overrideStore } from "react-overridable"; + +for (const [key, value] of Object.entries(overriddenComponents)) { + overrideStore.add(key, value); +} diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/deposit/override.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/overridableRegistry/mapping.js similarity index 89% rename from invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/deposit/override.js rename to invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/overridableRegistry/mapping.js index 23acda895..563fb0c41 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/deposit/override.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/overridableRegistry/mapping.js @@ -1,5 +1,5 @@ // This file is part of InvenioRDM -// Copyright (C) 2022 CERN. +// Copyright (C) 2023 CERN. // // Invenio App RDM is free software; you can redistribute it and/or modify it // under the terms of the MIT License; see LICENSE file for more details. diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/search/components.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/search/components.js index c34f05493..4cd6ad7ed 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/search/components.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/search/components.js @@ -16,7 +16,7 @@ import _get from "lodash/get"; import _truncate from "lodash/truncate"; import React from "react"; import Overridable from "react-overridable"; -import { withState } from "react-searchkit"; +import { withState, buildUID } from "react-searchkit"; import { Button, Card, @@ -33,8 +33,12 @@ import RecordsResultsListItem from "../components/RecordsResultsListItem"; import PropTypes from "prop-types"; export const RDMRecordResultsListItemWithState = withState( - ({ currentQueryState, result }) => ( - + ({ currentQueryState, result, appName }) => ( + ) ); @@ -66,14 +70,18 @@ RDMRecordResultsGridItem.propTypes = { result: PropTypes.object.isRequired, }; -export const RDMRecordSearchBarContainer = () => { +export const RDMRecordSearchBarContainer = ({ appName }) => { return ( - + ); }; +RDMRecordSearchBarContainer.propTypes = { + appName: PropTypes.string.isRequired, +}; + export const RDMRecordMultipleSearchBarElement = ({ queryString, onInputChange }) => { const headerSearchbar = document.getElementById("header-search-bar"); const searchbarOptions = JSON.parse(headerSearchbar.dataset.options); diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/search/index.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/search/index.js index ae86078de..e94b23ed3 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/search/index.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/search/index.js @@ -17,7 +17,7 @@ import { RDMRecordMultipleSearchBarElement, RDMToggleComponent, } from "./components"; -import { parametrize } from "react-overridable"; +import { parametrize, overrideStore } from "react-overridable"; import { ContribSearchAppFacets, ContribBucketAggregationElement, @@ -28,16 +28,38 @@ const ContribSearchAppFacetsWithConfig = parametrize(ContribSearchAppFacets, { toogle: true, }); -createSearchAppInit({ - "BucketAggregation.element": ContribBucketAggregationElement, - "BucketAggregationValues.element": ContribBucketAggregationValuesElement, - "ResultsGrid.item": RDMRecordResultsGridItem, - "EmptyResults.element": RDMEmptyResults, - "ResultsList.item": RDMRecordResultsListItemWithState, - "SearchApp.facets": ContribSearchAppFacetsWithConfig, - "SearchApp.searchbarContainer": RDMRecordSearchBarContainer, - "SearchBar.element": RDMRecordMultipleSearchBarElement, - "Count.element": RDMCountComponent, - "Error.element": RDMErrorComponent, - "SearchFilters.Toggle.element": RDMToggleComponent, +const appName = "InvenioAppRdm.Search"; + +const RDMRecordSearchBarContainerWithConfig = parametrize(RDMRecordSearchBarContainer, { + appName: appName, }); + +const RDMRecordResultsListItemWithConfig = parametrize( + RDMRecordResultsListItemWithState, + { + appName: appName, + } +); + +export const defaultComponents = { + [`${appName}.BucketAggregation.element`]: ContribBucketAggregationElement, + [`${appName}.BucketAggregationValues.element`]: ContribBucketAggregationValuesElement, + [`${appName}.ResultsGrid.item`]: RDMRecordResultsGridItem, + [`${appName}.EmptyResults.element`]: RDMEmptyResults, + [`${appName}.ResultsList.item`]: RDMRecordResultsListItemWithConfig, + [`${appName}.SearchApp.facets`]: ContribSearchAppFacetsWithConfig, + [`${appName}.SearchApp.searchbarContainer`]: RDMRecordSearchBarContainerWithConfig, + [`${appName}.SearchBar.element`]: RDMRecordMultipleSearchBarElement, + [`${appName}.Count.element`]: RDMCountComponent, + [`${appName}.Error.element`]: RDMErrorComponent, + [`${appName}.SearchFilters.Toggle.element`]: RDMToggleComponent, +}; + +const overriddenComponents = overrideStore.getAll(); + +createSearchAppInit( + { ...defaultComponents, ...overriddenComponents }, + true, + "invenio-search-config", + true +); diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/base.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/base.js index 32e4524a4..9e3783f37 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/base.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/base.js @@ -14,15 +14,14 @@ import { } from "@js/invenio_search_ui/components"; import { i18next } from "@translations/invenio_app_rdm/i18next"; import React from "react"; -import { Count, ResultsList, SearchBar, Sort } from "react-searchkit"; +import { Count, ResultsList, SearchBar, Sort, buildUID } from "react-searchkit"; import { GridResponsiveSidebarColumn } from "react-invenio-forms"; import { Grid, Segment, Button } from "semantic-ui-react"; import PropTypes from "prop-types"; - import Overridable from "react-overridable"; export function DashboardResultView(props) { - const { sortOptions, paginationOptions, currentResultsState } = props; + const { sortOptions, paginationOptions, currentResultsState, appName } = props; const { total } = currentResultsState.data; return ( total && ( @@ -31,7 +30,13 @@ export function DashboardResultView(props) { - + - + @@ -71,7 +82,13 @@ export function DashboardResultView(props) { - + @@ -83,11 +100,17 @@ DashboardResultView.propTypes = { sortOptions: PropTypes.array.isRequired, paginationOptions: PropTypes.object.isRequired, currentResultsState: PropTypes.object.isRequired, + appName: PropTypes.string, +}; + +DashboardResultView.defaultProps = { + appName: "", }; export const DashboardSearchLayoutHOC = ({ searchBarPlaceholder = "", newBtn = () => null, + appName = undefined, }) => { const DashboardUploadsSearchLayout = (props) => { const [sidebarVisible, setSidebarVisible] = React.useState(false); @@ -118,10 +141,13 @@ export const DashboardSearchLayoutHOC = ({ open={sidebarVisible} onHideClick={() => setSidebarVisible(false)} > - + - + diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/communities.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/communities.js index 4dceb5a06..3d4d59d6d 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/communities.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/communities.js @@ -21,6 +21,9 @@ import { ContribBucketAggregationElement, ContribBucketAggregationValuesElement, } from "@js/invenio_search_ui/components"; +import { overrideStore, parametrize } from "react-overridable"; + +export const appName = "InvenioAppRdm.DashboardCommunities"; function ResultsGridItemTemplate({ result, index }) { return ( @@ -74,6 +77,7 @@ export const DashboardCommunitiesSearchLayout = DashboardSearchLayoutHOC({ floated="right" /> ), + appName: appName, }); export const RDMCommunitiesEmptyResults = (props) => { @@ -98,16 +102,26 @@ RDMCommunitiesEmptyResults.propTypes = { resetQuery: PropTypes.func.isRequired, }; +const DashboardResultViewWAppName = parametrize(DashboardResultView, { + appName: appName, +}); + export const defaultComponents = { - "BucketAggregation.element": ContribBucketAggregationElement, - "BucketAggregationValues.element": ContribBucketAggregationValuesElement, - "EmptyResults.element": RDMCommunitiesEmptyResults, - "ResultsList.item": CommunitiesResultsItemTemplate, - "ResultsGrid.item": ResultsGridItemTemplate, - "SearchApp.facets": ContribSearchAppFacets, - "SearchApp.layout": DashboardCommunitiesSearchLayout, - "SearchApp.results": DashboardResultView, - "SearchBar.element": RDMRecordSearchBarElement, + [`${appName}.BucketAggregation.element`]: ContribBucketAggregationElement, + [`${appName}.BucketAggregationValues.element`]: ContribBucketAggregationValuesElement, + [`${appName}.EmptyResults.element`]: RDMCommunitiesEmptyResults, + [`${appName}.ResultsList.item`]: CommunitiesResultsItemTemplate, + [`${appName}.ResultsGrid.item`]: ResultsGridItemTemplate, + [`${appName}.SearchApp.facets`]: ContribSearchAppFacets, + [`${appName}.SearchApp.layout`]: DashboardCommunitiesSearchLayout, + [`${appName}.SearchApp.results`]: DashboardResultViewWAppName, + [`${appName}.SearchBar.element`]: RDMRecordSearchBarElement, }; +const overriddenComponents = overrideStore.getAll(); -createSearchAppInit(defaultComponents); +createSearchAppInit( + { ...defaultComponents, ...overriddenComponents }, + true, + "invenio-search-config", + true +); diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests.js index b852944c0..7e509c437 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/requests.js @@ -20,7 +20,7 @@ import PropTypes from "prop-types"; import React, { Component } from "react"; import { GridResponsiveSidebarColumn } from "react-invenio-forms"; import { Count, ResultsList, SearchBar, Sort, withState } from "react-searchkit"; -import { parametrize } from "react-overridable"; +import { parametrize, overrideStore } from "react-overridable"; import { LabelTypeInvitation, LabelTypeSubmission, @@ -60,6 +60,8 @@ import { ContribBucketAggregationValuesElement, } from "@js/invenio_search_ui/components"; +const appName = "InvenioAppRdm.DashboardRequests"; + export const RequestsResults = ({ sortOptions, paginationOptions, @@ -313,10 +315,13 @@ export const RDMRequestsSearchLayout = (props) => { open={sidebarVisible} onHideClick={() => setSidebarVisible(false)} > - + - + @@ -419,29 +424,37 @@ const Cancelled = () => ; const Expired = () => ; export const defaultComponents = { - "BucketAggregation.element": ContribBucketAggregationElement, - "BucketAggregationValues.element": ContribBucketAggregationValuesElement, - "SearchApp.facets": ContribSearchAppFacets, - "ResultsList.item": RequestsResultsItemTemplateDashboard, - "ResultsGrid.item": RequestsResultsGridItemTemplate, - "SearchApp.layout": RDMRequestsSearchLayout, - "SearchApp.results": RequestsResults, - "SearchBar.element": RDMRecordSearchBarElement, - "EmptyResults.element": RDMRequestsEmptyResultsWithState, - "RequestTypeLabel.layout.community-submission": CommunitySubmission, - "RequestTypeLabel.layout.community-invitation": CommunityInvitation, - "RequestStatusLabel.layout.submitted": Submitted, - "RequestStatusLabel.layout.deleted": Deleted, - "RequestStatusLabel.layout.accepted": Accepted, - "RequestStatusLabel.layout.declined": Declined, - "RequestStatusLabel.layout.cancelled": Cancelled, - "RequestStatusLabel.layout.expired": Expired, - "RequestActionModalTrigger.accept": RequestAcceptModalTriggerWithConfig, - "RequestActionModalTrigger.decline": RequestDeclineModalTriggerWithConfig, - "RequestActionModalTrigger.cancel": RequestCancelModalTriggerWithConfig, - "RequestActionButton.cancel": RequestCancelButton, - "RequestActionButton.decline": RequestDeclineButton, - "RequestActionButton.accept": RequestAcceptButton, + [`${appName}.BucketAggregation.element`]: ContribBucketAggregationElement, + [`${appName}.BucketAggregationValues.element`]: ContribBucketAggregationValuesElement, + [`${appName}.SearchApp.facets`]: ContribSearchAppFacets, + [`${appName}.ResultsList.item`]: RequestsResultsItemTemplateDashboard, + [`${appName}.ResultsGrid.item`]: RequestsResultsGridItemTemplate, + [`${appName}.SearchApp.layout`]: RDMRequestsSearchLayout, + [`${appName}.SearchApp.results`]: RequestsResults, + [`${appName}.SearchBar.element`]: RDMRecordSearchBarElement, + [`${appName}.EmptyResults.element`]: RDMRequestsEmptyResultsWithState, + [`${appName}.RequestTypeLabel.layout.community-submission`]: CommunitySubmission, + [`${appName}.RequestTypeLabel.layout.community-invitation`]: CommunityInvitation, + [`${appName}.RequestStatusLabel.layout.submitted`]: Submitted, + [`${appName}.RequestStatusLabel.layout.deleted`]: Deleted, + [`${appName}.RequestStatusLabel.layout.accepted`]: Accepted, + [`${appName}.RequestStatusLabel.layout.declined`]: Declined, + [`${appName}.RequestStatusLabel.layout.cancelled`]: Cancelled, + [`${appName}.RequestStatusLabel.layout.expired`]: Expired, + [`${appName}.RequestActionModalTrigger.accept`]: RequestAcceptModalTriggerWithConfig, + [`${appName}.RequestActionModalTrigger.decline`]: + RequestDeclineModalTriggerWithConfig, + [`${appName}.RequestActionModalTrigger.cancel`]: RequestCancelModalTriggerWithConfig, + [`${appName}.RequestActionButton.cancel`]: RequestCancelButton, + [`${appName}.RequestActionButton.decline`]: RequestDeclineButton, + [`${appName}.RequestActionButton.accept`]: RequestAcceptButton, }; -createSearchAppInit(defaultComponents); +const overriddenComponents = overrideStore.getAll(); + +createSearchAppInit( + { ...defaultComponents, ...overriddenComponents }, + true, + "invenio-search-config", + true +); diff --git a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads.js b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads.js index 99f8a5131..428fb19aa 100644 --- a/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads.js +++ b/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/user_dashboard/uploads.js @@ -12,7 +12,7 @@ import _get from "lodash/get"; import _truncate from "lodash/truncate"; import React from "react"; import { Button, Card, Divider, Header, Segment } from "semantic-ui-react"; -import { parametrize } from "react-overridable"; +import { parametrize, overrideStore } from "react-overridable"; import { RDMCountComponent, RDMEmptyResults as RDMNoSearchResults, @@ -161,6 +161,8 @@ RDMEmptyResults.propTypes = { queryString: PropTypes.string.isRequired, }; +const appName = "InvenioAppRdm.DashboardUploads"; + export const DashboardUploadsSearchLayout = DashboardSearchLayoutHOC({ searchBarPlaceholder: i18next.t("Search in my uploads..."), newBtn: ( @@ -172,24 +174,35 @@ export const DashboardUploadsSearchLayout = DashboardSearchLayoutHOC({ floated="right" /> ), + appName: appName, }); const ContribSearchAppFacetsWithConfig = parametrize(ContribSearchAppFacets, { toogle: true, }); +const DashboardResultViewWAppName = parametrize(DashboardResultView, { + appName: appName, +}); + export const defaultComponents = { - "BucketAggregation.element": ContribBucketAggregationElement, - "BucketAggregationValues.element": ContribBucketAggregationValuesElement, - "Count.element": RDMCountComponent, - "EmptyResults.element": RDMEmptyResults, - "ResultsList.item": RDMRecordResultsListItem, - "ResultsGrid.item": RDMRecordResultsGridItem, - "SearchApp.facets": ContribSearchAppFacetsWithConfig, - "SearchApp.layout": DashboardUploadsSearchLayout, - "SearchApp.results": DashboardResultView, - "SearchBar.element": RDMRecordSearchBarElement, - "SearchFilters.Toggle.element": RDMToggleComponent, + [`${appName}.BucketAggregation.element`]: ContribBucketAggregationElement, + [`${appName}.BucketAggregationValues.element`]: ContribBucketAggregationValuesElement, + [`${appName}.Count.element`]: RDMCountComponent, + [`${appName}.EmptyResults.element`]: RDMEmptyResults, + [`${appName}.ResultsList.item`]: RDMRecordResultsListItem, + [`${appName}.ResultsGrid.item`]: RDMRecordResultsGridItem, + [`${appName}.SearchApp.facets`]: ContribSearchAppFacetsWithConfig, + [`${appName}.SearchApp.layout`]: DashboardUploadsSearchLayout, + [`${appName}.SearchApp.results`]: DashboardResultViewWAppName, + [`${appName}.SearchBar.element`]: RDMRecordSearchBarElement, + [`${appName}.SearchFilters.Toggle.element`]: RDMToggleComponent, }; +const overriddenComponents = overrideStore.getAll(); -createSearchAppInit(defaultComponents); +createSearchAppInit( + { ...defaultComponents, ...overriddenComponents }, + true, + "invenio-search-config", + true +); diff --git a/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/javascript.html b/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/javascript.html index 0345ea657..c97dd4c8b 100644 --- a/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/javascript.html +++ b/invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/javascript.html @@ -9,3 +9,4 @@ {{ webpack['theme.js']}} {{ webpack['base-theme-rdm.js']}} {{ webpack['i18n_app.js']}} +{{ webpack['overridable-registry.js'] }} diff --git a/invenio_app_rdm/theme/webpack.py b/invenio_app_rdm/theme/webpack.py index 987859f69..4b9428028 100644 --- a/invenio_app_rdm/theme/webpack.py +++ b/invenio_app_rdm/theme/webpack.py @@ -29,6 +29,7 @@ "base-theme-rdm": "./js/invenio_app_rdm/theme.js", "iiif-simple-previewer": "./less/invenio_app_rdm/previewer/iiif_simple.less", "invenio-app-rdm-frontpage": "./js/invenio_app_rdm/frontpage/index.js", + "overridable-registry": "./js/invenio_app_rdm/overridableRegistry/index.js", }, dependencies={ "@babel/runtime": "^7.9.0", diff --git a/invenio_app_rdm/users_ui/templates/semantic-ui/invenio_app_rdm/users/communities.html b/invenio_app_rdm/users_ui/templates/semantic-ui/invenio_app_rdm/users/communities.html index ea11eba8b..3ab3ff4e4 100644 --- a/invenio_app_rdm/users_ui/templates/semantic-ui/invenio_app_rdm/users/communities.html +++ b/invenio_app_rdm/users_ui/templates/semantic-ui/invenio_app_rdm/users/communities.html @@ -18,7 +18,7 @@ {%- block user_dashboard_body %}
{%- endblock user_dashboard_body %} diff --git a/invenio_app_rdm/users_ui/templates/semantic-ui/invenio_app_rdm/users/requests.html b/invenio_app_rdm/users_ui/templates/semantic-ui/invenio_app_rdm/users/requests.html index bd72b41c9..6e463482f 100644 --- a/invenio_app_rdm/users_ui/templates/semantic-ui/invenio_app_rdm/users/requests.html +++ b/invenio_app_rdm/users_ui/templates/semantic-ui/invenio_app_rdm/users/requests.html @@ -18,7 +18,7 @@ {%- block user_dashboard_body %}
{%- endblock user_dashboard_body %} diff --git a/invenio_app_rdm/users_ui/templates/semantic-ui/invenio_app_rdm/users/uploads.html b/invenio_app_rdm/users_ui/templates/semantic-ui/invenio_app_rdm/users/uploads.html index cb3aabf82..d2e2f85c2 100644 --- a/invenio_app_rdm/users_ui/templates/semantic-ui/invenio_app_rdm/users/uploads.html +++ b/invenio_app_rdm/users_ui/templates/semantic-ui/invenio_app_rdm/users/uploads.html @@ -18,7 +18,7 @@ {%- block user_dashboard_body %}