diff options
author | Chocobozzz <me@florianbigard.com> | 2021-11-26 17:36:44 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-11-26 17:36:55 +0100 |
commit | 8afade2607e072221a8ff8c108bd1787a3501a2d (patch) | |
tree | cb4b3724cf38076cfd5850be727535a92e85fab3 /client/src/app/shared | |
parent | 7137377d097a74087ed062c8071c1aa5c717c7f7 (diff) | |
download | PeerTube-8afade2607e072221a8ff8c108bd1787a3501a2d.tar.gz PeerTube-8afade2607e072221a8ff8c108bd1787a3501a2d.tar.zst PeerTube-8afade2607e072221a8ff8c108bd1787a3501a2d.zip |
Introduce plugin id selectors
Diffstat (limited to 'client/src/app/shared')
3 files changed, 27 insertions, 3 deletions
diff --git a/client/src/app/shared/shared-main/plugins/index.ts b/client/src/app/shared/shared-main/plugins/index.ts index f36dab624..f45ed9b73 100644 --- a/client/src/app/shared/shared-main/plugins/index.ts +++ b/client/src/app/shared/shared-main/plugins/index.ts | |||
@@ -1 +1,2 @@ | |||
1 | export * from './plugin-placeholder.component' | 1 | export * from './plugin-placeholder.component' |
2 | export * from './plugin-selector.directive' | ||
diff --git a/client/src/app/shared/shared-main/plugins/plugin-selector.directive.ts b/client/src/app/shared/shared-main/plugins/plugin-selector.directive.ts new file mode 100644 index 000000000..576569f19 --- /dev/null +++ b/client/src/app/shared/shared-main/plugins/plugin-selector.directive.ts | |||
@@ -0,0 +1,21 @@ | |||
1 | import { Directive, ElementRef, Input, OnInit, Renderer2 } from '@angular/core' | ||
2 | import { PluginSelectorId } from '@shared/models' | ||
3 | |||
4 | @Directive({ selector: '[myPluginSelector]' }) | ||
5 | export class PluginSelectorDirective implements OnInit { | ||
6 | @Input() pluginSelectorId: PluginSelectorId | ||
7 | |||
8 | constructor ( | ||
9 | private renderer: Renderer2, | ||
10 | private hostElement: ElementRef<HTMLElement> | ||
11 | ) { | ||
12 | |||
13 | } | ||
14 | |||
15 | ngOnInit () { | ||
16 | const id = this.hostElement.nativeElement.getAttribute('id') | ||
17 | if (id) throw new Error('Cannot set id on element that already has an id') | ||
18 | |||
19 | this.renderer.setAttribute(this.hostElement.nativeElement, 'id', `plugin-selector-${this.pluginSelectorId}`) | ||
20 | } | ||
21 | } | ||
diff --git a/client/src/app/shared/shared-main/shared-main.module.ts b/client/src/app/shared/shared-main/shared-main.module.ts index a90b59e41..10fc364b3 100644 --- a/client/src/app/shared/shared-main/shared-main.module.ts +++ b/client/src/app/shared/shared-main/shared-main.module.ts | |||
@@ -41,7 +41,7 @@ import { | |||
41 | SimpleSearchInputComponent, | 41 | SimpleSearchInputComponent, |
42 | TopMenuDropdownComponent | 42 | TopMenuDropdownComponent |
43 | } from './misc' | 43 | } from './misc' |
44 | import { PluginPlaceholderComponent } from './plugins' | 44 | import { PluginPlaceholderComponent, PluginSelectorDirective } from './plugins' |
45 | import { ActorRedirectGuard } from './router' | 45 | import { ActorRedirectGuard } from './router' |
46 | import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users' | 46 | import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users' |
47 | import { EmbedComponent, RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video' | 47 | import { EmbedComponent, RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video' |
@@ -108,7 +108,8 @@ import { VideoChannelService } from './video-channel' | |||
108 | 108 | ||
109 | EmbedComponent, | 109 | EmbedComponent, |
110 | 110 | ||
111 | PluginPlaceholderComponent | 111 | PluginPlaceholderComponent, |
112 | PluginSelectorDirective | ||
112 | ], | 113 | ], |
113 | 114 | ||
114 | exports: [ | 115 | exports: [ |
@@ -166,7 +167,8 @@ import { VideoChannelService } from './video-channel' | |||
166 | 167 | ||
167 | EmbedComponent, | 168 | EmbedComponent, |
168 | 169 | ||
169 | PluginPlaceholderComponent | 170 | PluginPlaceholderComponent, |
171 | PluginSelectorDirective | ||
170 | ], | 172 | ], |
171 | 173 | ||
172 | providers: [ | 174 | providers: [ |