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 14 #738

Merged
merged 11 commits into from
Jan 27, 2023
Merged

Upgrade to Angular 14 #738

merged 11 commits into from
Jan 27, 2023

Conversation

jamesrwelch
Copy link
Contributor

@jamesrwelch jamesrwelch commented Jan 25, 2023

This is the final PR in the series - completing the upgrade to Angular 14. As part of this PR we also upgrade Chart JS for the summary metadata charts (I couldn't resist a minor style tweak at the same time), and upgrade a number of other packages for consistency.

The PR for upgrading Jodit should ideally be accepted before this one, so leaving it in draft mode for now.

Fixes #608
Fixes #553
Fixes #554

@jamesrwelch jamesrwelch requested a review from pjmonks January 25, 2023 09:24
@jamesrwelch jamesrwelch marked this pull request as draft January 25, 2023 09:25
@pjmonks pjmonks added this to the 7.3.0 milestone Jan 25, 2023
@pjmonks pjmonks self-assigned this Jan 25, 2023
@jamesrwelch jamesrwelch force-pushed the feature/upgrade-angular-14 branch from 76a7c63 to 0a72446 Compare January 25, 2023 12:07
@pjmonks
Copy link
Contributor

pjmonks commented Jan 25, 2023

Finding a significant issue with running the tests, almost half of them fail now because of importing ngx-jodit:

Cannot find module 'ngx-jodit' from 'src/app/shared/shared.module.ts'

    Require stack:
      src/app/shared/shared.module.ts
      src/app/testing/testing.module.ts
      src/app/testing/testing.helpers.ts
      src/app/bulk-edit/bulk-edit-profile.service.spec.ts

      63 | import { MauroItemTreeComponent } from './mauro-item-tree/mauro-item-tree.component';
      64 | import { ElementLabelComponent } from './element-label/element-label.component';
    > 65 | import { NgxJoditModule } from 'ngx-jodit';
         | ^
      66 |
      67 | @NgModule({
      68 |   declarations: [

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:491:11)
      at Object.<anonymous> (src/app/shared/shared.module.ts:65:1)

The ngx-jodit module is correctly imported into the SharedModule and can be found by Angular at runtime, but Jest cannot find it. I've tried a number of things to see if I can resolve it, the closest I thought this was was related to this issue:

JsDaddy/ngx-mask#962

ngx-jodit does not have a main field in its package.json file, so I've tried manually configuring Jest to map directly to those files, but without success. I'm at a bit of a loss on what to try next.

@pjmonks
Copy link
Contributor

pjmonks commented Jan 25, 2023

Issues with running the tests don't occur in the develop branch targeting Angular 12, so this test issue has somehow been introduced in the upgrade to Angular 14.

@jamesrwelch
Copy link
Contributor Author

I've been battling this all afternoon... I was hoping you might know the answer!
I have a few more ideas to try... I'm sure I had it working some point in the past

@jamesrwelch jamesrwelch marked this pull request as ready for review January 26, 2023 12:21
@jamesrwelch
Copy link
Contributor Author

Reverted too much... not quite there...

@jamesrwelch
Copy link
Contributor Author

Fixes #608
Fixes #553
Fixes #554

@jamesrwelch
Copy link
Contributor Author

@pjmonks I think this is now ready for review.

@pjmonks
Copy link
Contributor

pjmonks commented Jan 26, 2023

Found an issue with the Bulk Editor which seems to be new as part of this upgrade, but can be fixed separately. See issue #739

Copy link
Contributor

@pjmonks pjmonks left a comment

Choose a reason for hiding this comment

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

The branch now builds successfully. I've had a quick test clicking around the UI, only found one regression bug which I've created as a separate issue, but other than that cannot find any other issues.

I've requested one change to the config files to not break developer workflow, but once that's done I think I can approve it.

@@ -9,7 +9,7 @@
"dist-archive": "tar zcvf dist/mdm-ui-$npm_package_version$([ -z \"$MDM_UI_THEME_NAME\" ] && echo \"\" || echo \".$MDM_UI_THEME_NAME\").tgz -C dist mdm-ui-$npm_package_version$([ -z \"$MDM_UI_THEME_NAME\" ] && echo \"\" || echo \"-$MDM_UI_THEME_NAME\")",
"test": "ng test",
"test:watch": "ng test --watch",
"test-clearCache": "ng test --clearCache",
"test-clearCache": "ng test --clear-cache",
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a small problem when running npm run license-check command locally. Now that Angular 14 compiles intermediate files to a .angular cache folder, the license-check library will check in this folder too for missing license headers. This wasn't noticed on the Jenkins build I think because of the license check happening before a compile/test.

Please update the license-check-and-add-config.json file like below:

{
  "ignore": [
    ".angular"
    // ...
  ]
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fantastic catch! I've pushed this change.

@@ -34,7 +34,7 @@ import { MatFormFieldAppearance } from '@angular/material/form-field';
export class CatalogueSearchFormComponent implements OnInit {
@Input() appearance: MatFormFieldAppearance = 'outline';
@Input() routeSearchTerm?: string = '';
formGroup: FormGroup = new FormGroup({});
formGroup: UntypedFormGroup = new UntypedFormGroup({});
Copy link
Contributor

Choose a reason for hiding this comment

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

I've heard about these new typed Angular Forms, would be interesting to refactor some of these at a later date.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes - the automatic migration didn't work for me so I had to figure this out myself, and decided Untyped versions would be best for now. But I've added a ticket #742 for sorting it out later

@jamesrwelch
Copy link
Contributor Author

Thanks again for your really thorough reviewing on this, @pjmonks !

@pjmonks pjmonks self-requested a review January 27, 2023 09:54
Copy link
Contributor

@pjmonks pjmonks left a comment

Choose a reason for hiding this comment

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

I think this is in a great state to accept now, nice one! 🎉 I'll approve the PR but will give you the honour of merging 🏆

@jamesrwelch
Copy link
Contributor Author

@pjmonks Oh you're too kind! Thanks!

@jamesrwelch jamesrwelch merged commit f315cfb into develop Jan 27, 2023
@jamesrwelch jamesrwelch deleted the feature/upgrade-angular-14 branch January 27, 2023 10:02
@julianpoemp
Copy link

Hi,
I'm the developer of ngx-jodit and found out, that you were using ngx-jodit, but reverted back to jodit-angular. I just want to let you know that you can use Jodit v4 with ESM now and it supports template driven or reactive forms now (see demo) 🚀 . Feel free to test it :) . If there are any issues please create on on the issues page. 😄 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Merged to Develop / Waiting to release
3 participants