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/shared-main/plugins | |
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/shared-main/plugins')
-rw-r--r-- | client/src/app/shared/shared-main/plugins/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/shared/shared-main/plugins/plugin-selector.directive.ts | 21 |
2 files changed, 22 insertions, 0 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 | } | ||