aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-11-26 17:36:44 +0100
committerChocobozzz <me@florianbigard.com>2021-11-26 17:36:55 +0100
commit8afade2607e072221a8ff8c108bd1787a3501a2d (patch)
treecb4b3724cf38076cfd5850be727535a92e85fab3 /client
parent7137377d097a74087ed062c8071c1aa5c717c7f7 (diff)
downloadPeerTube-8afade2607e072221a8ff8c108bd1787a3501a2d.tar.gz
PeerTube-8afade2607e072221a8ff8c108bd1787a3501a2d.tar.zst
PeerTube-8afade2607e072221a8ff8c108bd1787a3501a2d.zip
Introduce plugin id selectors
Diffstat (limited to 'client')
-rw-r--r--client/src/app/+login/login.component.html2
-rw-r--r--client/src/app/shared/shared-main/plugins/index.ts1
-rw-r--r--client/src/app/shared/shared-main/plugins/plugin-selector.directive.ts21
-rw-r--r--client/src/app/shared/shared-main/shared-main.module.ts8
4 files changed, 28 insertions, 4 deletions
diff --git a/client/src/app/+login/login.component.html b/client/src/app/+login/login.component.html
index 0be67368e..90eea1505 100644
--- a/client/src/app/+login/login.component.html
+++ b/client/src/app/+login/login.component.html
@@ -15,7 +15,7 @@
15 <div class="wrapper"> 15 <div class="wrapper">
16 <div class="login-form-and-externals"> 16 <div class="login-form-and-externals">
17 17
18 <form role="form" (ngSubmit)="login()" [formGroup]="form"> 18 <form myPluginSelector pluginSelectorId="login-form" role="form" (ngSubmit)="login()" [formGroup]="form">
19 <div class="form-group"> 19 <div class="form-group">
20 <div> 20 <div>
21 <label i18n for="username">User</label> 21 <label i18n for="username">User</label>
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 @@
1export * from './plugin-placeholder.component' 1export * from './plugin-placeholder.component'
2export * 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 @@
1import { Directive, ElementRef, Input, OnInit, Renderer2 } from '@angular/core'
2import { PluginSelectorId } from '@shared/models'
3
4@Directive({ selector: '[myPluginSelector]' })
5export 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'
44import { PluginPlaceholderComponent } from './plugins' 44import { PluginPlaceholderComponent, PluginSelectorDirective } from './plugins'
45import { ActorRedirectGuard } from './router' 45import { ActorRedirectGuard } from './router'
46import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users' 46import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users'
47import { EmbedComponent, RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video' 47import { 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: [