diff options
Diffstat (limited to 'client/src/app/shared/shared-main')
7 files changed, 43 insertions, 6 deletions
diff --git a/client/src/app/shared/shared-main/angular/index.ts b/client/src/app/shared/shared-main/angular/index.ts index 4b87c2952..f72d60313 100644 --- a/client/src/app/shared/shared-main/angular/index.ts +++ b/client/src/app/shared/shared-main/angular/index.ts | |||
@@ -5,5 +5,6 @@ export * from './duration-formatter.pipe' | |||
5 | export * from './from-now.pipe' | 5 | export * from './from-now.pipe' |
6 | export * from './infinite-scroller.directive' | 6 | export * from './infinite-scroller.directive' |
7 | export * from './link.component' | 7 | export * from './link.component' |
8 | export * from './login-link.component' | ||
8 | export * from './number-formatter.pipe' | 9 | export * from './number-formatter.pipe' |
9 | export * from './peertube-template.directive' | 10 | export * from './peertube-template.directive' |
diff --git a/client/src/app/shared/shared-main/angular/link.component.html b/client/src/app/shared/shared-main/angular/link.component.html index e61a1e085..2ea2df2b5 100644 --- a/client/src/app/shared/shared-main/angular/link.component.html +++ b/client/src/app/shared/shared-main/angular/link.component.html | |||
@@ -2,10 +2,10 @@ | |||
2 | <ng-content></ng-content> | 2 | <ng-content></ng-content> |
3 | </ng-template> | 3 | </ng-template> |
4 | 4 | ||
5 | <a *ngIf="!href" [routerLink]="internalLink" [attr.title]="title" [tabindex]="tabindex"> | 5 | <a *ngIf="!href" [routerLink]="internalLink" [attr.title]="title" [tabindex]="tabindex" [ngClass]="builtClasses"> |
6 | <ng-template *ngTemplateOutlet="content"></ng-template> | 6 | <ng-template *ngTemplateOutlet="content"></ng-template> |
7 | </a> | 7 | </a> |
8 | 8 | ||
9 | <a *ngIf="href" [href]="href" [target]="target" [attr.title]="title" [tabindex]="tabindex"> | 9 | <a *ngIf="href" [href]="href" [target]="target" [attr.title]="title" [tabindex]="tabindex" [ngClass]="builtClasses"> |
10 | <ng-template *ngTemplateOutlet="content"></ng-template> | 10 | <ng-template *ngTemplateOutlet="content"></ng-template> |
11 | </a> | 11 | </a> |
diff --git a/client/src/app/shared/shared-main/angular/link.component.scss b/client/src/app/shared/shared-main/angular/link.component.scss index bb86d5488..f54240d31 100644 --- a/client/src/app/shared/shared-main/angular/link.component.scss +++ b/client/src/app/shared/shared-main/angular/link.component.scss | |||
@@ -1,4 +1,4 @@ | |||
1 | a { | 1 | .no-class { |
2 | color: inherit; | 2 | color: inherit; |
3 | text-decoration: inherit; | 3 | text-decoration: inherit; |
4 | position: inherit; | 4 | position: inherit; |
diff --git a/client/src/app/shared/shared-main/angular/link.component.ts b/client/src/app/shared/shared-main/angular/link.component.ts index ecbd9151c..1f5975589 100644 --- a/client/src/app/shared/shared-main/angular/link.component.ts +++ b/client/src/app/shared/shared-main/angular/link.component.ts | |||
@@ -1,17 +1,27 @@ | |||
1 | import { Component, Input } from '@angular/core' | 1 | import { Component, Input, OnInit } from '@angular/core' |
2 | 2 | ||
3 | @Component({ | 3 | @Component({ |
4 | selector: 'my-link', | 4 | selector: 'my-link', |
5 | styleUrls: [ './link.component.scss' ], | 5 | styleUrls: [ './link.component.scss' ], |
6 | templateUrl: './link.component.html' | 6 | templateUrl: './link.component.html' |
7 | }) | 7 | }) |
8 | export class LinkComponent { | 8 | export class LinkComponent implements OnInit { |
9 | @Input() internalLink?: string | any[] | 9 | @Input() internalLink?: string | any[] |
10 | 10 | ||
11 | @Input() href?: string | 11 | @Input() href?: string |
12 | @Input() target?: string | 12 | @Input() target = '_self' |
13 | 13 | ||
14 | @Input() title?: string | 14 | @Input() title?: string |
15 | 15 | ||
16 | @Input() className?: string | ||
17 | |||
16 | @Input() tabindex: string | number | 18 | @Input() tabindex: string | number |
19 | |||
20 | builtClasses: string | ||
21 | |||
22 | ngOnInit () { | ||
23 | this.builtClasses = this.className | ||
24 | ? this.className | ||
25 | : 'no-class' | ||
26 | } | ||
17 | } | 27 | } |
diff --git a/client/src/app/shared/shared-main/angular/login-link.component.html b/client/src/app/shared/shared-main/angular/login-link.component.html new file mode 100644 index 000000000..f90ffba68 --- /dev/null +++ b/client/src/app/shared/shared-main/angular/login-link.component.html | |||
@@ -0,0 +1 @@ | |||
<my-link i18n internalLink="/login" [href]="getExternalLoginHref()" [className]="className">{{ label }}</my-link> | |||
diff --git a/client/src/app/shared/shared-main/angular/login-link.component.ts b/client/src/app/shared/shared-main/angular/login-link.component.ts new file mode 100644 index 000000000..7e3a773c2 --- /dev/null +++ b/client/src/app/shared/shared-main/angular/login-link.component.ts | |||
@@ -0,0 +1,22 @@ | |||
1 | import { environment } from 'src/environments/environment' | ||
2 | import { Component, Input } from '@angular/core' | ||
3 | import { ServerService } from '@app/core' | ||
4 | import { PluginsManager } from '@root-helpers/plugins-manager' | ||
5 | |||
6 | @Component({ | ||
7 | selector: 'my-login-link', | ||
8 | templateUrl: './login-link.component.html' | ||
9 | }) | ||
10 | export class LoginLinkComponent { | ||
11 | @Input() label = $localize`Login` | ||
12 | |||
13 | @Input() className?: string | ||
14 | |||
15 | constructor (private server: ServerService) { | ||
16 | |||
17 | } | ||
18 | |||
19 | getExternalLoginHref () { | ||
20 | return PluginsManager.getDefaultLoginHref(environment.apiUrl, this.server.getHTMLConfig()) | ||
21 | } | ||
22 | } | ||
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 eb1642d97..0bdf27263 100644 --- a/client/src/app/shared/shared-main/shared-main.module.ts +++ b/client/src/app/shared/shared-main/shared-main.module.ts | |||
@@ -25,6 +25,7 @@ import { | |||
25 | FromNowPipe, | 25 | FromNowPipe, |
26 | InfiniteScrollerDirective, | 26 | InfiniteScrollerDirective, |
27 | LinkComponent, | 27 | LinkComponent, |
28 | LoginLinkComponent, | ||
28 | NumberFormatterPipe, | 29 | NumberFormatterPipe, |
29 | PeerTubeTemplateDirective | 30 | PeerTubeTemplateDirective |
30 | } from './angular' | 31 | } from './angular' |
@@ -92,6 +93,7 @@ import { VideoChannelService } from './video-channel' | |||
92 | InfiniteScrollerDirective, | 93 | InfiniteScrollerDirective, |
93 | PeerTubeTemplateDirective, | 94 | PeerTubeTemplateDirective, |
94 | LinkComponent, | 95 | LinkComponent, |
96 | LoginLinkComponent, | ||
95 | 97 | ||
96 | ActionDropdownComponent, | 98 | ActionDropdownComponent, |
97 | ButtonComponent, | 99 | ButtonComponent, |
@@ -152,6 +154,7 @@ import { VideoChannelService } from './video-channel' | |||
152 | InfiniteScrollerDirective, | 154 | InfiniteScrollerDirective, |
153 | PeerTubeTemplateDirective, | 155 | PeerTubeTemplateDirective, |
154 | LinkComponent, | 156 | LinkComponent, |
157 | LoginLinkComponent, | ||
155 | 158 | ||
156 | ActionDropdownComponent, | 159 | ActionDropdownComponent, |
157 | ButtonComponent, | 160 | ButtonComponent, |