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

Bug: theme matching by handle doesn't work, but uuid does #2348

Closed
misilot opened this issue Jun 30, 2023 · 25 comments · Fixed by #2562 or DSpace/DSpace#9162
Closed

Bug: theme matching by handle doesn't work, but uuid does #2348

misilot opened this issue Jun 30, 2023 · 25 comments · Fixed by #2562 or DSpace/DSpace#9162
Assignees
Labels
bug claimed: Atmire Atmire team is working on this issue & will contribute back help wanted Needs a volunteer to claim to move forward high priority themes
Milestone

Comments

@misilot
Copy link
Contributor

misilot commented Jun 30, 2023

Describe the bug
Matching on a collection handle does not appear to work for a collection, but using a UUID does work (except for the duplicated elements #2346)

To Reproduce
Steps to reproduce the behavior:

themes:
  - name: etdr
    extends: krex
    handle: '2097/4'
    # uuid: '6d684812-6d29-4564-8b51-f5670957936b'

  # default theme, based on DSpace
  - name: krex

This works though

themes:
  - name: etdr
    extends: krex
    uuid: '6d684812-6d29-4564-8b51-f5670957936b'

  # default theme, based on DSpace
  - name: krex

Expected behavior
Theming should be applied to the collection items when using the handle, or the uuid.

Related work

@misilot misilot added bug needs triage New issue needs triage and/or scheduling labels Jun 30, 2023
@tdonohue tdonohue added help wanted Needs a volunteer to claim to move forward high priority themes and removed needs triage New issue needs triage and/or scheduling labels Jun 30, 2023
@alexandrevryghem
Copy link
Member

I tried the same with this config, and it worked (I also had to uncomment the CustomEagerThemeModule in src/themes/eager-themes.module.ts):

themes:
  - name: custom
    extends: dspace
    handle: '123456789/2'
  - name: dspace

Could you maybe go over these steps and check that your theme is correctly set up

@misilot
Copy link
Contributor Author

misilot commented Jul 1, 2023

@alexandrevryghem I believe it's setup correctly? The copy of dspace to krex seems to work (https://github.com/kstatelibrariesit/dspace-angular/tree/etdr-theme/src/themes/krex) but not the subtheme etdr

I made the repo public incase it would be easier to see where I might have messed up

@alexandrevryghem alexandrevryghem self-assigned this Jul 24, 2023
@alexandrevryghem alexandrevryghem added claimed: Atmire Atmire team is working on this issue & will contribute back and removed help wanted Needs a volunteer to claim to move forward labels Jul 24, 2023
@alexandrevryghem
Copy link
Member

@misilot sorry for the late response I was on vacation. Can you try rebasing/merging your branch with the branch from the linked PR and check that both issues are now resolved?

@misilot
Copy link
Contributor Author

misilot commented Jul 25, 2023

@alexandrevryghem I was trying to apply this to the 7.6 branch I have, but it doesn't apply cleanly.

git am --show-current-patch=diff
---
 src/app/shared/theme-support/themed.component.ts | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/app/shared/theme-support/themed.component.ts b/src/app/shared/theme-support/themed.component.ts
index 2ff0713f460..920fbba6e56 100644
--- a/src/app/shared/theme-support/themed.component.ts
+++ b/src/app/shared/theme-support/themed.component.ts
@@ -1,10 +1,10 @@
 import {
+  AfterViewInit,
   Component,
   ViewChild,
   ViewContainerRef,
   ComponentRef,
   SimpleChanges,
-  OnInit,
   OnDestroy,
   ComponentFactoryResolver,
   ChangeDetectorRef,
@@ -21,7 +21,7 @@ import { GenericConstructor } from '../../core/shared/generic-constructor';
   styleUrls: ['./themed.component.scss'],
   templateUrl: './themed.component.html',
 })
-export abstract class ThemedComponent<T> implements OnInit, OnDestroy, OnChanges {
+export abstract class ThemedComponent<T> implements AfterViewInit, OnDestroy, OnChanges {
   @ViewChild('vcr', { read: ViewContainerRef }) vcr: ViewContainerRef;
   protected compRef: ComponentRef<T>;

@@ -49,7 +49,7 @@ export abstract class ThemedComponent<T> implements OnInit, OnDestroy, OnChanges
     }
   }

-  ngOnInit(): void {
+  ngAfterViewInit(): void {
     this.destroyComponentInstance();
     this.themeSub = this.themeService.getThemeName$().subscribe(() => {
       this.renderComponentInstance();

is what git am isn't happy about

@tdonohue tdonohue linked a pull request Jul 25, 2023 that will close this issue
8 tasks
@alexandrevryghem
Copy link
Member

I just tried merging in themed-component-fixes-main into etdr-theme and it succeeded without any merge conflicts

 git merge themed-component-fixes-main                                                                                                                                                                  
 Merge made by the 'ort' strategy.
 src/app/shared/theme-support/themed.component.ts | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

@misilot
Copy link
Contributor Author

misilot commented Jul 25, 2023

Thanks @alexandrevryghem so

  - name: etdr
    extends: krex
    uuid: '6d684812-6d29-4564-8b51-f5670957936b'

appears to work, but not

  - name: etdr
    extends: krex
    handle: '2097/4'

However, the duplicating theme element issue did go away!

@alexandrevryghem
Copy link
Member

@misilot I couldn't reproduce this error. I tried with both dynamically created components like UntypedComponent and standard themable components like HeaderNavbarWrapperComponent, and I still wasn't able to reproduced this error I also tried running it in both prod and dev mode without any luck. Can you provide more info about how you noticed that it didn't work like for which component doesn't it work on your branch and what change would you expect where.

@misilot
Copy link
Contributor Author

misilot commented Jul 26, 2023

@alexandrevryghem

So I'm trying to add these additional metadata specific components to specific communities (the etdr theme)
https://github.com/kstatelibrariesit/dspace-angular/blob/etdr-theme/src/themes/etdr/app/item-page/simple/item-types/untyped-item/untyped-item.component.html#L65-L75

If I use in my config.yml file

themes:
  # Specific Item
  # - name: etdr
  #   extends: krex
  #   handle: '2097/43295'

  - name: etdr
    extends: krex
    handle: '2097/4'

  # default theme, based on DSpace
  - name: krex
    headTags:
      # Insert <link rel="icon" href="assets/krex/images/favicons/favicon.ico" sizes="any"/> into the <head> of the page.
      - tagName: link
        attributes:
          rel: icon
          href: assets/krex/images/favicons/favicon.ico
          sizes: any

I get the following results (not working)

image

However if I use

themes:
  - name: etdr
    extends: krex
    uuid: '6d684812-6d29-4564-8b51-f5670957936b'

  # default theme, based on DSpace
  - name: krex
    headTags:
      # Insert <link rel="icon" href="assets/krex/images/favicons/favicon.ico" sizes="any"/> into the <head> of the page.
      - tagName: link
        attributes:
          rel: icon
          href: assets/krex/images/favicons/favicon.ico
          sizes: any

It does work as expected. (The duplicative collections was me, since I was trying to prove something was working when I started down customizing it)

image

@alexandrevryghem
Copy link
Member

@misilot I used your branch again to test it and I'm still not able to reproduce the error, I asked a colleague (@nona-luypaert) to also test it on your branch to be sure I didn't miss anything and she also wasn't able to reproduce your error. Have you already tried running yarn clean & removing the .angular folder?
https://github.com/DSpace/dspace-angular/assets/43750381/ccdffd5a-ccb0-497c-95c0-6c77a87b22e0

@alexandrevryghem alexandrevryghem added the cannot reproduce Unable to reproduce at this time, so the ticket either needs more information or needs closing label Jul 27, 2023
@misilot
Copy link
Contributor Author

misilot commented Aug 1, 2023

@alexandrevryghem I ran docker system prune to purge all of the build components, and I am still seeing it when I target a collection by the handle. Not sure if there is anything else I can test?

@alexandrevryghem
Copy link
Member

Have you also tried running it locally using yarn start:dev/yarn start:prod, maybe it's docker related?

@misilot
Copy link
Contributor Author

misilot commented Aug 1, 2023 via email

@misilot
Copy link
Contributor Author

misilot commented Aug 1, 2023

@alexandrevryghem So I did the following

  • yarn clean
  • rm -Rf .angular/
  • yarn install
  • yarn build:prod
  • rsync -avzh /klib/build/dspace-angular/dist/ /klib/app/dspace-ui-deploy/dist/ --delete
  • cd /klib/app/dspace-ui-deploy/
  • pm2 restart dspace-ui.json (with handle filter for the etdr theme configured)
  • Tested (did not work)
  • modifed config/config.yml to enable the uuid filter
  • Tested (did work)

@misilot
Copy link
Contributor Author

misilot commented Aug 24, 2023

@tdonohue I see that PR #2395 is linked to this. That PR addresses #2346

@alexandrevryghem alexandrevryghem removed their assignment Aug 24, 2023
@alexandrevryghem alexandrevryghem removed the claimed: Atmire Atmire team is working on this issue & will contribute back label Aug 24, 2023
@tdonohue tdonohue added the help wanted Needs a volunteer to claim to move forward label Aug 24, 2023
@alanorth
Copy link
Contributor

I confirm that matching by handle in DSpace 7.6 doesn't work for me either.

@alexandrevryghem
Copy link
Member

Hey @alanorth, are you able to reproduce it on the main branch or were you only able to reproduce it in your project? And if you were able to reproduce it on main, how do you run your dspace with yarn start:dev/yarn start:prod or with pm2? Because I wasn't able to reproduce it 😅

@misilot
Copy link
Contributor Author

misilot commented Sep 28, 2023 via email

@alanorth
Copy link
Contributor

Hi, I was testing via yarn start:dev, but I just tried via yarn start (production mode) and it definitely doesn't work for me on 7.6.

@alexandrevryghem
Copy link
Member

@alanorth could you maybe give me your config.yml that you used on the main branch

@alanorth
Copy link
Contributor

@alexandrevryghem I was working on DSpace 7.6, not main. But sure, this is my config.dev.yaml:

https://gist.github.com/alanorth/4d6e9a1db7a09567fd588d47ec34d8f9

@alexandrevryghem alexandrevryghem added claimed: Atmire Atmire team is working on this issue & will contribute back and removed cannot reproduce Unable to reproduce at this time, so the ticket either needs more information or needs closing labels Oct 13, 2023
@alexandrevryghem alexandrevryghem self-assigned this Oct 13, 2023
@alexandrevryghem
Copy link
Member

Good news, I was able to reproduce the error locally. The error only happens for clients who change their handle.canonical.prefix, because this regex expects all handle urls to have handle in front of the handle, but this means that urls like http://hdl.handle.net/xxx/yyy currently aren't supported. I will provide a PR for this

@misilot
Copy link
Contributor Author

misilot commented Oct 13, 2023

@alexandrevryghem glad that might fix the issue, but not sure it is the case since we access the url's like https://fqdn/handle/2097/4

Our handle.canonical.prefix=https://hdl.handle.net/ is though 🤷

@alexandrevryghem
Copy link
Member

The handle that is used to find the correct theme isn't the one from the url, but the one in the metadata of the Community/Collection/Item. So in your case that regex will try to retrieve the handle from the url https://hdl.handle.net/2097/4. If you already want to test it on your local machine you can temporarily update the handle of your collection and replace https://hdl.handle.net/ with https://fqdn/handle/ and then you should be able to see the correct theme again.

@alexandrevryghem
Copy link
Member

Hey @misilot, I apologize for the delay in finishing the PR, but my last few weeks have been quite busy 😅, but I was able to finish it today could you maybe take a look and check if it fixes your issue?

@tdonohue tdonohue added this to the 7.6.1 milestone Nov 1, 2023
@misilot
Copy link
Contributor Author

misilot commented Nov 29, 2023

Thank you for fixing this @alexandrevryghem!

dsteelma-umd added a commit to dsteelma-umd/mdsoar-angular that referenced this issue Jan 24, 2024
Modified the identifiers used to associated a community with an
institutional theme from handle identifiers to UUIDs.

This is a workaround for the the stock DSpace bug described in
DSpace/dspace-angular#2348
in which handles may not be properly parsed.

The stock DSpace bug is expected to be fixed in a 7.6.x update,
so simply commenting out the handles so that can be easily restored
when the bug is fixed.

Updated the "CommunityThemes.md" documentation to use UUID instead of
handle identifiers.

https://umd-dit.atlassian.net/browse/LIBCIR-372
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment