-
Notifications
You must be signed in to change notification settings - Fork 7
feat: add 0:n override #24
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
Conversation
utnapischtim
commented
Sep 4, 2025
- this change enables to add multiple components to one override id
|
Can you please share an example on how this would be used? |
|
Also, wouldn't it be cleaner to override the component with a custom component (this could potentially be a |
|
I am working on a cataloging feature for the repository of tu graz based on InvenioRDM. this commit tries it out: it is mostly here where i add the here i add the custom components to the store. this should at the end be moved to a separate package. it is now tested within the catalogue-marc21 to make the tests easier. at the end i will move that to here i added the context provider. it is the wrapper round the whole deposit page. |
no, because i would like to have the possibility to add e.g. so the idea is that different packages can add features to the |
src/overridable.js
Outdated
| const elements = overrides.map((overriden, i) => | ||
| React.createElement(overriden, {...childProps, ...restProps, key: `${id}-${i}`}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const elements = overrides.map((overriden, i) => | |
| React.createElement(overriden, {...childProps, ...restProps, key: `${id}-${i}`}) | |
| const elements = overrides.map((overridden, i) => | |
| React.createElement(overridden, {...childProps, ...restProps, key: `${id}-${i}`}) |
|
OK, sounds reasonable. I'll let one of the Invenio guys have a look at the change as well though before testing it myself (just to ensure it does not break anything in Indico, even though the change looks fully backwards compatible) and merging it. |
7a9342e to
d7bceb9
Compare
|
i moved one component to another package to check if all is still working as expected. diff for invenio-workflows-tugraz: https://github.com/tu-graz-library/invenio-workflows-tugraz/pull/112/files . it adds the component here to the and the tricky part was to add the |
@utnapischtim I tend to agree with @ThiefMaster, and I would be more in favor of keeping this library simple as it is. Question (I didn't check the code deeply): can we instead introduce here an extension point, and you can implement extra APIs like @ThiefMaster ideas? Do you see a use case for this in Indico installations? |
|
we could add a separate like: #25 but i think if we want to have this solution it would be better to create a separate react package like |
i am unsure what you mean, but in my interpretation it would introduce more "complicated" code to the |
|
@ThiefMaster |
| }; | ||
|
|
||
| append = (id, Component) => { | ||
| if (!Array.isArray(this.components[id])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this fail if there's already a single-component override? Or automatically convert the existing entry to an array containing that one?
Right now add followed by append silently discards the initial element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say that is debatable.
After thinking it through i would say, append should silently convert the existing one element to an array with the element in it.
BUT: what do we do if afterwards a add is called?
after thinking that another time through (i already feel like i am a reasoning model) i would use another property for append
append = (id, Component) => {
if (!Array.isArray(this.components_multiple[id])) { // TODO: naming
this.components_multiple[id] = [];
}
this.components_multiple[id].push(Component);
};
with following change:
get = id => {
let out = [];
if (id in this.components_multiple) {
out = this.components_multiple[id];
}
if (id in this.components) {
out.push(this.components[id])
}
if (out.length > 1) {
return out;
} else {
return out[0];
}
};
with this approach we would enable the option to add another item to a container which is already replaced.
* this change enables to add multiple components to one override id
d7bceb9 to
a5bee21
Compare
|
i close this. i have implemented the feature now in my package |