Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Add support for route guards #168

Merged

Conversation

blackbaud-brandonstirnaman
Copy link
Contributor

Adds support for canActivate/canDeactivate route guards as requested in blackbaud/skyux2#423.

I want to look at refactoring the way route generation works to use childRoutes and all for canActivateChild as well but this is a solid first step to unblock some consumers.

@codecov-io
Copy link

codecov-io commented Jun 2, 2017

Codecov Report

Merging #168 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #168   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          38     38           
  Lines         843    869   +26     
  Branches      113    116    +3     
=====================================
+ Hits          843    869   +26
Flag Coverage Δ
#builder 100% <100%> (ø) ⬆️
#runtime 100% <ø> (ø) ⬆️
#srcapp 100% <ø> (ø) ⬆️
Impacted Files Coverage Δ
lib/sky-pages-module-generator.js 100% <ø> (ø) ⬆️
lib/sky-pages-route-generator.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 018127d...14eb067. Read the comment docs.

@blackbaud-brandonstirnaman
Copy link
Contributor Author

Don't merge this yet, testing some stuff related to deep nested routes.

@blackbaud-brandonstirnaman
Copy link
Contributor Author

Nested routes work as expected. Additionally after talking with @Blackbaud-PaulCrowder I'm going to make some changes so that guard creators don't have to export default.

@blackbaud-brandonstirnaman blackbaud-brandonstirnaman force-pushed the guard-support branch 5 times, most recently from 5a82d3d to 72e4a34 Compare June 4, 2017 00:31
@blackbaud-brandonstirnaman
Copy link
Contributor Author

With latest commit on this PR, it now supports using both named exports and a default export. Ready for review @Blackbaud-BobbyEarl.

Copy link

@Blackbaud-BobbyEarl Blackbaud-BobbyEarl left a comment

Choose a reason for hiding this comment

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

LGTM. I would suggest we create additional issues for:

  • Documenting an example of this in our learn docs. @blackbaud-johnly
  • Create an e2e test to verify

@@ -114,11 +129,30 @@ function generateDefinitions(routes) {
function generateDeclarations(routes) {
const p = indent(1);
const declarations = routes
.map(r => `${p}{ path: '${r.routePath}', component: ${r.componentName} }`)
.map(r => {
let guard = r.guardPath && r.guardName ? `require('${r.guardPath}').${r.guardName}` : '';

Choose a reason for hiding this comment

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

Was there not a way to build a list of classes to import like we do in the code where we detect components and add them to the declarations of the NgModule? I'd like to use that same pattern if at all possible. Same for the generateProviders method on line 148.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. gimme a few minutes.. be ready to review again soon! :)

}
});

expect(routes.declarations).toContain(

Choose a reason for hiding this comment

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

This is still checking for .default from your previous implementation. Should this be .Guard instead? There are other instances later in this file, so be sure to address them as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope. Its a separate test to verify that .default still works. Basically both paths are explicitly supported now. The test above this one uses the non-default, named class approach with .Guard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing support for export default entirely now as part of refactoring to use import instead of require

edit: or maybe not. ;)

@Blackbaud-BobbyEarl Blackbaud-BobbyEarl merged commit db06c56 into blackbaud:master Jun 7, 2017
Blackbaud-DiHuynh pushed a commit to Blackbaud-DiHuynh/skyux-builder that referenced this pull request Jul 10, 2020
* Initial implementation of cert resolver.

* Added check and warning/error if certificate not found.

* Switched to using provided sslRoot

* Bugfixes and tests.

* Cleaned up eslint errors.  Fixed e2e tests.

* Using new cert installation technique in Travis and Appveyor.

* Using initial-commit branch of certs repo.

* Slight refactor to not use return in else, based on feedback.

* Updated to generated cert technique.

* Updated tests.

* Fixed tests.

* Passing in sslCert and sslKey.  Trying OSX too.

* Showing specific error.

* Debugging

* Added missing dash.

* Using install instead of trust.

* Pointing to latest version of CLI.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants