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

Upgrade to angular 16 #2871

Merged
merged 78 commits into from
Apr 4, 2024
Merged

Upgrade to angular 16 #2871

merged 78 commits into from
Apr 4, 2024

Conversation

atarix83
Copy link
Contributor

@atarix83 atarix83 commented Mar 21, 2024

References

Description

This PR provide upgrade to angular 16

Instructions for Reviewers

List of changes in this PR:

  • since view engine libraries are no longer supported we had to :
    • remove ngx-sortablej and replaced it by usig the angular cdk drag/drop module.
    • remove markdown-it-mathjax3. Since this was only a plugin to support the MathJax for the markdown-it library we decide to use directly the MathJax library. It's not a direct dependency but we've implemented a service for injecting the script by retrieving it from a CDN. In this way we don't need to add to the bundle a so heavy dependency.
  • Node 16 is no longer supported so i've also changed the github workflow in order to run CI for version 18 and 20 of node

Include guidance for how to test or review your PR.
Review this PR by running the application (against sandbox rest server) to verify everything works properly as the current sandbox environment.

Checklist

This checklist provides a reminder of what we are going to look for when reviewing your PR. You need not complete this checklist prior to creating your PR (draft PRs are always welcome). If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!

  • 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 yarn lint
  • My PR doesn't introduce circular dependencies (verified via yarn 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.
  • 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.

Andrea Barbasso and others added 30 commits February 12, 2024 16:09
DURACOM-238 update ng2 file upload

Approved-by: Andrea Barbasso
# Conflicts:
#	package.json
#	src/app/access-control/epeople-registry/eperson-resolver.service.ts
#	src/app/admin/admin-registries/bitstream-formats/bitstream-formats.resolver.ts
#	src/app/admin/admin-search-page/admin-search-results/admin-search-result-grid-element/item-search-result/item-admin-search-result-grid-element.component.ts
#	src/app/admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/workflow-item/workflow-item-search-result-admin-workflow-grid-element.component.ts
#	src/app/admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/workspace-item/workspace-item-search-result-admin-workflow-grid-element.component.ts
#	src/app/app.module.ts
#	src/app/bitstream-page/bitstream-page.resolver.ts
#	src/app/bitstream-page/legacy-bitstream-url.resolver.ts
#	src/app/browse-by/browse-by-guard.ts
#	src/app/collection-page/collection-page.resolver.ts
#	src/app/collection-page/create-collection-page/create-collection-page.guard.ts
#	src/app/collection-page/edit-item-template-page/item-template-page.resolver.ts
#	src/app/community-page/community-page.resolver.ts
#	src/app/community-page/create-community-page/create-community-page.guard.ts
#	src/app/core/auth/auth-blocking.guard.ts
#	src/app/core/auth/authenticated.guard.ts
#	src/app/core/breadcrumbs/dso-breadcrumb.resolver.ts
#	src/app/core/breadcrumbs/i18n-breadcrumb.resolver.ts
#	src/app/core/breadcrumbs/quality-assurance-breadcrumb.resolver.ts
#	src/app/core/data/feature-authorization/feature-authorization-guard/dso-page-single-feature.guard.spec.ts
#	src/app/core/data/feature-authorization/feature-authorization-guard/dso-page-some-feature.guard.spec.ts
#	src/app/core/data/feature-authorization/feature-authorization-guard/dso-page-some-feature.guard.ts
#	src/app/core/data/feature-authorization/feature-authorization-guard/some-feature-authorization.guard.ts
#	src/app/core/end-user-agreement/abstract-end-user-agreement.guard.ts
#	src/app/core/feedback/feedback.guard.ts
#	src/app/core/reload/reload.guard.ts
#	src/app/core/server-check/server-check.guard.ts
#	src/app/core/submission/resolver/submission-object.resolver.ts
#	src/app/home-page/home-page.resolver.ts
#	src/app/init.service.ts
#	src/app/item-page/edit-item-page/edit-item-page.component.spec.ts
#	src/app/item-page/edit-item-page/edit-item-page.component.ts
#	src/app/item-page/item.resolver.ts
#	src/app/item-page/version-page/version.resolver.ts
#	src/app/lookup-by-id/lookup-guard.ts
#	src/app/menu.resolver.ts
#	src/app/my-dspace-page/my-dspace.guard.ts
#	src/app/process-page/process-breadcrumb.resolver.ts
#	src/app/process-page/process-page.resolver.ts
#	src/app/quality-assurance-notifications-pages/quality-assurance-events-page/quality-assurance-events-page.resolver.ts
#	src/app/quality-assurance-notifications-pages/quality-assurance-source-page-component/quality-assurance-source-data.resolver.ts
#	src/app/quality-assurance-notifications-pages/quality-assurance-source-page-component/quality-assurance-source-page-resolver.service.ts
#	src/app/quality-assurance-notifications-pages/quality-assurance-topics-page/quality-assurance-topics-page-resolver.service.ts
#	src/app/register-email-form/registration.resolver.ts
#	src/app/register-page/registration.guard.ts
#	src/app/request-copy/request-copy.resolver.ts
#	src/app/search-page/configuration-search-page.guard.ts
#	src/app/shared/context-help.directive.ts
#	src/app/shared/dso-page/dso-edit-menu.resolver.ts
#	src/app/shared/form/chips/chips.component.spec.ts
#	src/app/shared/form/chips/chips.component.ts
#	src/app/shared/form/form.module.ts
#	src/app/shared/metadata-representation/metadata-representation-loader.component.ts
#	src/app/shared/mydspace-actions/claimed-task/switcher/claimed-task-actions-loader.component.ts
#	src/app/shared/resource-policies/resolvers/resource-policy-target.resolver.ts
#	src/app/shared/resource-policies/resolvers/resource-policy.resolver.ts
#	src/app/shared/theme-support/themed.component.ts
#	src/app/shared/utils/markdown.pipe.ts
#	src/app/submission/sections/upload/accessConditions/submission-section-upload-access-conditions.component.ts
#	src/app/workflowitems-edit-page/advanced-workflow-action/advanced-workflow-actions-loader/advanced-workflow-actions-loader.component.ts
#	src/app/workflowitems-edit-page/item-from-workflow.resolver.ts
#	src/app/workflowitems-edit-page/workflow-item-page.resolver.ts
#	src/app/workspaceitems-edit-page/item-from-workspace.resolver.ts
#	src/app/workspaceitems-edit-page/workspace-item-page.resolver.ts
#	src/config/app-config.interface.ts
#	src/main.server.ts
#	src/modules/app/browser-app.module.ts
#	src/modules/app/browser-init.service.ts
#	src/modules/app/server-app.module.ts
#	src/modules/app/server-init.service.ts
#	src/ngx-translate-loaders/translate-browser.loader.ts
#	src/ngx-translate-loaders/translate-server.loader.ts
#	src/themes/custom/lazy-theme.module.ts
#	src/themes/dspace/lazy-theme.module.ts
#	yarn.lock
@atarix83
Copy link
Contributor Author

atarix83 commented Apr 2, 2024

sorry @tdonohue the PR was not yet ready to be reviewed again. Now it should if all tests pass.

@artlowel @tdonohue
Regarding the deprecated interfaces for revolvers and guards, I've applied the following changes:

  • all revolvers have been migrated in order to use functional resolvers
  • all the guards which didn't use class inheritance have been migrated in order to use functional guards
  • for all the other guards whose migration would have taken too long due to the use of class inheritance (the ones which extend SomeFeatureAuthorizationGuard class) i've use the helper function mapToCanActivate provided by Angular. I suggest to open a follow-up task for migrating all of them to functional guards if you agree

@tdonohue
Copy link
Member

tdonohue commented Apr 2, 2024

NOTE: I think the e2e test failures are now because of CSRF issues with our Cypress test suite. Now that DSpace/DSpace#9321 is merged on the backend, I think that slightly changed the CSRF behavior (the changes were caused by Spring Security 6, not by us). This difference in behavior appears to be causing Cypress to fail whenever it tries to login.

So, I think the e2e test failures here are NOT an issue with this PR as they are not reproducible in the UI. Instead it is an issue with our Cypress test suite -- I'm looking into it, but I think it can be ignored for now. If we have to we could temporarily disable the failing Cypress tests while we fix them.

Copy link
Member

@artlowel artlowel left a comment

Choose a reason for hiding this comment

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

Thanks @atarix83!

for all the other guards whose migration would have taken too long due to the use of class inheritance (the ones which extend SomeFeatureAuthorizationGuard class) i've use the helper function mapToCanActivate provided by Angular. I suggest to open a follow-up task for migrating all of them to functional guards if you agree

That's fine

One more thing though: the convention is for function names to start with a lowercase letter, and class names to start with a capital letter. All resolver-functions in this PR still start with a capital letter. If you can still fix it, that would be great, or you can add it to the ticket to clean up the guards.

@tdonohue
Copy link
Member

tdonohue commented Apr 3, 2024

@atarix83 and @artlowel : I've verified that the remaining e2e test failures in this PR also exist on main. They are also visible on this new PR from dependabot: #2881

I'm working on a fix to these issues. The problem is that the CSRF token is not being initialized properly before the e2e tests run, which causes the e2e tests to not be able to login (i.e. all tests that require authentication are failing).

The fix is to pre-initialize the CSRF token.. I'm borrowing code from #2838 (created by @artlowel 's team) and updating it to fix the issue. With these fixes, the e2e tests are working now on my end, but I'm doing some minor code cleanup & I'll create a PR for this shortly.

@atarix83
Copy link
Contributor Author

atarix83 commented Apr 3, 2024

One more thing though: the convention is for function names to start with a lowercase letter, and class names to start with a capital letter. All resolver-functions in this PR still start with a capital letter. If you can still fix it, that would be great, or you can add it to the ticket to clean up the guards.

@artlowel done

Copy link

github-actions bot commented Apr 3, 2024

Hi @atarix83,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

@tdonohue
Copy link
Member

tdonohue commented Apr 3, 2024

@atarix83 : I've just merged #2886 which fixes the e2e test errors. If you rebase this PR on the latest main (and fix the minor merge conflicts), your e2e tests should now succeed.

# Conflicts:
#	src/app/core/data/request.service.ts
#	src/modules/app/browser-app.config.ts
#	src/modules/app/server-app.config.ts
@atarix83
Copy link
Contributor Author

atarix83 commented Apr 4, 2024

@tdonohue
I've aligned this on main branch.

@artlowel @tdonohue
Looking at the #2886 i'm wondering if the code added here should be refactored in a better way.
I think the better place to do that check is the effect related to the dispatched ngrx action (https://github.com/DSpace/dspace-angular/blob/main/src/app/core/data/request.effects.ts#L43). In this way we avoid to add a nested subscription.
@artlowel do you agree? if so i can do the change in this PR

@artlowel
Copy link
Member

artlowel commented Apr 4, 2024

@atarix83 I agree that refactor would be a good idea, However I wouldn't hold up this PR to do it. I'd rather do it in a small bugfix PR next week.

Copy link
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 @atarix83 ! As discussed in today's dev meeting, I'm merging this immediately. The code looks good & I've verified it's working. The only outstanding issues are the refactor you mentioned above and the potential security vulnerability reported by CodeQL. I'm going to move those both to follow-up tickets & assign to you so that they can be fixed prior to 8.0 final.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file high priority
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Upgrade to Angular 16
4 participants