import { ActivatedRoute } from '@angular/router'
import { Subscription } from 'rxjs'
import { map, switchMap } from 'rxjs/operators'
-import { RegisterSettingOptions } from '@shared/models/plugins/register-setting.model'
import { BuildFormArgument, FormReactive, FormValidatorService } from '@app/shared'
+import { RegisterServerSettingOptions } from '@shared/models/plugins/register-server-setting.model'
@Component({
selector: 'my-plugin-show-installed',
})
export class PluginShowInstalledComponent extends FormReactive implements OnInit, OnDestroy {
plugin: PeerTubePlugin
- registeredSettings: RegisterSettingOptions[] = []
+ registeredSettings: RegisterServerSettingOptions[] = []
pluginTypeLabel: string
private sub: Subscription
import { PeerTubePlugin } from '@shared/models/plugins/peertube-plugin.model'
import { ManagePlugin } from '@shared/models/plugins/manage-plugin.model'
import { InstallOrUpdatePlugin } from '@shared/models/plugins/install-plugin.model'
-import { RegisterSettingOptions } from '@shared/models/plugins/register-setting.model'
import { PeerTubePluginIndex } from '@shared/models/plugins/peertube-plugin-index.model'
+import { RegisterServerSettingOptions } from '@shared/models/plugins/register-server-setting.model'
@Injectable()
export class PluginApiService {
getPluginRegisteredSettings (pluginName: string, pluginType: PluginType) {
const path = PluginApiService.BASE_APPLICATION_URL + '/' + this.nameToNpmName(pluginName, pluginType) + '/registered-settings'
- return this.authHttp.get<{ settings: RegisterSettingOptions[] }>(path)
+ return this.authHttp.get<{ settings: RegisterServerSettingOptions[] }>(path)
.pipe(catchError(res => this.restExtractor.handleError(res)))
}
import { ServerService } from '@app/core/server/server.service'
import { ClientScript } from '@shared/models/plugins/plugin-package-json.model'
import { environment } from '../../../environments/environment'
-import { RegisterHookOptions } from '@shared/models/plugins/register-hook.model'
import { ReplaySubject } from 'rxjs'
import { first, shareReplay } from 'rxjs/operators'
import { getHookType, internalRunHook } from '@shared/core-utils/plugins/hooks'
import { ClientHook, ClientHookName, clientHookObject } from '@shared/models/plugins/client-hook.model'
import { PluginClientScope } from '@shared/models/plugins/plugin-client-scope.type'
+import { RegisterClientHookOptions } from '@shared/models/plugins/register-client-hook.model'
-interface HookStructValue extends RegisterHookOptions {
+interface HookStructValue extends RegisterClientHookOptions {
plugin: ServerConfigPlugin
clientScript: ClientScript
}
private loadPlugin (pluginInfo: PluginInfo) {
const { plugin, clientScript } = pluginInfo
- const registerHook = (options: RegisterHookOptions) => {
+ const registerHook = (options: RegisterClientHookOptions) => {
if (clientHookObject[options.target] !== true) {
console.error('Unknown hook %s of plugin %s. Skipping.', options.target, plugin.name)
return
import { logger } from '../../helpers/logger'
import { listAvailablePluginsFromIndex } from '../../lib/plugins/plugin-index'
import { PeertubePluginIndexList } from '../../../shared/models/plugins/peertube-plugin-index-list.model'
-import { RegisteredSettings } from '../../../shared/models/plugins/register-setting.model'
+import { RegisteredServerSettings } from '../../../shared/models/plugins/register-server-setting.model'
const pluginRouter = express.Router()
function getPluginRegisteredSettings (req: express.Request, res: express.Response) {
const settings = PluginManager.Instance.getRegisteredSettings(req.params.npmName)
- const json: RegisteredSettings = { settings }
+ const json: RegisteredServerSettings = { settings }
return res.json(json)
}
import { PluginType } from '../../../shared/models/plugins/plugin.type'
import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn'
import { outputFile, readJSON } from 'fs-extra'
-import { RegisterSettingOptions } from '../../../shared/models/plugins/register-setting.model'
-import { RegisterHookOptions } from '../../../shared/models/plugins/register-hook.model'
import { PluginSettingsManager } from '../../../shared/models/plugins/plugin-settings-manager.model'
import { PluginStorageManager } from '../../../shared/models/plugins/plugin-storage-manager.model'
import { ServerHook, ServerHookName, serverHookObject } from '../../../shared/models/plugins/server-hook.model'
import { getHookType, internalRunHook } from '../../../shared/core-utils/plugins/hooks'
-import { RegisterOptions } from '../../typings/plugins/register-options.model'
+import { RegisterServerOptions } from '../../typings/plugins/register-server-option.model'
import { PluginLibrary } from '../../typings/plugins'
import { ClientHtml } from '../client-html'
+import { RegisterServerHookOptions } from '../../../shared/models/plugins/register-server-hook.model'
+import { RegisterServerSettingOptions } from '../../../shared/models/plugins/register-server-setting.model'
export interface RegisteredPlugin {
npmName: string
private static instance: PluginManager
private registeredPlugins: { [ name: string ]: RegisteredPlugin } = {}
- private settings: { [ name: string ]: RegisterSettingOptions[] } = {}
+ private settings: { [ name: string ]: RegisterServerSettingOptions[] } = {}
private hooks: { [ name: string ]: HookInformationValue[] } = {}
private constructor () {
// ###################### Generate register helpers ######################
- private getRegisterHelpers (npmName: string, plugin: PluginModel): RegisterOptions {
- const registerHook = (options: RegisterHookOptions) => {
+ private getRegisterHelpers (npmName: string, plugin: PluginModel): RegisterServerOptions {
+ const registerHook = (options: RegisterServerHookOptions) => {
if (serverHookObject[options.target] !== true) {
logger.warn('Unknown hook %s of plugin %s. Skipping.', options.target, npmName)
return
})
}
- const registerSetting = (options: RegisterSettingOptions) => {
+ const registerSetting = (options: RegisterServerSettingOptions) => {
if (!this.settings[npmName]) this.settings[npmName] = []
this.settings[npmName].push(options)
import { PluginType } from '../../../../shared/models/plugins/plugin.type'
import { PeerTubePluginIndex } from '../../../../shared/models/plugins/peertube-plugin-index.model'
import { ServerConfig } from '../../../../shared/models/server'
-import { RegisteredSettings } from '../../../../shared/models/plugins/register-setting.model'
import { PeerTubePlugin } from '../../../../shared/models/plugins/peertube-plugin.model'
import { User } from '../../../../shared/models/users'
import { PluginPackageJson } from '../../../../shared/models/plugins/plugin-package-json.model'
+import { RegisteredServerSettings } from '../../../../shared/models/plugins/register-server-setting.model'
const expect = chai.expect
npmName: 'peertube-plugin-hello-world'
})
- const settings = (res.body as RegisteredSettings).settings
+ const settings = (res.body as RegisteredServerSettings).settings
expect(settings).to.have.length.at.least(1)
-export * from './register-options.model'
+export * from './register-server-option.model'
export * from './plugin-library.model'
-import { RegisterOptions } from './register-options.model'
+import { RegisterServerOptions } from './register-server-option.model'
export interface PluginLibrary {
- register: (options: RegisterOptions) => Promise<any>
+ register: (options: RegisterServerOptions) => Promise<any>
unregister: () => Promise<any>
}
+++ /dev/null
-import { logger } from '../../helpers/logger'
-import { RegisterHookOptions } from '../../../shared/models/plugins/register-hook.model'
-import { RegisterSettingOptions } from '../../../shared/models/plugins/register-setting.model'
-import { PluginSettingsManager } from '../../../shared/models/plugins/plugin-settings-manager.model'
-import { PluginStorageManager } from '../../../shared/models/plugins/plugin-storage-manager.model'
-
-export type RegisterOptions = {
- registerHook: (options: RegisterHookOptions) => void
-
- registerSetting: (options: RegisterSettingOptions) => void
-
- settingsManager: PluginSettingsManager
-
- storageManager: PluginStorageManager
-
- peertubeHelpers: {
- logger: typeof logger
- }
-}
--- /dev/null
+import { logger } from '../../helpers/logger'
+import { PluginSettingsManager } from '../../../shared/models/plugins/plugin-settings-manager.model'
+import { PluginStorageManager } from '../../../shared/models/plugins/plugin-storage-manager.model'
+import { RegisterServerHookOptions } from '../../../shared/models/plugins/register-server-hook.model'
+import { RegisterServerSettingOptions } from '../../../shared/models/plugins/register-server-setting.model'
+
+export type RegisterServerOptions = {
+ registerHook: (options: RegisterServerHookOptions) => void
+
+ registerSetting: (options: RegisterServerSettingOptions) => void
+
+ settingsManager: PluginSettingsManager
+
+ storageManager: PluginStorageManager
+
+ peertubeHelpers: {
+ logger: typeof logger
+ }
+}
--- /dev/null
+import { ClientHookName } from './client-hook.model'
+
+export interface RegisterClientHookOptions {
+ target: ClientHookName
+ handler: Function
+ priority?: number
+}
+++ /dev/null
-export interface RegisterHookOptions {
- target: string
- handler: Function
- priority?: number
-}
--- /dev/null
+import { ServerHookName } from './server-hook.model'
+
+export interface RegisterServerHookOptions {
+ target: ServerHookName
+ handler: Function
+ priority?: number
+}
--- /dev/null
+export interface RegisterServerSettingOptions {
+ name: string
+ label: string
+ type: 'input'
+ default?: string
+}
+
+export interface RegisteredServerSettings {
+ settings: RegisterServerSettingOptions[]
+}
+++ /dev/null
-export interface RegisterSettingOptions {
- name: string
- label: string
- type: 'input'
- default?: string
-}
-
-export interface RegisteredSettings {
- settings: RegisterSettingOptions[]
-}