diff --git a/js/src/common/components/ErrorPage.js b/js/src/common/components/ErrorPage.js index 3b036e8a6..2fa68bb53 100644 --- a/js/src/common/components/ErrorPage.js +++ b/js/src/common/components/ErrorPage.js @@ -1,11 +1,38 @@ +import Link from './Link'; import Page from './Page'; export default class ErrorPage extends Page { + oninit(vnode) { + super.oninit(vnode); + + this.title = app.translator.trans(`core.forum.error.${this.attrs.errorCode}_title`); + } + + oncreate(vnode) { + super.oncreate(vnode); + + app.setTitle(this.title); + } + view() { + const links = { + 404: '/', + }; + + const link = links[this.attrs.errorCode]; + return (
-

Error!

+

{this.title}

+

{app.translator.trans(`core.forum.error.${this.attrs.errorCode}_text`)}

+

+ {link && ( + + {app.translator.trans(`core.forum.error.${this.attrs.errorCode}_link_text`, { forum: app.forum.attribute('title') })} + + )} +

); diff --git a/js/src/common/resolvers/DefaultResolver.ts b/js/src/common/resolvers/DefaultResolver.ts index ba58e1a1c..80559f37b 100644 --- a/js/src/common/resolvers/DefaultResolver.ts +++ b/js/src/common/resolvers/DefaultResolver.ts @@ -34,10 +34,9 @@ export default class DefaultResolver { onmatch(args, requestedPath, route) { const errorCode = app.data.errorCode; - const currRoute = m.route.get(); if (errorCode) { delete app.data.errorCode; - return { view: () => ErrorPage.component({ errorCode, currRoute }) }; + return { view: () => ErrorPage.component({ errorCode }) }; } return this.component; diff --git a/locale/core.yml b/locale/core.yml index 8e7821d7a..4a011d9f4 100644 --- a/locale/core.yml +++ b/locale/core.yml @@ -303,6 +303,15 @@ core: username_heading: => core.ref.username username_label: => core.ref.username + error: + 401_text: You do not have permission to access this page. Try again after logging in. + 403_text: You do not have permission to access this page. + 404_text: The page you requested could not be found. + 401_title: Not Authenticated + 403_title: Permission Denied + 404_title: Not Found + 404_link_text: "Return to {forum}" + # These translations are used in the Forgot Password modal dialog. forgot_password: dismiss_button: => core.ref.okay @@ -517,10 +526,6 @@ core: csrf_token_mismatch: You have been inactive for too long. csrf_token_mismatch_return_link: Go back, to try again invalid_confirmation_token: This confirmation link has already been used or is invalid. - not_authenticated: You do not have permission to access this page. Try again after logging in. - not_found: The page you requested could not be found. - not_found_return_link: "Return to {forum}" - permission_denied: You do not have permission to access this page. unknown: An error occurred while trying to load this page. # Translations in this namespace are displayed by the basic HTML discussion index. diff --git a/views/error/not_found.blade.php b/views/error/not_found.blade.php deleted file mode 100644 index 48979df37..000000000 --- a/views/error/not_found.blade.php +++ /dev/null @@ -1,12 +0,0 @@ -@extends('flarum.forum::layouts.basic') - -@section('content') -

- {{ $message }} -

-

- - {{ $translator->trans('core.views.error.not_found_return_link', ['{forum}' => $settings->get('forum_title')]) }} - -

-@endsection