-
Notifications
You must be signed in to change notification settings - Fork 174
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
404 support for non existing paths #162
404 support for non existing paths #162
Conversation
…04-support-for-non-existing-paths
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.
Read the comments and add an example to our angular app together with a UI test.
core/src/App.html
Outdated
<Backdrop> | ||
<div class="fd-page iframeContainer" use:init="context" /> | ||
|
||
|
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.
Maybe I'm picky, but please remove unnecessary spaces ;)
core/src/App.html
Outdated
@@ -226,6 +240,20 @@ | |||
console.error('goBack() not possible, no preserved views found.'); | |||
} | |||
} | |||
|
|||
if ('luigi.displayAlert' === e.data.msg) { | |||
if (e.data.detail) { |
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.
Would be better to add one additional check to prevent from those undefined errors.
if(e.data && e.data.detail){}
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.
Also, I would vote for changing from 'detail' to 'errorMessage' or something more straight forward. Could be discussed :)
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.
errorMessage
looks good to me. message
would be even better but it'd collide with the postMessage name which is the same.
core/src/App.html
Outdated
this.set({ alertMessage: e.data.detail }); | ||
} else { | ||
console.error( | ||
'Error alert has been triggered but no message was provided in "detail" property' |
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.
Please change this message. I think it would be sufficient to just let the user know that there was an error, without telling him that the event message has not been sent properly.
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.
So what error should it be?
I thought we may use the alert somewhere else in the future and the developer may forget about the message in an event so this error would tell him directly what the problem is.
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.
I wouldn't show to the user an error saying that developers misconfigured something. That wouldn't tell the user anything, but could cause a confusion. In my opinion it would be sufficient that this information is visible in the console and in the UI there is a more generic message.
We can discuss it with the team.
core/test/utilities/helpers.spec.js
Outdated
|
||
it("should return false when pathSegments numbers don't match", async () => { | ||
const tooShortSourceUrl = 'one/two'; | ||
const tooLongSourceUrl = 'lets/change/Sinon/to/Jest/someday'; |
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.
Please change this part.
core/src/utilities/helpers.js
Outdated
return false; //we can already tell segments will not match so no loop is needed | ||
} | ||
|
||
mandatorySegments.forEach((segment, index) => { |
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.
Maybe it would be good to add an if statement before forEach loop, because if mandatorySegments
will be undefined, there will be an error.
It might not be the case for our example, but I'm rather cautious with forEach loops and things like that, they can be tricky 😉
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.
Same with this mandatorySegments.length
above etc.
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.
Good point, I'll improve it
Code looks better, but please also add an example and UI test as I requested previously. |
…04-support-for-non-existing-paths # Conflicts: # core/examples/luigi-sample-angular/src/app/project/project.component.html # core/src/App.html # core/src/services/routing.js
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.
- If I enter a url like http://localhost:4200/#/projects-does-not-exist the route is not changed. Tested for both hash and path routing. In this case we should probably redirect to localhost:4200.
- The notification still does not show the route the user wanted to navigate to .
…04-support-for-non-existing-paths
86165ab
to
d35f53c
Compare
…04-support-for-non-existing-paths # Conflicts: # core/src/services/routing.js # core/src/utilities/helpers.js # core/test/services/config.spec.js
The implementation is not working for a url with query parameters like http://localhost:4200/#/projects/pr2/settings?~foo=bar& Additionally, there are some refactorings that I would apply. I generated the following patch file you can apply it with this command: |
All things done by Jesus's patch
…04-support-for-non-existing-paths
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.
Please see my comment
@@ -86,6 +86,36 @@ export const prependOrigin = path => { | |||
return window.location.origin; | |||
}; | |||
|
|||
export const containsAllSegments = (sourceUrl, targetPathSegments) => { |
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.
There is still a bug when the user introduces a url with a trailing slash like '/projects/pr2/' (sourceUrl
param in function)
Furthermore the implementation could be simpler. My proposal is the following (unit tests are still green after refactoring)
(thanks Jesus)
…04-support-for-non-existing-paths
…04-support-for-non-existing-paths
Handle 404 when route is absolutely not found
Description
Changes proposed in this pull request:
Related issue(s)
Refeers #58