-
Notifications
You must be signed in to change notification settings - Fork 120
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
Introduce Error 404 page #1107
Merged
Merged
Introduce Error 404 page #1107
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
baafb03
Introduce Error 404 page
Quetzacoalt91 49a6f2c
feat: adjust auto height layout on each version
tblivet 44a7ffa
fix: layout spacings
tblivet 2f81190
Remove color on error logo
Quetzacoalt91 8010c3c
Introduce page to display in case of HTTP 404
Quetzacoalt91 5ef62d4
Update wording
Quetzacoalt91 631c12c
Add exit links to the post update and restore pages
Quetzacoalt91 f58ff26
Replace type inference with explicit types
Quetzacoalt91 7d065dc
Fix load of storybybook
Quetzacoalt91 dd82c13
Update constant used to define the HTTP code
Quetzacoalt91 744d37d
Invert home page condition and add icon
Quetzacoalt91 be9a57d
Update comment after rebase
Quetzacoalt91 45f4168
Add return type to loadScript
Quetzacoalt91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import DomLifecycle from '../types/DomLifecycle'; | ||
import ErrorPage404 from './error/ErrorPage404'; | ||
import PageAbstract from './PageAbstract'; | ||
|
||
export default class ErrorPage extends PageAbstract { | ||
errorPage?: DomLifecycle; | ||
|
||
constructor() { | ||
super(); | ||
|
||
if (document.getElementById('ua_error_404')) { | ||
this.errorPage = new ErrorPage404(); | ||
} | ||
} | ||
|
||
public mount = (): void => { | ||
this.errorPage?.mount(); | ||
}; | ||
|
||
public beforeDestroy = (): void => { | ||
this.errorPage?.beforeDestroy(); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import api from '../../api/RequestHandler'; | ||
import DomLifecycle from '../../types/DomLifecycle'; | ||
|
||
export default class ErrorPage404 implements DomLifecycle { | ||
isOnHomePage: boolean = false; | ||
|
||
public constructor() { | ||
this.isOnHomePage = new URLSearchParams(window.location.search).get('route') === 'home-page'; | ||
} | ||
|
||
public mount = (): void => { | ||
this.#activeActionButton.classList.remove('hidden'); | ||
this.#form.addEventListener('submit', this.#onSubmit); | ||
}; | ||
|
||
public beforeDestroy = (): void => { | ||
this.#form.removeEventListener('submit', this.#onSubmit); | ||
}; | ||
|
||
get #activeActionButton(): HTMLFormElement | HTMLAnchorElement { | ||
return this.isOnHomePage ? this.#exitButton : this.#form; | ||
} | ||
|
||
get #form(): HTMLFormElement { | ||
const form = document.forms.namedItem('home-page-form'); | ||
if (!form) { | ||
throw new Error('Form not found'); | ||
} | ||
|
||
['routeToSubmit'].forEach((data) => { | ||
if (!form.dataset[data]) { | ||
throw new Error(`Missing data ${data} from form dataset.`); | ||
} | ||
}); | ||
|
||
return form; | ||
} | ||
|
||
get #exitButton(): HTMLAnchorElement { | ||
const link = document.getElementById('exit-button'); | ||
|
||
if (!link || !(link instanceof HTMLAnchorElement)) { | ||
throw new Error('Link is not found or invalid'); | ||
} | ||
return link; | ||
} | ||
|
||
readonly #onSubmit = async (event: Event): Promise<void> => { | ||
event.preventDefault(); | ||
|
||
await api.post(this.#form.dataset.routeToSubmit!, new FormData(this.#form)); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,4 +67,7 @@ class Routes | |
|
||
/* logs */ | ||
const DOWNLOAD_LOGS = 'download-logs'; | ||
|
||
/* errors */ | ||
const ERROR_404 = 'error-404'; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Axios allows the use of interceptor, which allows specific behavior based on an error code. This would allow us to easily control/orient the view used and potentially have logic on a specific error.
Ex:
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 like the idea of using the interceptor, especially to validate the response contents from the back end.
I suggest to handle this in another pull-request though, as we only cover the HTTP 404 here.