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

Child route support, root guard support #177

Merged

Conversation

blackbaud-brandonstirnaman
Copy link
Contributor

PR implements child routing based on the design @Blackbaud-PaulCrowder and I discussed.

A directory prefixed with # such as src/app/about/#child would create a child-route underneath /about which can be affected by canActivateChild guards as well as used by controls that implement router-outlet in their template such as the future tab control (or currently microedge contrib tab control).

A directory without the prefix but underneath a child route such as src/app/about/#child/top-level will break out and become a top level route that cannot be affected by canActivateChild guards and will not participate in router-outlet.

All other routes will continue to be top-level. Routes continue to only be created if an index.html is provided.

Additionally now that we have child routing, I've also implemented a top-level route that makes it very simple to declare an index.guard.ts next to src/app/index.html and have a guard that affects being able to load anything within the SPA. This should be the preferred method for locking down SPAs in future.

Added several e2e tests to validate the functionality as well as unit tests for the route generation.

@codecov-io
Copy link

codecov-io commented Jun 11, 2017

Codecov Report

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

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #177   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          38     38           
  Lines         871    928   +57     
  Branches      116    130   +14     
=====================================
+ Hits          871    928   +57
Flag Coverage Δ
#builder 100% <100%> (ø) ⬆️
#runtime 100% <ø> (ø) ⬆️
#srcapp 100% <ø> (ø) ⬆️
Impacted Files Coverage Δ
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 1686175...7a10783. Read the comment docs.

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.

Just a few random comments, but this still LGTM.

}

/**
* Verify directory exists in src/app folder

Choose a reason for hiding this comment

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

Same comment as the verifyAppFolder method.

@@ -106,6 +106,14 @@ function generateRoutes(skyAppConfig) {
.sync(path.join(skyAppConfig.runtime.srcPath, skyAppConfig.runtime.routesPattern))
.map(file => parseFileIntoEntity(skyAppConfig, file, counter++));

// Add a root component that will become the wrapper for all the others
entities.push({
routePath: ['~'], // we need a non-empty route path so it won't be merged later

Choose a reason for hiding this comment

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

Not that I would expect it, but any concern if a user has a ~ folder?

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