diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-01-24 03:02:04 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-01-25 15:37:26 +0100 |
commit | ab398a05e9ffaacb8fc713bb2ba9717ac463b34c (patch) | |
tree | d73c6debfcc14c0dc05c681bb442e6f6fb6ce3a7 /client/src/app/+page-not-found | |
parent | 6939cbac48e0a9823b34577836480ae3c28186be (diff) | |
download | PeerTube-ab398a05e9ffaacb8fc713bb2ba9717ac463b34c.tar.gz PeerTube-ab398a05e9ffaacb8fc713bb2ba9717ac463b34c.tar.zst PeerTube-ab398a05e9ffaacb8fc713bb2ba9717ac463b34c.zip |
redirect to login on 401, display error variants in 404 component
Diffstat (limited to 'client/src/app/+page-not-found')
-rw-r--r-- | client/src/app/+page-not-found/page-not-found.component.html | 15 | ||||
-rw-r--r-- | client/src/app/+page-not-found/page-not-found.component.ts | 22 |
2 files changed, 32 insertions, 5 deletions
diff --git a/client/src/app/+page-not-found/page-not-found.component.html b/client/src/app/+page-not-found/page-not-found.component.html index aa57b07e8..efd3cc9f9 100644 --- a/client/src/app/+page-not-found/page-not-found.component.html +++ b/client/src/app/+page-not-found/page-not-found.component.html | |||
@@ -1,23 +1,32 @@ | |||
1 | <div class="root"> | 1 | <div class="root"> |
2 | <div *ngIf="status === 404" class="box"> | 2 | <div *ngIf="status !== 403 && status !== 418" class="box"> |
3 | <strong>{{ status }}.</strong> | 3 | <strong>{{ status }}.</strong> |
4 | <span class="ml-1 text-muted" i18n>That's an error.</span> | 4 | <span class="ml-1 text-muted" i18n>That's an error.</span> |
5 | 5 | ||
6 | <div class="text mt-4" i18n> | 6 | <div class="text mt-4" i18n> |
7 | We couldn't find any ressource tied to the URL {{ pathname }} you were looking for. | 7 | We couldn't find any {{ getRessourceName() }} tied to the URL {{ pathname }} you were looking for. |
8 | </div> | 8 | </div> |
9 | 9 | ||
10 | <div class="text-muted mt-4"> | 10 | <div class="text-muted mt-4"> |
11 | <span i18n="Possible reasons preceding a list of reasons a `Not Found` error page may occur">Possible reasons:</span> | 11 | <span i18n="Possible reasons preceding a list of reasons a `Not Found` error page may occur">Possible reasons:</span> |
12 | 12 | ||
13 | <ul> | 13 | <ul> |
14 | <li i18n>The page may have been moved or deleted</li> | ||
15 | <li i18n>You may have used an outdated or broken link</li> | 14 | <li i18n>You may have used an outdated or broken link</li> |
15 | <li i18n>The {{ getRessourceName() }} may have been moved or deleted</li> | ||
16 | <li i18n>You may have typed the address or URL incorrectly</li> | 16 | <li i18n>You may have typed the address or URL incorrectly</li> |
17 | </ul> | 17 | </ul> |
18 | </div> | 18 | </div> |
19 | </div> | 19 | </div> |
20 | 20 | ||
21 | <div *ngIf="status === 403" class="box"> | ||
22 | <strong>{{ status }}.</strong> | ||
23 | <span class="ml-1 text-muted" i18n>You are not authorized here.</span> | ||
24 | |||
25 | <div class="text mt-4" i18n> | ||
26 | You might need to check your account is allowed by the {{ getRessourceName() }} or instance owner. | ||
27 | </div> | ||
28 | </div> | ||
29 | |||
21 | <div *ngIf="status === 418" class="box"> | 30 | <div *ngIf="status === 418" class="box"> |
22 | <strong>{{ status }}.</strong> | 31 | <strong>{{ status }}.</strong> |
23 | <span class="ml-1 text-muted">I'm a teapot.</span> | 32 | <span class="ml-1 text-muted">I'm a teapot.</span> |
diff --git a/client/src/app/+page-not-found/page-not-found.component.ts b/client/src/app/+page-not-found/page-not-found.component.ts index 81830d415..9302201ea 100644 --- a/client/src/app/+page-not-found/page-not-found.component.ts +++ b/client/src/app/+page-not-found/page-not-found.component.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, OnInit } from '@angular/core' |
2 | import { Title } from '@angular/platform-browser' | 2 | import { Title } from '@angular/platform-browser' |
3 | import { Router } from '@angular/router' | ||
3 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 4 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' |
4 | 5 | ||
5 | @Component({ | 6 | @Component({ |
@@ -9,10 +10,16 @@ import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | |||
9 | }) | 10 | }) |
10 | export class PageNotFoundComponent implements OnInit { | 11 | export class PageNotFoundComponent implements OnInit { |
11 | status = HttpStatusCode.NOT_FOUND_404 | 12 | status = HttpStatusCode.NOT_FOUND_404 |
13 | type: string | ||
12 | 14 | ||
13 | public constructor ( | 15 | public constructor ( |
14 | private titleService: Title | 16 | private titleService: Title, |
15 | ) {} | 17 | private router: Router |
18 | ) { | ||
19 | const state = this.router.getCurrentNavigation()?.extras.state | ||
20 | this.type = state?.type || this.type | ||
21 | this.status = state?.obj.status || this.status | ||
22 | } | ||
16 | 23 | ||
17 | ngOnInit () { | 24 | ngOnInit () { |
18 | if (this.pathname.includes('teapot')) { | 25 | if (this.pathname.includes('teapot')) { |
@@ -25,10 +32,21 @@ export class PageNotFoundComponent implements OnInit { | |||
25 | return window.location.pathname | 32 | return window.location.pathname |
26 | } | 33 | } |
27 | 34 | ||
35 | getRessourceName () { | ||
36 | switch (this.type) { | ||
37 | case 'video': | ||
38 | return $localize`video` | ||
39 | default: | ||
40 | return $localize`ressource` | ||
41 | } | ||
42 | } | ||
43 | |||
28 | getMascotName () { | 44 | getMascotName () { |
29 | switch (this.status) { | 45 | switch (this.status) { |
30 | case HttpStatusCode.I_AM_A_TEAPOT_418: | 46 | case HttpStatusCode.I_AM_A_TEAPOT_418: |
31 | return 'happy' | 47 | return 'happy' |
48 | case HttpStatusCode.FORBIDDEN_403: | ||
49 | return 'arguing' | ||
32 | case HttpStatusCode.NOT_FOUND_404: | 50 | case HttpStatusCode.NOT_FOUND_404: |
33 | default: | 51 | default: |
34 | return 'defeated' | 52 | return 'defeated' |