Skip to content

[DURACOM-353] fix orejime callbacks#4225

Merged
tdonohue merged 2 commits intoDSpace:mainfrom
4Science:task/main/DURACOM-353
Apr 28, 2025
Merged

[DURACOM-353] fix orejime callbacks#4225
tdonohue merged 2 commits intoDSpace:mainfrom
4Science:task/main/DURACOM-353

Conversation

@AndreaBarbasso
Copy link
Copy Markdown
Contributor

References

Description

Since orejime does not have a "global" callback property, we need to apply the method that updates user preferences to each app in orejime's config, and of course we need to call any custom callback already there for each app.

Instructions for Reviewers

List of changes in this PR:

  • Created the applyUpdateSettingsCallbackToApps method. This method changes the callback property of each app by calling the method that updates the saved user settings, and then calls any callback function set to that app in config.
  • Wrote tests.

To test this PR, you need to add a non-mandatory cookie to the orejime configuration and then enable/disable that cookie. Changes should be persisted on the REST side, and any original callback should be called.

Checklist

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes ESLint validation using npm run lint
  • My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • My PR aligns with Accessibility guidelines if it makes changes to the user interface.
  • My PR uses i18n (internationalization) keys instead of hardcoded English text, to allow for translations.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

@tdonohue tdonohue self-requested a review April 22, 2025 13:58
@tdonohue tdonohue added bug 1 APPROVAL pull request only requires a single approval to merge labels Apr 22, 2025
@tdonohue tdonohue moved this to 👍 Reviewer Approved in DSpace 9.0 Release Apr 22, 2025
@tdonohue tdonohue moved this from 👍 Reviewer Approved to 🙋 Needs Reviewers Assigned in DSpace 9.0 Release Apr 22, 2025
@tdonohue tdonohue added this to the 9.0 milestone Apr 22, 2025
Copy link
Copy Markdown
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndreaBarbasso : Thanks for this PR. Overall, it is working well. I can verify that, after logging in, if I save the Cookie Settings, I'll see a PATCH request to change those settings in my account. If I then logout & login again, those same Cookie settings are restored.

However, I did find a small bug. If you run this in Production mode (npm run build:prod && npm run serve:ssr), then you'll see a TypeError appear on the homepage if you are not logged in:

ERROR TypeError: Cannot read properties of undefined (reading 'uuid')
    at d.updateSettingsForUsers (main.05f4e55b85d89082.js:1:1789348)
    at main.05f4e55b85d89082.js:1:1787004
    at F (main.05f4e55b85d89082.js:1:2220475)
    at X (main.05f4e55b85d89082.js:1:2220708)
    at W (main.05f4e55b85d89082.js:1:2220593)
    at bt.<computed> (polyfills.de6e35a366b9582f.js:1:12038)
    at Z.invokeTask (polyfills.de6e35a366b9582f.js:1:21035)
    at Object.onInvokeTask (main.05f4e55b85d89082.js:1:2570651)
    at Z.invokeTask (polyfills.de6e35a366b9582f.js:1:20954)
    at wt.runTask (polyfills.de6e35a366b9582f.js:1:16205)

To Reproduce this bug:

  1. Install this PR in production mode
  2. Open your browser's DevTools & watch the Console
  3. Access the homepage anonymously. The TypeError will appear because no one is logged in.

Once that minor bug is fixed, I'm +1 this PR. Looks good!

@github-project-automation github-project-automation Bot moved this from 🙋 Needs Reviewers Assigned to 👀 Under Review in DSpace 9.0 Release Apr 22, 2025
@tdonohue
Copy link
Copy Markdown
Member

@AndreaBarbasso : If you could find time to fix the TypeError in this PR, I'd like to get this merged as soon as possible, especially since it's holding up testing/merging of both #3889 and #3613

@AndreaBarbasso
Copy link
Copy Markdown
Contributor Author

@tdonohue, sorry for leaving this hanging, but a one-two combo of sick leave and Italian bank holidays happened!

I pushed a fix that resolves the error you encountered. Thanks for finding it!

Copy link
Copy Markdown
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks @AndreaBarbasso ! This is now working perfectly. Code looks good too

@github-project-automation github-project-automation Bot moved this from 👀 Under Review to 👍 Reviewer Approved in DSpace 9.0 Release Apr 28, 2025
@tdonohue tdonohue merged commit f107573 into DSpace:main Apr 28, 2025
15 checks passed
@github-project-automation github-project-automation Bot moved this from 👍 Reviewer Approved to ✅ Done in DSpace 9.0 Release Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 APPROVAL pull request only requires a single approval to merge bug

Projects

No open projects
Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Cookies are no longer stored in user metadata when changed.

2 participants