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

Mirekys/overridable bundle project #266

Merged
merged 24 commits into from
Jan 29, 2025
Merged

Conversation

mirekys
Copy link
Member

@mirekys mirekys commented Jan 21, 2025

This PR adds OverridableBundleProject which can be used to provide site-wide UI component overrides using:

#invenio.cfg
WEBPACKEXT_PROJECT = "oarepo_ui.webpack:project"

UI_OVERRIDES = {
    # Flask blueprint endpoint name
    "documents.search": {
       # Overridable component ID            Default import name                  Import path
        "Documents.Search.ResultsList.item": ("ResultsListItem", "@js/documents/search/ResultsListItem")
    }
}

Requires oarepo/nrp-devtools#54

@mirekys mirekys marked this pull request as draft January 21, 2025 18:05
@mirekys mirekys marked this pull request as ready for review January 22, 2025 13:30
@mirekys mirekys requested review from Ducica and mesemus January 22, 2025 14:19
@Ducica
Copy link
Contributor

Ducica commented Jan 23, 2025

@mirekys I like the solution, very nice job.

I've also made some checks and if we use this and make some small refactoring, the bundle on search for example, goes from 38 to 27 mb which is a pretty good improvement. it is still not great, but 7 of those that are left is just tiny mce, which we cannot do anything about right now (numbers are of course much smaller for production builds). Anyway, it is a solid step in a good direction.

I got two remarks/questions:

  1. If we wish to just disable a certain component, normally, I would do "cmpid":()=>null. The question is if this can be handled by the code generator (meaning if you do not provide component, to just add to override store "cmpid":()=>null". Or to just have a "NullComponent" that can be used in invenio.cfg for when you want to do this.
  2. It would be really great, if a 4th parameter (after the import type), could be introduced, which would be for parametrization, i.e. an object with props, so that the component will be automatically parametrized as well. This would be a nice to have and is bypassable like we discussed.

@mirekys
Copy link
Member Author

mirekys commented Jan 23, 2025

@mirekys I like the solution, very nice job.

I've also made some checks and if we use this and make some small refactoring, the bundle on search for example, goes from 38 to 27 mb which is a pretty good improvement. it is still not great, but 7 of those that are left is just tiny mce, which we cannot do anything about right now (numbers are of course much smaller for production builds). Anyway, it is a solid step in a good direction.

I got two remarks/questions:

  1. If we wish to just disable a certain component, normally, I would do "cmpid":()=>null. The question is if this can be handled by the code generator (meaning if you do not provide component, to just add to override store "cmpid":()=>null". Or to just have a "NullComponent" that can be used in invenio.cfg for when you want to do this.
  2. It would be really great, if a 4th parameter (after the import type), could be introduced, which would be for parametrization, i.e. an object with props, so that the component will be automatically parametrized as well. This would be a nice to have and is bypassable like we discussed.

Thanks @Ducica for excellent feedback! The solution for 1. would probably be having this simple Disabled or Noop component exported by e.g. oarepo_ui and referenced from overrides config. That way you could also know, when looking into React devtools component tree, by its name, which parts of UI was deliberately disabled. For 2., I'll have a look at how that could be done. I think it could be possible now without too much effort

Ducica
Ducica previously approved these changes Jan 23, 2025
Ducica
Ducica previously approved these changes Jan 28, 2025
@mirekys mirekys merged commit a946924 into main Jan 29, 2025
4 checks passed
@mirekys mirekys deleted the mirekys/overridable-bundle-project branch January 29, 2025 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants