-
Notifications
You must be signed in to change notification settings - Fork 437
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
Fix match theme by handle with canonical prefix https://hdl.handle.net/ not working #2562
Fix match theme by handle with canonical prefix https://hdl.handle.net/ not working #2562
Conversation
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.
@alexandrevryghem : Gave this a review/test today (along with the backend PR). Overall, it looks good and it works as described. I've tested all the various theme configurations, including handle
(both for hdl.handle.net and dspace.ui based), regex
, and uuid
. They all work well for me.
However, when running in Production mode (yarn build:prod; yarn serve:ssr
), I'm seeing errors in the DevTools console of my browser. These seem to be caused by this PR as they don't occur on main
. The console errors look like this:
main.b3ecb47baf1f06fa.js:1 ERROR TypeError: Cannot read properties of undefined (reading 'responseMsToLive')
at main.b3ecb47baf1f06fa.js:1:224248
at main.b3ecb47baf1f06fa.js:1:2860890
at a._next (main.b3ecb47baf1f06fa.js:1:2856910)
at a.next (main.b3ecb47baf1f06fa.js:1:2845710)
at main.b3ecb47baf1f06fa.js:1:2859619
at a._next (main.b3ecb47baf1f06fa.js:1:2856910)
at a.next (main.b3ecb47baf1f06fa.js:1:2845710)
at main.b3ecb47baf1f06fa.js:1:2850375
at a._next (main.b3ecb47baf1f06fa.js:1:2856910)
at a.next (main.b3ecb47baf1f06fa.js:1:2845710)
This error occurs twice for me immediately on loading the homepage. It then continues to occur on other page loads as well. I haven't dug deeper than that, but obviously we'd need to find a fix before we could merge this. If you are able to find a fix in the next day or two, there's still time to get this into 7.6.1. But, ideally we'd get this merged by end of day Monday at the latest.
…prevent circular dependencies
…fined whey calling the ngOnDestroy in the ThemedComponent
7d37993
to
4e54cca
Compare
@tdonohue, it was a simple mistake this |
@alexandrevryghem : I'm testing this again right now, but still seeing the same errors in production mode ( |
@alexandrevryghem : Set this aside for a while and came back to it. It appears something was cached previously (maybe in my browser?). I'm not seeing the console error anymore. I'll do some further testing today to make sure it doesn't reappear and then (hopefully) get this merged. Thanks! |
@tdonohue, I also switched from to a different branch since yesterday & ran a |
b67cf3b
to
7529ed8
Compare
@alexandrevryghem : Is this ready for re-testing? Or is the prior error still being looked into? Thanks! |
@tdonohue it should be fixed 🤞 |
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.
👍 Thanks @alexandrevryghem ! Retested this today, and have been running this for the last hour & not noticed any errors anymore.
Also tested again that theme configs via handle
(both local URL & hdl.handle.net), regex
and uuid
all work perfectly. So, this fixes the bug and doesn't appear to have any new side effects.
Successfully created backport PR for |
Alignment with DSpace 8
References
Description
This PR fixes a problem with this regex that assumes all handle URLs are prefixed by a
handle/
. This is not the case if you set thehandle.canonical.prefix
to https://hdl.handle.net/. The solution is to retrieve thehandle.canonical.prefix
from the backend and use it inside the regex. By default thehandle.canonical.prefix
is not exposed, so you also need the backend PR in order to test this fix.Instructions for Reviewers
List of changes in this PR:
HandleService
now retrieves thehandle.canonical.prefix
from the backend. This means thatnormalizeHandle
doesn't return astring | null
anymore but anObservable<string | null>
. This means that the code using this method also needs to be refactored:CurationFormComponent
used this method, and it was fairly simple to switch toObservable
s.HandleTheme
also usesnormalizeHandle
in itsmatches
method. So this means that the return type of the matches method needs to be changed for all the classes extendingTheme
fromboolean
➜Observable<boolean>
, but this also means that more methods needed to be refactored on the two places where this method is used:updateThemeOnRouteChange$
method, the code that finds which theme should be used when you're not on a Community/Collection/Item page now still has to iterate over the list of available themes and return the first theme where itsmatches
method returnstrue
. The only difference is that it now returns anObservable<true>
instead, so I had to wrap everything in aconcatMap
to ensure that even if the second theme returns true faster than the first theme, the first matching theme is still returned. Luckily this part of the code was already in aswitchMap
, so this refactor cascade stops here.matchThemeToDSOs
also usesTheme.matches()
and had to be refactored in the same way as above. But it not only had to iterate over all the themes but for each theme, it also had to iterate over the DSO you are currently on, but also the parent DSOs. For those DSO-theme combinations, it had to useTheme.matches()
and now also had to always return the first matching theme no matter the order in which theObservables
resolve. This method was only used in theupdateThemeOnRouteChange$
method inside theswitchMap
, so the refactor cascade stops here.CommunityPageSubCommunityListComponent
&CommunityPageSubCollectionListComponent
because the destroy is sometimes called before the component has time to fully initialize. This can happen when the component initializes itself in the default theme, but then while initializing, a match is found for aUUIDTheme
/HandleTheme
/RegexTheme
so the component is destroyed before theconfig
property could be initialized.Guidance for how to test/review this PR:
custom
&dspace
CustomEagerThemeModule
insrc/themes/eager-themes.module.ts
HeaderComponent
(this will make testing easier). By default you can see that thedspace
theme uses a green bottom border, while thecustom
theme uses the base theme's header by default without that green border.handle.canonical.prefix = https://hdl.handle.net/
and ensure thatrest.properties.exposed = handle.canonical.prefix
is also present in your config.config.yml
like this:config.yml
, the same theme should also be applied to all its sub-communities, collections & items).Checklist
yarn lint
yarn check-circ-deps
)package.json
), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.