Skip to content

Commit

Permalink
added a route guard that prevents the user from going to the root Mes…
Browse files Browse the repository at this point in the history
…hes page. it will send them to the Mesh child route and default to showing all meshes.
  • Loading branch information
Daryn St. Pierre committed Apr 17, 2020
1 parent cc6fb05 commit 0401b91
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,18 @@ export default (store) => {
/**
* This will make sure that the Meshes page displays all meshes
* if the user happens to go to the bare `/meshes` url with no
* query on the end of it for drilling down by Mesh.
* query on the end of it.
*/
// router.beforeEach((to, from, next) => {
// console.log(to.query)

// if (to.name === 'all-meshes' && !to.query.mesh) {
// next({
// name: 'all-meshes',
// query: { mesh: 'all' }
// })
// } else {
// next()
// }
// })
router.beforeEach((to, from, next) => {
if (to.name === 'all-meshes') {
next({
name: 'mesh-child',
params: { mesh: 'all' }
})
} else {
next()
}
})

/**
* A route guard for handling the onboarding process. If the user hasn't gone
Expand Down
2 changes: 2 additions & 0 deletions src/views/Entities/Meshes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ export default {
const mesh = this.$route.params.mesh
console.log(mesh)
const endpoint = (mesh === 'all' || !mesh)
? this.$api.getAllMeshes()
: this.$api.getMesh(mesh)
Expand Down

0 comments on commit 0401b91

Please sign in to comment.