Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-29999: As an editor, I want to see custom icons for content types #805

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@
return total;
}, {});
const udwConfigBulkMoveItems = JSON.parse(container.dataset.udwConfigBulkMoveItems);
const mfuContentTypesMap = Object.values(eZ.adminUiConfig.contentTypes).reduce((contentTypeDataMap, contentTypeGroup) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to pass different config to MFU because the one based on: container.dataset.contentTypes contains only CTs of elements displayed in Sub-items.

Given that mfuContentTypesMap in contrast to contentTypesMap (which is passed to Sub-items) does not contain whole CT objects but rather data stored in eZ.adminUiConfig.contentTypes, are we OK with passing mfuContentTypesMap to MFU as contentTypesMap - ping @dew326 @sunpietro ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the approach is ok.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a difference only in missing data or in the data structure as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contentTypesMap is a map of CT objects; mfuContentTypesMap in this case is a map of objects like:

{
    href: "/api/ezp/v2/content/types/21"
    identifier: "about"
    name: "About"
    thumbnail: "/bundles/ezplatformadminui/img/ez-icons.svg#about"
}

name and thumbnail does not exist on CT object.
We can always call it contentTypesDataMap etc. We can also resign from passing this as a prop and extract it inside MFU. Or even make global helper function - getContentTypeIdentifierByHref, which may be helpful in other React components.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explanation. Can't the backend provide this structure instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We opted for this solution mostly because this is more efficient than extracting objects for all Content Types. But maybe it is way to go. This question is more to @adamwojs .

for (const contentTypeData of contentTypeGroup) {
contentTypeDataMap[contentTypeData.href] = contentTypeData;
}

return contentTypeDataMap;
}, {});

ReactDOM.render(
React.createElement(eZ.modules.SubItems, {
Expand All @@ -127,7 +134,7 @@
attrs: Object.assign({}, mfuAttrs, {
onPopupClose: (itemsUploaded) => itemsUploaded.length && global.location.reload(true),
contentCreatePermissionsConfig: JSON.parse(container.dataset.mfuCreatePermissionsConfig),
contentTypesMap,
contentTypesMap: mfuContentTypesMap,
}),
},
],
Expand Down