aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-12 10:40:04 +0200
committerChocobozzz <me@florianbigard.com>2020-08-14 10:28:30 +0200
commit66357162f8e1227495f09bd4f68446aad7071c6d (patch)
tree7d4429506deb512b2fe1d0267f38a28cda20af55 /client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts
parent8c360747995e17eb5520e22fc3d7bd4c3d26eeee (diff)
downloadPeerTube-66357162f8e1227495f09bd4f68446aad7071c6d.tar.gz
PeerTube-66357162f8e1227495f09bd4f68446aad7071c6d.tar.zst
PeerTube-66357162f8e1227495f09bd4f68446aad7071c6d.zip
Migrate to $localize
* Remove i18n polyfill to translate things in components * Reduce bundle sizes * Improve runtime perf * Reduce a lot the time to make a full client build * Reduce client build complexity * We don't need a service to translate things anymore (so we will be able to translate title pages etc) Unfortunately we may loose some translations in the migration process. I'll put a message on weblate to notify translators
Diffstat (limited to 'client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts')
-rw-r--r--client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts42
1 files changed, 19 insertions, 23 deletions
diff --git a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts
index 422d873c0..2b1ef663c 100644
--- a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts
+++ b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts
@@ -1,15 +1,14 @@
1import { SortMeta } from 'primeng/api' 1import { SortMeta } from 'primeng/api'
2import { filter, switchMap } from 'rxjs/operators' 2import { filter, switchMap } from 'rxjs/operators'
3import { buildVideoLink, buildVideoOrPlaylistEmbed } from 'src/assets/player/utils'
4import { environment } from 'src/environments/environment'
3import { AfterViewInit, Component, OnInit } from '@angular/core' 5import { AfterViewInit, Component, OnInit } from '@angular/core'
6import { DomSanitizer } from '@angular/platform-browser'
4import { ActivatedRoute, Params, Router } from '@angular/router' 7import { ActivatedRoute, Params, Router } from '@angular/router'
5import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable, ServerService } from '@app/core' 8import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable, ServerService } from '@app/core'
6import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' 9import { DropdownAction, Video, VideoService } from '@app/shared/shared-main'
7import { VideoBlockService } from '@app/shared/shared-moderation' 10import { VideoBlockService } from '@app/shared/shared-moderation'
8import { I18n } from '@ngx-translate/i18n-polyfill'
9import { VideoBlacklist, VideoBlacklistType } from '@shared/models' 11import { VideoBlacklist, VideoBlacklistType } from '@shared/models'
10import { buildVideoOrPlaylistEmbed, buildVideoLink } from 'src/assets/player/utils'
11import { environment } from 'src/environments/environment'
12import { DomSanitizer } from '@angular/platform-browser'
13 12
14@Component({ 13@Component({
15 selector: 'my-video-block-list', 14 selector: 'my-video-block-list',
@@ -34,26 +33,25 @@ export class VideoBlockListComponent extends RestTable implements OnInit, AfterV
34 private sanitizer: DomSanitizer, 33 private sanitizer: DomSanitizer,
35 private videoService: VideoService, 34 private videoService: VideoService,
36 private route: ActivatedRoute, 35 private route: ActivatedRoute,
37 private router: Router, 36 private router: Router
38 private i18n: I18n 37 ) {
39 ) {
40 super() 38 super()
41 39
42 this.videoBlocklistActions = [ 40 this.videoBlocklistActions = [
43 [ 41 [
44 { 42 {
45 label: this.i18n('Internal actions'), 43 label: $localize`Internal actions`,
46 isHeader: true, 44 isHeader: true,
47 isDisplayed: videoBlock => videoBlock.type === VideoBlacklistType.AUTO_BEFORE_PUBLISHED 45 isDisplayed: videoBlock => videoBlock.type === VideoBlacklistType.AUTO_BEFORE_PUBLISHED
48 }, 46 },
49 { 47 {
50 label: this.i18n('Switch video block to manual'), 48 label: $localize`Switch video block to manual`,
51 handler: videoBlock => { 49 handler: videoBlock => {
52 this.videoBlocklistService.unblockVideo(videoBlock.video.id).pipe( 50 this.videoBlocklistService.unblockVideo(videoBlock.video.id).pipe(
53 switchMap(_ => this.videoBlocklistService.blockVideo(videoBlock.video.id, undefined, true)) 51 switchMap(_ => this.videoBlocklistService.blockVideo(videoBlock.video.id, undefined, true))
54 ).subscribe( 52 ).subscribe(
55 () => { 53 () => {
56 this.notifier.success(this.i18n('Video {{name}} switched to manual block.', { name: videoBlock.video.name })) 54 this.notifier.success($localize`Video ${videoBlock.video.name} switched to manual block.`)
57 this.loadData() 55 this.loadData()
58 }, 56 },
59 57
@@ -65,27 +63,27 @@ export class VideoBlockListComponent extends RestTable implements OnInit, AfterV
65 ], 63 ],
66 [ 64 [
67 { 65 {
68 label: this.i18n('Actions for the video'), 66 label: $localize`Actions for the video`,
69 isHeader: true 67 isHeader: true
70 }, 68 },
71 { 69 {
72 label: this.i18n('Unblock'), 70 label: $localize`Unblock`,
73 handler: videoBlock => this.unblockVideo(videoBlock) 71 handler: videoBlock => this.unblockVideo(videoBlock)
74 }, 72 },
75 73
76 { 74 {
77 label: this.i18n('Delete'), 75 label: $localize`Delete`,
78 handler: async videoBlock => { 76 handler: async videoBlock => {
79 const res = await this.confirmService.confirm( 77 const res = await this.confirmService.confirm(
80 this.i18n('Do you really want to delete this video?'), 78 $localize`Do you really want to delete this video?`,
81 this.i18n('Delete') 79 $localize`Delete`
82 ) 80 )
83 if (res === false) return 81 if (res === false) return
84 82
85 this.videoService.removeVideo(videoBlock.video.id) 83 this.videoService.removeVideo(videoBlock.video.id)
86 .subscribe( 84 .subscribe(
87 () => { 85 () => {
88 this.notifier.success(this.i18n('Video deleted.')) 86 this.notifier.success($localize`Video deleted.`)
89 }, 87 },
90 88
91 err => this.notifier.error(err.message) 89 err => this.notifier.error(err.message)
@@ -148,9 +146,9 @@ export class VideoBlockListComponent extends RestTable implements OnInit, AfterV
148 } 146 }
149 147
150 booleanToText (value: boolean) { 148 booleanToText (value: boolean) {
151 if (value === true) return this.i18n('yes') 149 if (value === true) return $localize`yes`
152 150
153 return this.i18n('no') 151 return $localize`no`
154 } 152 }
155 153
156 toHtml (text: string) { 154 toHtml (text: string) {
@@ -158,16 +156,14 @@ export class VideoBlockListComponent extends RestTable implements OnInit, AfterV
158 } 156 }
159 157
160 async unblockVideo (entry: VideoBlacklist) { 158 async unblockVideo (entry: VideoBlacklist) {
161 const confirmMessage = this.i18n( 159 const confirmMessage = $localize`Do you really want to unblock this video? It will be available again in the videos list.`
162 'Do you really want to unblock this video? It will be available again in the videos list.'
163 )
164 160
165 const res = await this.confirmService.confirm(confirmMessage, this.i18n('Unblock')) 161 const res = await this.confirmService.confirm(confirmMessage, $localize`Unblock`)
166 if (res === false) return 162 if (res === false) return
167 163
168 this.videoBlocklistService.unblockVideo(entry.video.id).subscribe( 164 this.videoBlocklistService.unblockVideo(entry.video.id).subscribe(
169 () => { 165 () => {
170 this.notifier.success(this.i18n('Video {{name}} unblocked.', { name: entry.video.name })) 166 this.notifier.success($localize`Video ${entry.video.name} unblocked.`)
171 this.loadData() 167 this.loadData()
172 }, 168 },
173 169