-
Notifications
You must be signed in to change notification settings - Fork 111
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
Jamie/4699 frontend update deps #4835
Conversation
Deploy preview for chef-automate processing. Building with commit ed3b4a8 https://app.netlify.com/sites/chef-automate/deploys/605c01fe6d047d000960c2c9 |
@@ -1,6 +1,6 @@ | |||
import { Injectable } from '@angular/core'; | |||
import { HttpErrorResponse } from '@angular/common/http'; | |||
import { Actions, Effect, ofType } from '@ngrx/effects'; | |||
import { Actions, createEffect, ofType } from '@ngrx/effects'; |
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.
the @Effect
decorator has been deprecated in favor of a more "React hooks" style of composition.
Deprecation notice: https://ngrx.io/api/effects/Effect
Usage notes for createEffect
: https://ngrx.io/api/effects/createEffect#usage-notes
getAllTokens$ = createEffect(() => { | ||
return this.actions$.pipe(ofType<GetAllTokens>(ApiTokenActionTypes.GET_ALL), | ||
mergeMap((_action) => | ||
this.requests.getAll().pipe( | ||
map(resp => new GetAllTokensSuccess(resp)), | ||
catchError((error: HttpErrorResponse) => of(new GetAllTokensFailure(error)))) | ||
)); | ||
}); |
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.
You'll see this new format used throughout all our effects files moving forward and its how we should continue to compose effects.
34b19e7
to
c9f39a7
Compare
@@ -151,7 +151,7 @@ export class ServiceGroupsRequests { | |||
}, searchParam, filters); | |||
} | |||
|
|||
public deleteServicesById(listOfIds: number[]): any { | |||
public deleteServicesById(listOfIds: number[]): Observable<any> { |
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 to @msorens for helping realize the error in this related effect was coming from the lack of an Observable signature. The should be updated to be more specific as well
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.
Looking into this more, I'm going to investigate the proper type in a new branch so as not to hold up these dependencies.
@@ -32,6 +32,7 @@ describe('ClientDetailsComponent', () => { | |||
MockComponent({ selector: 'chef-tr' }), | |||
MockComponent({ selector: 'chef-th' }), | |||
MockComponent({ selector: 'chef-td' }), | |||
MockComponent({ selector: 'chef-snippet', inputs: ['code'] }), |
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.
Some cleanup of missing mock-selectors. I'm actually surprised these made it through bulidkite.
@@ -46,7 +47,8 @@ describe('DataBagsListComponent', () => { | |||
ReactiveFormsModule, | |||
RouterTestingModule, | |||
StoreModule.forRoot(ngrxReducers, { runtimeChecks }) | |||
] | |||
], | |||
schemas: [CUSTOM_ELEMENTS_SCHEMA] |
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.
Several test files were missing the CUSTOM_ELEMENTS_SCHEMA
required for our custom components and as a result were throwing linting errors.
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.
Nice work!
-
Should add to your "done" criteria the fact that
npm install
should report "found 0 vulnerabilities" -- that is not always the case and should be celebrated!! -
Should mention in the PR preamble that wallaby is reporting 2 errors and if there are plans to resolve those.
-
Should mention that the TSLint deprecation warnings will be dealt with in a separate issue.
-
Should also mention that
make serve
should display no errors or warnings. Currently, it does have one (I would add this as a new issue to the Bringing dependencies up-to-date epic.)
Option "baseHref" is deprecated: Use the "baseHref" option in the browser builder instead.
latestOptions$ = createEffect(() => | ||
observableInterval(1000 * this.POLLING_INTERVAL_IN_SECONDS).pipe( | ||
mergeMap(this.loadOptionsAction$()))); | ||
|
||
// Fast-initialize project filter just from local storage | ||
@Effect() | ||
initOptions$ = this.actions$.pipe( | ||
initOptions$ = createEffect(() => { | ||
return this.actions$.pipe( |
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.
Let's be consistent: as you have it here, there are two equivalent syntaxes for writing the createEffect
expression. I want to urge the more concise format (L33). No need to introduce a separate block of code (L38-39) when there is just a single return. (Apologies that that does make a lot of editing for you. 😁 )
ofType<SaveOptions>(ProjectsFilterActionTypes.SAVE_OPTIONS), | ||
tap(({ payload }) => this.projectsFilter.storeOptions(payload)) | ||
); | ||
), { dispatch: false }); |
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.
Why was this dispatch
added? What does it do?
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.
We need to use {dispatch: false}
whenever our effect isn't returning an action so that we don't cause an infinite loop.
Non-dispatching Effects
Sometimes you don't want effects to dispatch an action, for example when you only want to log or navigate based on an incoming action. But when an effect does not dispatch another action, the browser will crash because the effect is both 'subscribing' to and 'dispatching' the exact same action, causing an infinite loop. To prevent this, add { dispatch: false } to the createEffect function as the second argument.
In this case, dispatch wasn't added here, it already existed but it now looks a little different in the new style of writing effects.
In the old format it was composed as
@Effect( {dispatch: false} )
in the new style
createEffect( () => some code, {dispatch: false})
@@ -55,17 +55,9 @@ Certain packages in package.json are constrained for the reasons detailed here. | |||
At any future moment though, the reasons for constraint here could be invalidated, so this should be updated as needed when package.json is updated. | |||
While it is problematic to document this information due to the maintenance burden, the value of having this in one place outweighs that burden. | |||
|
|||
### Packages @ngrx/* =10.1.0 | |||
### Package typescript: ^4.0.7 |
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.
Nice--thanks for keeping these docs current!
@@ -57,7 +57,7 @@ export class Jwt { | |||
static parseLicenseToken(token: string): LicenseToken | null { | |||
let tok: LicenseToken; | |||
try { | |||
tok = jwtDecode(token); | |||
tok = jwt_decode(token); |
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.
Is this change still causing errors to be reported by Wallaby?
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.
yeah it is, I meant to send them a note last week but didn't. I'll get one out to them today.
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.
The wallaby errors have since disappeared 🤷
80cb092
to
215b42b
Compare
|
||
@Effect() | ||
resetKeyClient$ = this.actions$.pipe( | ||
resetKeyClient$ = createEffect(() => this.actions$.pipe( |
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.
[nitpick] Of the 364 effects, there are just 14 (like this one) that do not have a line break after the =>
. 😉
215b42b
to
a5dac92
Compare
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Unfortunately unable to use auto migrater, hitting an exception error Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Thanks to new createEffect and Typescript, a should be non dispatching effect was found and updated. Signed-off-by: seajamied <jdegnan@chef.io>
dispatch false was the wrong approach - obvious by the fact that we needed to dispatch an action. However it appears we did not have a need to use mergeMap and instead should simply be merging. Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
This is the latest available to these packages Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Per documentation https://www.npmjs.com/package/zone.js\?activeTab\=readme a breaking change was introduced after v0.11.1, we are safe to upgrade by importing as 'zone.js/dist/zone' which we are doing in polyfills.ts Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Initially I tought the package upgrade was causing errors but after making the required changes, I think what is actually happening is that it helped expose some bad tests or function in signin.component.ts. Interestingly enough, running 'make unit' shows that all tests are passing Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
The error is not infact fixed here, mergeMap seems to be required however there is a Type error that needs more investigation. The 'old' way works but the new way throws a type error Signed-off-by: seajamied <jdegnan@chef.io>
This fixed the effect error - thanks to Michael Sorens. This should be updated from an 'any' response as well. Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
Signed-off-by: seajamied <jdegnan@chef.io>
6c08fe6
to
ed3b4a8
Compare
🔩 Description: What code changed, and why?
As the dependencies we utilize and rely on within our codebase are updated and improved, its important that we continue to stay ahead of deprecations, breaking changes, and best security. We periodically examine where our dependencies are falling behind and update as necessary.
We are currently outdated in a number of packages: see image in description of #4699
after update from this branch, running
npm outdated
will list the following exceptions documented in README.md⛓️ Related Resources
Adresses #4699
👍 Definition of Done
running
ng build
returns no errorsrunning
make lint
returns no errors with exception listed belowrunning
make unit
returns no errorsAll automate-ui frontend dependencies are as up to date as possible with the exception of those documented in README.md.
👟 How to Build and Test the Change
option 1: - Delete your node files and perform a new installation
cd into automate-ui folder
rm -rf node_modules && npm install
please remember to run this again after switching back to whatever branch you are working on
option 2 - Save your node modules elsewhere to reuse after
cd into automate-ui folder
mv node_modules /location/to/save/your/old/node_modules
npm install
After the new install
ng build
make unit
make serve
-> this will return a warning for baseHref which is being handled in #4865All should return no errors
running
npm install
should report 0 vulnerabilitiesIt is also highly appreciated if each tester would spend some time clicking around the application, keeping an eye out for any new console errors that my expose themselves. Thankfully, almost all of the dependency updates are of a minor version so I don't expect anything much to pop up.
Note regarding TSLint Deprecation warnings
TSLint Deprecation warnings will be handled in #4700
Note for those using WallabyJS
Wallaby is currently picking up two errors in
jwt.ts
. It appears that these are false positives as our signin is still working as expected. I am reaching out to the Wallaby team for assistance in resolving.✅ Checklist
📷 Screenshots, if applicable