aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/models/plugins/client
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-05-11 12:04:47 +0200
committerChocobozzz <me@florianbigard.com>2021-05-11 13:33:11 +0200
commit428ccb8b7a44ce60cabb7401a5464cf5fcbd4dba (patch)
treeb75329b64f5e201abdfb39961f2db09a08292b77 /shared/models/plugins/client
parent2b02c520e66ea452687cab39401b371711caa9ed (diff)
downloadPeerTube-428ccb8b7a44ce60cabb7401a5464cf5fcbd4dba.tar.gz
PeerTube-428ccb8b7a44ce60cabb7401a5464cf5fcbd4dba.tar.zst
PeerTube-428ccb8b7a44ce60cabb7401a5464cf5fcbd4dba.zip
Reorganize plugin models
Diffstat (limited to 'shared/models/plugins/client')
-rw-r--r--shared/models/plugins/client/client-hook.model.ts125
-rw-r--r--shared/models/plugins/client/index.ts6
-rw-r--r--shared/models/plugins/client/plugin-client-scope.type.ts9
-rw-r--r--shared/models/plugins/client/plugin-element-placeholder.type.ts1
-rw-r--r--shared/models/plugins/client/register-client-form-field.model.ts23
-rw-r--r--shared/models/plugins/client/register-client-hook.model.ts7
-rw-r--r--shared/models/plugins/client/register-client-settings-script.model.ts8
7 files changed, 179 insertions, 0 deletions
diff --git a/shared/models/plugins/client/client-hook.model.ts b/shared/models/plugins/client/client-hook.model.ts
new file mode 100644
index 000000000..620651051
--- /dev/null
+++ b/shared/models/plugins/client/client-hook.model.ts
@@ -0,0 +1,125 @@
1// Data from API hooks: {hookType}:api.{location}.{elementType}.{actionType}.{target}
2// Data in internal functions: {hookType}:{location}.{elementType}.{actionType}.{target}
3
4export const clientFilterHookObject = {
5 // Filter params/result of the function that fetch videos of the trending page
6 'filter:api.trending-videos.videos.list.params': true,
7 'filter:api.trending-videos.videos.list.result': true,
8
9 // Filter params/result of the function that fetch videos of the trending page
10 'filter:api.most-liked-videos.videos.list.params': true,
11 'filter:api.most-liked-videos.videos.list.result': true,
12
13 // Filter params/result of the function that fetch videos of the local page
14 'filter:api.local-videos.videos.list.params': true,
15 'filter:api.local-videos.videos.list.result': true,
16
17 // Filter params/result of the function that fetch videos of the recently-added page
18 'filter:api.recently-added-videos.videos.list.params': true,
19 'filter:api.recently-added-videos.videos.list.result': true,
20
21 // Filter params/result of the function that fetch videos of the user subscription page
22 'filter:api.user-subscriptions-videos.videos.list.params': true,
23 'filter:api.user-subscriptions-videos.videos.list.result': true,
24
25 // Filter params/result of the function that fetch the video of the video-watch page
26 'filter:api.video-watch.video.get.params': true,
27 'filter:api.video-watch.video.get.result': true,
28
29 // Filter params/result of the function that fetch the threads of the video-watch page
30 'filter:api.video-watch.video-threads.list.params': true,
31 'filter:api.video-watch.video-threads.list.result': true,
32
33 // Filter params/result of the function that fetch the replies of a thread in the video-watch page
34 'filter:api.video-watch.video-thread-replies.list.params': true,
35 'filter:api.video-watch.video-thread-replies.list.result': true,
36
37 // Filter params/result of the function that fetch videos according to the user search
38 'filter:api.search.videos.list.params': true,
39 'filter:api.search.videos.list.result': true,
40 // Filter params/result of the function that fetch video-channels according to the user search
41 'filter:api.search.video-channels.list.params': true,
42 'filter:api.search.video-channels.list.result': true,
43
44 // Filter form
45 'filter:api.signup.registration.create.params': true,
46
47 // Filter the options to create our player
48 'filter:internal.video-watch.player.build-options.params': true,
49 'filter:internal.video-watch.player.build-options.result': true,
50
51 // Filter our SVG icons content
52 'filter:internal.common.svg-icons.get-content.params': true,
53 'filter:internal.common.svg-icons.get-content.result': true
54}
55
56export type ClientFilterHookName = keyof typeof clientFilterHookObject
57
58export const clientActionHookObject = {
59 // Fired when the application is being initialized
60 'action:application.init': true,
61
62 // Fired when the video watch page is being initialized
63 'action:video-watch.init': true,
64 // Fired when the video watch page loaded the video
65 'action:video-watch.video.loaded': true,
66 // Fired when the player finished loading
67 'action:video-watch.player.loaded': true,
68 // Fired when the video watch page comments(threads) are loaded and load more comments on scroll
69 'action:video-watch.video-threads.loaded': true,
70 // Fired when a user click on 'View x replies' and they're loaded
71 'action:video-watch.video-thread-replies.loaded': true,
72
73 // Fired when the video edit page (upload, URL/torrent import, update) is being initialized
74 'action:video-edit.init': true,
75
76 // Fired when the login page is being initialized
77 'action:login.init': true,
78
79 // Fired when the search page is being initialized
80 'action:search.init': true,
81
82 // Fired every time Angular URL changes
83 'action:router.navigation-end': true,
84
85 // Fired when the registration page is being initialized
86 'action:signup.register.init': true,
87
88 // PeerTube >= 3.2
89 // Fired when the admin plugin settings page is being initialized
90 'action:admin-plugin-settings.init': true,
91
92 // Fired when the video upload page is being initalized
93 'action:video-upload.init': true,
94 // Fired when the video import by URL page is being initalized
95 'action:video-url-import.init': true,
96 // Fired when the video import by torrent/magnet URI page is being initalized
97 'action:video-torrent-import.init': true,
98 // Fired when the "Go Live" page is being initalized
99 'action:go-live.init': true,
100
101 // Fired when the user explicitely logged in/logged out
102 'action:auth-user.logged-in': true,
103 'action:auth-user.logged-out': true,
104 // Fired when the application loaded user information (using tokens from the local storage or after a successful login)
105 'action:auth-user.information-loaded': true,
106
107 // Fired when the modal to download a video/caption is shown
108 'action:modal.video-download.shown': true,
109
110 // ####### Embed hooks #######
111 // /!\ In embed scope, peertube helpers are not available
112 // ###########################
113
114 // Fired when the embed loaded the player
115 'action:embed.player.loaded': true
116}
117
118export type ClientActionHookName = keyof typeof clientActionHookObject
119
120export const clientHookObject = Object.assign({}, clientFilterHookObject, clientActionHookObject)
121export type ClientHookName = keyof typeof clientHookObject
122
123export interface ClientHook {
124 runHook <T> (hookName: ClientHookName, result?: T, params?: any): Promise<T>
125}
diff --git a/shared/models/plugins/client/index.ts b/shared/models/plugins/client/index.ts
new file mode 100644
index 000000000..6dfc6351f
--- /dev/null
+++ b/shared/models/plugins/client/index.ts
@@ -0,0 +1,6 @@
1export * from './client-hook.model'
2export * from './plugin-client-scope.type'
3export * from './plugin-element-placeholder.type'
4export * from './register-client-form-field.model'
5export * from './register-client-hook.model'
6export * from './register-client-settings-script.model'
diff --git a/shared/models/plugins/client/plugin-client-scope.type.ts b/shared/models/plugins/client/plugin-client-scope.type.ts
new file mode 100644
index 000000000..8cc234ff2
--- /dev/null
+++ b/shared/models/plugins/client/plugin-client-scope.type.ts
@@ -0,0 +1,9 @@
1export type PluginClientScope =
2 'common' |
3 'video-watch' |
4 'search' |
5 'signup' |
6 'login' |
7 'embed' |
8 'video-edit' |
9 'admin-plugin'
diff --git a/shared/models/plugins/client/plugin-element-placeholder.type.ts b/shared/models/plugins/client/plugin-element-placeholder.type.ts
new file mode 100644
index 000000000..129099c62
--- /dev/null
+++ b/shared/models/plugins/client/plugin-element-placeholder.type.ts
@@ -0,0 +1 @@
export type PluginElementPlaceholder = 'player-next'
diff --git a/shared/models/plugins/client/register-client-form-field.model.ts b/shared/models/plugins/client/register-client-form-field.model.ts
new file mode 100644
index 000000000..2df071337
--- /dev/null
+++ b/shared/models/plugins/client/register-client-form-field.model.ts
@@ -0,0 +1,23 @@
1export type RegisterClientFormFieldOptions = {
2 name?: string
3 label?: string
4 type: 'input' | 'input-checkbox' | 'input-password' | 'input-textarea' | 'markdown-text' | 'markdown-enhanced' | 'select' | 'html'
5
6 // For select type
7 options?: { value: string, label: string }[]
8
9 // For html type
10 html?: string
11
12 descriptionHTML?: string
13
14 // Default setting value
15 default?: string | boolean
16
17 // Not supported by plugin setting registration, use registerSettingsScript instead
18 hidden?: (options: any) => boolean
19}
20
21export interface RegisterClientVideoFieldOptions {
22 type: 'update' | 'upload' | 'import-url' | 'import-torrent' | 'go-live'
23}
diff --git a/shared/models/plugins/client/register-client-hook.model.ts b/shared/models/plugins/client/register-client-hook.model.ts
new file mode 100644
index 000000000..81047b21d
--- /dev/null
+++ b/shared/models/plugins/client/register-client-hook.model.ts
@@ -0,0 +1,7 @@
1import { ClientHookName } from './client-hook.model'
2
3export interface RegisterClientHookOptions {
4 target: ClientHookName
5 handler: Function
6 priority?: number
7}
diff --git a/shared/models/plugins/client/register-client-settings-script.model.ts b/shared/models/plugins/client/register-client-settings-script.model.ts
new file mode 100644
index 000000000..481ceef96
--- /dev/null
+++ b/shared/models/plugins/client/register-client-settings-script.model.ts
@@ -0,0 +1,8 @@
1import { RegisterServerSettingOptions } from '../server'
2
3export interface RegisterClientSettingsScript {
4 isSettingHidden (options: {
5 setting: RegisterServerSettingOptions
6 formValues: { [name: string]: any }
7 }): boolean
8}