aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/guards
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-04 16:21:17 +0200
committerChocobozzz <me@florianbigard.com>2018-06-05 08:43:01 +0200
commitb1d40cff89f7cff565a98cdbcea9a624196a169a (patch)
treed24746c1cc69f50471a9eba0dfb1c1bae06a1870 /client/src/app/shared/guards
parent989e526abf0c0dd7958deb630df009608561bb67 (diff)
downloadPeerTube-b1d40cff89f7cff565a98cdbcea9a624196a169a.tar.gz
PeerTube-b1d40cff89f7cff565a98cdbcea9a624196a169a.tar.zst
PeerTube-b1d40cff89f7cff565a98cdbcea9a624196a169a.zip
Add i18n attributes
Diffstat (limited to 'client/src/app/shared/guards')
-rw-r--r--client/src/app/shared/guards/can-deactivate-guard.service.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/client/src/app/shared/guards/can-deactivate-guard.service.ts b/client/src/app/shared/guards/can-deactivate-guard.service.ts
index 550dd656e..c038a5c0e 100644
--- a/client/src/app/shared/guards/can-deactivate-guard.service.ts
+++ b/client/src/app/shared/guards/can-deactivate-guard.service.ts
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'
2import { ActivatedRouteSnapshot, CanDeactivate, RouterStateSnapshot } from '@angular/router' 2import { ActivatedRouteSnapshot, CanDeactivate, RouterStateSnapshot } from '@angular/router'
3import { Observable } from 'rxjs' 3import { Observable } from 'rxjs'
4import { ConfirmService } from '../../core/index' 4import { ConfirmService } from '../../core/index'
5import { I18n } from '@ngx-translate/i18n-polyfill'
5 6
6export interface CanComponentDeactivate { 7export interface CanComponentDeactivate {
7 canDeactivate: () => { text?: string, canDeactivate: Observable<boolean> | boolean } 8 canDeactivate: () => { text?: string, canDeactivate: Observable<boolean> | boolean }
@@ -9,7 +10,10 @@ export interface CanComponentDeactivate {
9 10
10@Injectable() 11@Injectable()
11export class CanDeactivateGuard implements CanDeactivate<CanComponentDeactivate> { 12export class CanDeactivateGuard implements CanDeactivate<CanComponentDeactivate> {
12 constructor (private confirmService: ConfirmService) { } 13 constructor (
14 private confirmService: ConfirmService,
15 private i18n: I18n
16 ) { }
13 17
14 canDeactivate (component: CanComponentDeactivate, 18 canDeactivate (component: CanComponentDeactivate,
15 currentRoute: ActivatedRouteSnapshot, 19 currentRoute: ActivatedRouteSnapshot,
@@ -17,11 +21,11 @@ export class CanDeactivateGuard implements CanDeactivate<CanComponentDeactivate>
17 nextState: RouterStateSnapshot 21 nextState: RouterStateSnapshot
18 ) { 22 ) {
19 const result = component.canDeactivate() 23 const result = component.canDeactivate()
20 const text = result.text || 'All unsaved data will be lost, are you sure you want to leave this page?' 24 const text = result.text || this.i18n('All unsaved data will be lost, are you sure you want to leave this page?')
21 25
22 return result.canDeactivate || this.confirmService.confirm( 26 return result.canDeactivate || this.confirmService.confirm(
23 text, 27 text,
24 'Warning' 28 this.i18n('Warning')
25 ) 29 )
26 } 30 }
27 31