Skip to content

Commit

Permalink
Add Overridable wrapper to CommunitiesManagement component (#2753)
Browse files Browse the repository at this point in the history
* Add Overridable wrap to CommunitiesManagement component
  • Loading branch information
mkloeppe authored Nov 12, 2024
1 parent 3d4cafc commit 35165ab
Showing 1 changed file with 44 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { RecordVersionsList } from "./RecordVersionsList";
import { RecordCitationField } from "./RecordCitationField";
import { ExportDropdown } from "./ExportDropdown";
import { CommunitiesManagement } from "./CommunitiesManagement";
import { OverridableContext, overrideStore } from "react-overridable";
import Overridable, { OverridableContext, overrideStore } from "react-overridable";

const recordManagementAppDiv = document.getElementById("recordManagement");
const recordManagementMobile = document.getElementById("recordManagementMobile");
Expand All @@ -26,14 +26,16 @@ const sidebarCommunitiesManageDiv = document.getElementById(
"sidebar-communities-manage"
);

const overriddenComponents = overrideStore.getAll();

if (recordManagementAppDiv) {
renderRecordManagement(recordManagementAppDiv);
recordManagementMobile && renderRecordManagement(recordManagementMobile);
}

function renderRecordManagement(element) {
ReactDOM.render(
<OverridableContext.Provider value={overrideStore.getAll()}>
<OverridableContext.Provider value={overriddenComponents}>
<RecordManagement
record={JSON.parse(recordManagementAppDiv.dataset.record)}
permissions={JSON.parse(recordManagementAppDiv.dataset.permissions)}
Expand Down Expand Up @@ -86,22 +88,46 @@ if (sidebarCommunitiesManageDiv) {
const pendingCommunitiesSearchConfig =
sidebarCommunitiesManageDiv.dataset.pendingCommunitiesSearchConfig;
ReactDOM.render(
<CommunitiesManagement
userCommunitiesMemberships={JSON.parse(
sidebarCommunitiesManageDiv.dataset.userCommunitiesMemberships
)}
recordCommunityEndpoint={
sidebarCommunitiesManageDiv.dataset.recordCommunityEndpoint
}
recordUserCommunitySearchConfig={JSON.parse(
sidebarCommunitiesManageDiv.dataset.recordUserCommunitySearchConfig
)}
canManageRecord={JSON.parse(sidebarCommunitiesManageDiv.dataset.canManageRecord)}
recordCommunitySearchConfig={recordCommunitySearchConfig}
permissions={JSON.parse(sidebarCommunitiesManageDiv.dataset.permissions)}
searchConfig={JSON.parse(pendingCommunitiesSearchConfig)}
record={JSON.parse(recordCitationAppDiv.dataset.record)}
/>,
<OverridableContext.Provider value={overriddenComponents}>
<Overridable
id="InvenioAppRdm.RecordLandingPage.CommunitiesManagement.container"
userCommunitiesMemberships={JSON.parse(
sidebarCommunitiesManageDiv.dataset.userCommunitiesMemberships
)}
recordCommunityEndpoint={
sidebarCommunitiesManageDiv.dataset.recordCommunityEndpoint
}
recordUserCommunitySearchConfig={JSON.parse(
sidebarCommunitiesManageDiv.dataset.recordUserCommunitySearchConfig
)}
canManageRecord={JSON.parse(
sidebarCommunitiesManageDiv.dataset.canManageRecord
)}
recordCommunitySearchConfig={recordCommunitySearchConfig}
permissions={JSON.parse(sidebarCommunitiesManageDiv.dataset.permissions)}
searchConfig={JSON.parse(pendingCommunitiesSearchConfig)}
record={JSON.parse(recordCitationAppDiv.dataset.record)}
>
<CommunitiesManagement
userCommunitiesMemberships={JSON.parse(
sidebarCommunitiesManageDiv.dataset.userCommunitiesMemberships
)}
recordCommunityEndpoint={
sidebarCommunitiesManageDiv.dataset.recordCommunityEndpoint
}
recordUserCommunitySearchConfig={JSON.parse(
sidebarCommunitiesManageDiv.dataset.recordUserCommunitySearchConfig
)}
canManageRecord={JSON.parse(
sidebarCommunitiesManageDiv.dataset.canManageRecord
)}
recordCommunitySearchConfig={recordCommunitySearchConfig}
permissions={JSON.parse(sidebarCommunitiesManageDiv.dataset.permissions)}
searchConfig={JSON.parse(pendingCommunitiesSearchConfig)}
record={JSON.parse(recordCitationAppDiv.dataset.record)}
/>
</Overridable>
</OverridableContext.Provider>,
sidebarCommunitiesManageDiv
);
}

0 comments on commit 35165ab

Please sign in to comment.