ActivityPub-federated video streaming platform using P2P directly in your web browser
Add notifier to plugin helpers (#2627)
Kim74c2dece42d3
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.tsindex da5114048a..b9d55a7e49 100644--- a/client/src/app/core/plugins/plugin.service.ts+++ b/client/src/app/core/plugins/plugin.service.ts@@ -12,7 +12,7 @@ import { ClientHook, ClientHookName, clientHookObject } from '@shared/models/pluimport { PluginClientScope } from '@shared/models/plugins/plugin-client-scope.type'import { RegisterClientHookOptions } from '@shared/models/plugins/register-client-hook.model'import { HttpClient } from '@angular/common/http'-import { AuthService } from '@app/core/auth'+import { AuthService, Notifier } from '@app/core'import { RestExtractor } from '@app/shared/rest'import { PluginType } from '@shared/models/plugins/plugin.type'import { PublicServerSetting } from '@shared/models/plugins/public-server.setting'@@ -60,6 +60,7 @@ export class PluginService implements ClientHook {constructor (private router: Router,private authService: AuthService,+ private notifier: Notifier,private server: ServerService,private zone: NgZone,private authHttp: HttpClient,@@ -272,6 +273,8 @@ export class PluginService implements ClientHook {return this.authService.isLoggedIn()},+ notifier: this.notifier,+translate: (value: string) => {return this.translationsObservable.pipe(map(allTranslations => allTranslations[npmName]))diff --git a/client/src/types/register-client-option.model.ts b/client/src/types/register-client-option.model.tsindex 638b086532..1faf13c42c 100644--- a/client/src/types/register-client-option.model.ts+++ b/client/src/types/register-client-option.model.ts@@ -1,4 +1,5 @@import { RegisterClientHookOptions } from '@shared/models/plugins/register-client-hook.model'+import { Notifier } from '@app/core'export type RegisterClientOptions = {registerHook: (options: RegisterClientHookOptions) => void@@ -13,5 +14,7 @@ export type RegisterClientHelpers = {getSettings: () => Promise<{ [ name: string ]: string }>+ notifier: Notifier+translate: (toTranslate: string) => Promise<string>}diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.mdindex bdc9d2ad82..5251ce48a8 100644--- a/support/doc/plugins/guide.md+++ b/support/doc/plugins/guide.md@@ -197,7 +197,7 @@ The `ping` route can be accessed using:### Client helpers (themes & plugins)-### Plugin static route+#### Plugin static routeTo get your plugin static route:@@ -206,6 +206,16 @@ const baseStaticUrl = peertubeHelpers.getBaseStaticRoute()const imageUrl = baseStaticUrl + '/images/chocobo.png'```+#### Notifier++To notify the user with the PeerTube ToastModule:++```js+const { notifier } = peertubeHelpers+notifier.success('Success message content.')+notifier.error('Error message content.')+```+#### TranslateYou can translate some strings of your plugin (PeerTube will use your `translations` object of your `package.json` file):