diff options
author | Kim <1877318+kimsible@users.noreply.github.com> | 2020-04-15 15:35:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-15 15:35:41 +0200 |
commit | 437e8e06eb32ffe21111f0946115aae0e4c33381 (patch) | |
tree | c221f0c41b4d29de00f4a3318393c32a83b02fe5 /client/src/app/core | |
parent | 45c14ae1b2884e75c6341117489ea39ae0e1a3bc (diff) | |
download | PeerTube-437e8e06eb32ffe21111f0946115aae0e4c33381.tar.gz PeerTube-437e8e06eb32ffe21111f0946115aae0e4c33381.tar.zst PeerTube-437e8e06eb32ffe21111f0946115aae0e4c33381.zip |
Add custom modal to plugin helpers (#2631)
* Add custom modal component
* Add custom modal to app and plugins helpers
* Fixes custom modal component
* Add doc for custom modal
* Fix newline end of file html and scss files
* Move my-custom-modal component outside component for UserLoggedIn modals
* Move initializeCustomModal to ngAfterViewInit()
* Wrap events and conditionnals
* Replace ng-show with ngIf*
* Add modalRef to open only one modal + onCloseClick
* Refacto + Fix access methods of custom modal
* Fix methods names custom-modal.component
* Fix implement AfterViewInit & no default boolean
Co-authored-by: kimsible <kimsible@users.noreply.github.com>
Diffstat (limited to 'client/src/app/core')
-rw-r--r-- | client/src/app/core/plugins/plugin.service.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index aa6823060..b4ed56cbe 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts | |||
@@ -20,6 +20,7 @@ import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils' | |||
20 | import { RegisterClientHelpers } from '../../../types/register-client-option.model' | 20 | import { RegisterClientHelpers } from '../../../types/register-client-option.model' |
21 | import { PluginTranslation } from '@shared/models/plugins/plugin-translation.model' | 21 | import { PluginTranslation } from '@shared/models/plugins/plugin-translation.model' |
22 | import { importModule } from '@app/shared/misc/utils' | 22 | import { importModule } from '@app/shared/misc/utils' |
23 | import { CustomModalComponent } from '@app/modal/custom-modal.component' | ||
23 | 24 | ||
24 | interface HookStructValue extends RegisterClientHookOptions { | 25 | interface HookStructValue extends RegisterClientHookOptions { |
25 | plugin: ServerConfigPlugin | 26 | plugin: ServerConfigPlugin |
@@ -49,6 +50,8 @@ export class PluginService implements ClientHook { | |||
49 | 50 | ||
50 | translationsObservable: Observable<PluginTranslation> | 51 | translationsObservable: Observable<PluginTranslation> |
51 | 52 | ||
53 | customModal: CustomModalComponent | ||
54 | |||
52 | private plugins: ServerConfigPlugin[] = [] | 55 | private plugins: ServerConfigPlugin[] = [] |
53 | private scopes: { [ scopeName: string ]: PluginInfo[] } = {} | 56 | private scopes: { [ scopeName: string ]: PluginInfo[] } = {} |
54 | private loadedScripts: { [ script: string ]: boolean } = {} | 57 | private loadedScripts: { [ script: string ]: boolean } = {} |
@@ -81,6 +84,10 @@ export class PluginService implements ClientHook { | |||
81 | }) | 84 | }) |
82 | } | 85 | } |
83 | 86 | ||
87 | initializeCustomModal (customModal: CustomModalComponent) { | ||
88 | this.customModal = customModal | ||
89 | } | ||
90 | |||
84 | ensurePluginsAreBuilt () { | 91 | ensurePluginsAreBuilt () { |
85 | return this.pluginsBuilt.asObservable() | 92 | return this.pluginsBuilt.asObservable() |
86 | .pipe(first(), shareReplay()) | 93 | .pipe(first(), shareReplay()) |
@@ -279,6 +286,16 @@ export class PluginService implements ClientHook { | |||
279 | success: (text: string, title?: string, timeout?: number) => this.notifier.success(text, title, timeout) | 286 | success: (text: string, title?: string, timeout?: number) => this.notifier.success(text, title, timeout) |
280 | }, | 287 | }, |
281 | 288 | ||
289 | showModal: (input: { | ||
290 | title: string, | ||
291 | content: string, | ||
292 | close?: boolean, | ||
293 | cancel?: { value: string, action?: () => void }, | ||
294 | confirm?: { value: string, action?: () => void } | ||
295 | }) => { | ||
296 | this.customModal.show(input) | ||
297 | }, | ||
298 | |||
282 | translate: (value: string) => { | 299 | translate: (value: string) => { |
283 | return this.translationsObservable | 300 | return this.translationsObservable |
284 | .pipe(map(allTranslations => allTranslations[npmName])) | 301 | .pipe(map(allTranslations => allTranslations[npmName])) |