Extending / Overriding the `Contents` and `ContentsItem` components

I'm trying to figure out what it would take to change / extend the Contents and ContentsItem components (which show the contents of different folders and allows you to select, modify, and reorder items).

Obviously these are both pretty complicated components so, while I know that I can override them with my own, I thought I should ask here in case there is some simpler way.

I've been looking at the code and I believe the high-level things I need to accomplish are:

  • Rendering multiple Contents components on one page, each looking at a different folder. This might be possible already but I noticed some html elements with ids so I'm not sure.
  • Change the defaultIndexes (the columns in the Contents table). This is already easily configurable, which is great.
  • Pass some additional data / props into the ContentsItems (calculated on the frontend, not data from Plone)
  • Customize / replace the ContentsItem component.

I would love to leave the Contents component alone and simply replace / override the ContentsItem component. But I'm not sure I will have a way to pass additional data through Contents. I see that I can pass in the items which will be wrapped up as ContentsItems, so maybe I could inject my own data (calculations done on the front end, not data that would be stored in Plone) into the items from above the page containing the Contents components? But I couldn't tell how this would interact with the fetchContents and searchContents functions. Has anyone tried to pass "customized" items props directly to a Contents component before?

Failing that, maybe I have to accept that I need to override Contents, make a copy from the Volto source code, and then try to keep my changes minimal and isolated so that I can still merge future upstream changes?

Sorry for the long question, thanks for reading this far!

I think there's a common shared goal of reimplementing the Contents component with something based on react-table or similar. That component is nr 1 on my naughty list. Somebody needs to make it a priority :slight_smile:

2 Likes