question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Replace hardcoded pageLabels in logic with semantic urls from config

See original GitHub issue

In few places we have hardcoded pageLabels / pageContext.ids of CMS routes:

  • logout guard - '/logout'
  • cms page guard - '/not-found'
  • router reducer - '/login', '/login/register'

We need to get them from the routes configuration.

Now we have only a method UrlService.generateUrl() returns an array of url commands to be passed to Angular’s routerLink or router.navigate. This is not what we simply need here. We just need string with a page label for given named route.

To build a full bullet-proof solution we need considering:

  • passing parameters
  • URI-encoding segments of url
  • supporting aliases
  • supporting relative links

Or we can simply build a method that returns just a string from configuration (with leading slash).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
KateChuencommented, Jun 4, 2019

Tested on dev2.

  • Configuring the logout route works. Going to /my-logout logs me out now and redirects me to the homepage (before I would stay logged in and get a not-found page)
  • Configuring the notFound route works. Going to /my-404 displays the “NotFound” page. 404NotFoundRoute
0reactions
Platonncommented, Jun 3, 2019

QA steps

1. Logout is configurable

  • in app.module configure the logout route:
routing: {
  routes: {
    logout: { paths: ['my-logout'] }
  }
}
  • login in the application
  • type in the navigaiton bar /my-logout
  • verify that you are logged out

2. ‘Page not found’ route is configurable

  • in app.module configure notFound route:
routing: {
  routes: {
    notFound: { paths: ['my-404'] }
  }
}
  • in the backoffice change the page label /not-found to /my-404
  • type in the navigaiton bar /my-404
  • verify you see the ‘Not found’ page
Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I handle hard coded URL, database configuration in ...
First, move all your config options into a configuration file (or files). Use a language agnostic format such as JSON or YAML.
Read more >
Extend Cart Save and Validation Logic in Fewer Steps
This logic class validates and saves the cart, and you can easily extend this ... To revert, change the Use Cart Page 2.0...
Read more >
Javascript Setup - Yext Hitchhikers
To start, this template won't display anything – just a hardcoded string (which we'll replace later on). We'll place this within our onReady...
Read more >
PyMuPDF Documentation
cd PyMuPDF && python setup.py install. This will automatically download a specific hard-coded MuPDF source release, and build it into ...
Read more >
Changelog - Doxygen Manual
The specific options DOT_FONTNAME and DOT_FONTSIZE have been replaced be more generic ... Make templated HTML output more similar to hardcoded output.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found