aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/plugins
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/plugins
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/plugins')
-rw-r--r--client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts16
-rw-r--r--client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts13
-rw-r--r--client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts4
-rw-r--r--client/src/app/+admin/plugins/shared/plugin-api.service.ts10
4 files changed, 17 insertions, 26 deletions
diff --git a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts
index af31f1144..1ffd001c6 100644
--- a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts
+++ b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts
@@ -4,7 +4,6 @@ import { ActivatedRoute, Router } from '@angular/router'
4import { PluginApiService } from '@app/+admin/plugins/shared/plugin-api.service' 4import { PluginApiService } from '@app/+admin/plugins/shared/plugin-api.service'
5import { ComponentPagination, ConfirmService, hasMoreItems, Notifier } from '@app/core' 5import { ComponentPagination, ConfirmService, hasMoreItems, Notifier } from '@app/core'
6import { PluginService } from '@app/core/plugins/plugin.service' 6import { PluginService } from '@app/core/plugins/plugin.service'
7import { I18n } from '@ngx-translate/i18n-polyfill'
8import { compareSemVer } from '@shared/core-utils/miscs/miscs' 7import { compareSemVer } from '@shared/core-utils/miscs/miscs'
9import { PeerTubePlugin } from '@shared/models/plugins/peertube-plugin.model' 8import { PeerTubePlugin } from '@shared/models/plugins/peertube-plugin.model'
10import { PluginType } from '@shared/models/plugins/plugin.type' 9import { PluginType } from '@shared/models/plugins/plugin.type'
@@ -37,7 +36,6 @@ export class PluginListInstalledComponent implements OnInit {
37 onDataSubject = new Subject<any[]>() 36 onDataSubject = new Subject<any[]>()
38 37
39 constructor ( 38 constructor (
40 private i18n: I18n,
41 private pluginService: PluginService, 39 private pluginService: PluginService,
42 private pluginApiService: PluginApiService, 40 private pluginApiService: PluginApiService,
43 private notifier: Notifier, 41 private notifier: Notifier,
@@ -88,10 +86,10 @@ export class PluginListInstalledComponent implements OnInit {
88 86
89 getNoResultMessage () { 87 getNoResultMessage () {
90 if (this.pluginType === PluginType.PLUGIN) { 88 if (this.pluginType === PluginType.PLUGIN) {
91 return this.i18n("You don't have plugins installed yet.") 89 return $localize`You don't have plugins installed yet.`
92 } 90 }
93 91
94 return this.i18n("You don't have themes installed yet.") 92 return $localize`You don't have themes installed yet.`
95 } 93 }
96 94
97 isUpdateAvailable (plugin: PeerTubePlugin) { 95 isUpdateAvailable (plugin: PeerTubePlugin) {
@@ -99,7 +97,7 @@ export class PluginListInstalledComponent implements OnInit {
99 } 97 }
100 98
101 getUpdateLabel (plugin: PeerTubePlugin) { 99 getUpdateLabel (plugin: PeerTubePlugin) {
102 return this.i18n('Update to {{version}}', { version: plugin.latestVersion }) 100 return $localize`Update to ${plugin.latestVersion}`
103 } 101 }
104 102
105 isUpdating (plugin: PeerTubePlugin) { 103 isUpdating (plugin: PeerTubePlugin) {
@@ -108,15 +106,15 @@ export class PluginListInstalledComponent implements OnInit {
108 106
109 async uninstall (plugin: PeerTubePlugin) { 107 async uninstall (plugin: PeerTubePlugin) {
110 const res = await this.confirmService.confirm( 108 const res = await this.confirmService.confirm(
111 this.i18n('Do you really want to uninstall {{pluginName}}?', { pluginName: plugin.name }), 109 $localize`Do you really want to uninstall ${plugin.name}?`,
112 this.i18n('Uninstall') 110 $localize`Uninstall`
113 ) 111 )
114 if (res === false) return 112 if (res === false) return
115 113
116 this.pluginApiService.uninstall(plugin.name, plugin.type) 114 this.pluginApiService.uninstall(plugin.name, plugin.type)
117 .subscribe( 115 .subscribe(
118 () => { 116 () => {
119 this.notifier.success(this.i18n('{{pluginName}} uninstalled.', { pluginName: plugin.name })) 117 this.notifier.success($localize`${plugin.name} uninstalled.`)
120 118
121 this.plugins = this.plugins.filter(p => p.name !== plugin.name) 119 this.plugins = this.plugins.filter(p => p.name !== plugin.name)
122 this.pagination.totalItems-- 120 this.pagination.totalItems--
@@ -138,7 +136,7 @@ export class PluginListInstalledComponent implements OnInit {
138 res => { 136 res => {
139 this.updating[updatingKey] = false 137 this.updating[updatingKey] = false
140 138
141 this.notifier.success(this.i18n('{{pluginName}} updated.', { pluginName: plugin.name })) 139 this.notifier.success($localize`${plugin.name} updated.`)
142 140
143 Object.assign(plugin, res) 141 Object.assign(plugin, res)
144 }, 142 },
diff --git a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts
index ccf9f1ed5..1a6b4eba3 100644
--- a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts
+++ b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts
@@ -3,8 +3,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'
3import { Component, OnInit } from '@angular/core' 3import { Component, OnInit } from '@angular/core'
4import { ActivatedRoute, Router } from '@angular/router' 4import { ActivatedRoute, Router } from '@angular/router'
5import { PluginApiService } from '@app/+admin/plugins/shared/plugin-api.service' 5import { PluginApiService } from '@app/+admin/plugins/shared/plugin-api.service'
6import { ComponentPagination, ConfirmService, hasMoreItems, Notifier, ServerService } from '@app/core' 6import { ComponentPagination, ConfirmService, hasMoreItems, Notifier } from '@app/core'
7import { I18n } from '@ngx-translate/i18n-polyfill'
8import { PeerTubePluginIndex } from '@shared/models/plugins/peertube-plugin-index.model' 7import { PeerTubePluginIndex } from '@shared/models/plugins/peertube-plugin-index.model'
9import { PluginType } from '@shared/models/plugins/plugin.type' 8import { PluginType } from '@shared/models/plugins/plugin.type'
10 9
@@ -40,8 +39,6 @@ export class PluginSearchComponent implements OnInit {
40 private searchSubject = new Subject<string>() 39 private searchSubject = new Subject<string>()
41 40
42 constructor ( 41 constructor (
43 private server: ServerService,
44 private i18n: I18n,
45 private pluginService: PluginApiService, 42 private pluginService: PluginApiService,
46 private notifier: Notifier, 43 private notifier: Notifier,
47 private confirmService: ConfirmService, 44 private confirmService: ConfirmService,
@@ -100,7 +97,7 @@ export class PluginSearchComponent implements OnInit {
100 err => { 97 err => {
101 console.error(err) 98 console.error(err)
102 99
103 const message = this.i18n('The plugin index is not available. Please retry later.') 100 const message = $localize`The plugin index is not available. Please retry later.`
104 this.notifier.error(message) 101 this.notifier.error(message)
105 } 102 }
106 ) 103 )
@@ -122,8 +119,8 @@ export class PluginSearchComponent implements OnInit {
122 if (this.installing[plugin.npmName]) return 119 if (this.installing[plugin.npmName]) return
123 120
124 const res = await this.confirmService.confirm( 121 const res = await this.confirmService.confirm(
125 this.i18n('Please only install plugins or themes you trust, since they can execute any code on your instance.'), 122 $localize`Please only install plugins or themes you trust, since they can execute any code on your instance.`,
126 this.i18n('Install {{pluginName}}?', { pluginName: plugin.name }) 123 $localize`Install ${plugin.name}?`
127 ) 124 )
128 if (res === false) return 125 if (res === false) return
129 126
@@ -135,7 +132,7 @@ export class PluginSearchComponent implements OnInit {
135 this.installing[plugin.npmName] = false 132 this.installing[plugin.npmName] = false
136 this.pluginInstalled = true 133 this.pluginInstalled = true
137 134
138 this.notifier.success(this.i18n('{{pluginName}} installed.', { pluginName: plugin.name })) 135 this.notifier.success($localize`${plugin.name} installed.`)
139 136
140 plugin.installed = true 137 plugin.installed = true
141 }, 138 },
diff --git a/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts b/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts
index dde03f1da..a33f01691 100644
--- a/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts
+++ b/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts
@@ -4,7 +4,6 @@ import { Component, OnDestroy, OnInit } from '@angular/core'
4import { ActivatedRoute } from '@angular/router' 4import { ActivatedRoute } from '@angular/router'
5import { Notifier } from '@app/core' 5import { Notifier } from '@app/core'
6import { BuildFormArgument, FormReactive, FormValidatorService } from '@app/shared/shared-forms' 6import { BuildFormArgument, FormReactive, FormValidatorService } from '@app/shared/shared-forms'
7import { I18n } from '@ngx-translate/i18n-polyfill'
8import { PeerTubePlugin, RegisterServerSettingOptions } from '@shared/models' 7import { PeerTubePlugin, RegisterServerSettingOptions } from '@shared/models'
9import { PluginApiService } from '../shared/plugin-api.service' 8import { PluginApiService } from '../shared/plugin-api.service'
10 9
@@ -22,7 +21,6 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit
22 21
23 constructor ( 22 constructor (
24 protected formValidatorService: FormValidatorService, 23 protected formValidatorService: FormValidatorService,
25 private i18n: I18n,
26 private pluginService: PluginApiService, 24 private pluginService: PluginApiService,
27 private notifier: Notifier, 25 private notifier: Notifier,
28 private route: ActivatedRoute 26 private route: ActivatedRoute
@@ -50,7 +48,7 @@ export class PluginShowInstalledComponent extends FormReactive implements OnInit
50 this.pluginService.updatePluginSettings(this.plugin.name, this.plugin.type, settings) 48 this.pluginService.updatePluginSettings(this.plugin.name, this.plugin.type, settings)
51 .subscribe( 49 .subscribe(
52 () => { 50 () => {
53 this.notifier.success(this.i18n('Settings updated.')) 51 this.notifier.success($localize`Settings updated.`)
54 }, 52 },
55 53
56 err => this.notifier.error(err.message) 54 err => this.notifier.error(err.message)
diff --git a/client/src/app/+admin/plugins/shared/plugin-api.service.ts b/client/src/app/+admin/plugins/shared/plugin-api.service.ts
index 1fb827832..b28d46df4 100644
--- a/client/src/app/+admin/plugins/shared/plugin-api.service.ts
+++ b/client/src/app/+admin/plugins/shared/plugin-api.service.ts
@@ -4,7 +4,6 @@ import { HttpClient, HttpParams } from '@angular/common/http'
4import { Injectable } from '@angular/core' 4import { Injectable } from '@angular/core'
5import { ComponentPagination, RestExtractor, RestService } from '@app/core' 5import { ComponentPagination, RestExtractor, RestService } from '@app/core'
6import { PluginService } from '@app/core/plugins/plugin.service' 6import { PluginService } from '@app/core/plugins/plugin.service'
7import { I18n } from '@ngx-translate/i18n-polyfill'
8import { peertubeTranslate } from '@shared/core-utils/i18n' 7import { peertubeTranslate } from '@shared/core-utils/i18n'
9import { 8import {
10 InstallOrUpdatePlugin, 9 InstallOrUpdatePlugin,
@@ -25,18 +24,17 @@ export class PluginApiService {
25 private authHttp: HttpClient, 24 private authHttp: HttpClient,
26 private restExtractor: RestExtractor, 25 private restExtractor: RestExtractor,
27 private restService: RestService, 26 private restService: RestService,
28 private i18n: I18n,
29 private pluginService: PluginService 27 private pluginService: PluginService
30 ) { } 28 ) { }
31 29
32 getPluginTypeOptions () { 30 getPluginTypeOptions () {
33 return [ 31 return [
34 { 32 {
35 label: this.i18n('Plugins'), 33 label: $localize`Plugins`,
36 value: PluginType.PLUGIN 34 value: PluginType.PLUGIN
37 }, 35 },
38 { 36 {
39 label: this.i18n('Themes'), 37 label: $localize`Themes`,
40 value: PluginType.THEME 38 value: PluginType.THEME
41 } 39 }
42 ] 40 ]
@@ -44,10 +42,10 @@ export class PluginApiService {
44 42
45 getPluginTypeLabel (type: PluginType) { 43 getPluginTypeLabel (type: PluginType) {
46 if (type === PluginType.PLUGIN) { 44 if (type === PluginType.PLUGIN) {
47 return this.i18n('plugin') 45 return $localize`plugin`
48 } 46 }
49 47
50 return this.i18n('theme') 48 return $localize`theme`
51 } 49 }
52 50
53 getPlugins ( 51 getPlugins (