diff options
author | Chocobozzz <me@florianbigard.com> | 2020-01-22 15:01:38 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-01-22 15:01:38 +0100 |
commit | fef213cae10cbbf760b5ec81a1ed154038b59a61 (patch) | |
tree | 94ec1db206d56bd4a474f55bef02a39cba617880 /client/src | |
parent | 0736b2735f3dcbaa17304fa229f0973e70f763b8 (diff) | |
download | PeerTube-fef213cae10cbbf760b5ec81a1ed154038b59a61.tar.gz PeerTube-fef213cae10cbbf760b5ec81a1ed154038b59a61.tar.zst PeerTube-fef213cae10cbbf760b5ec81a1ed154038b59a61.zip |
Fix is managaeble for channels
Diffstat (limited to 'client/src')
3 files changed, 48 insertions, 33 deletions
diff --git a/client/src/app/+accounts/accounts.component.ts b/client/src/app/+accounts/accounts.component.ts index b06ecfe0e..ad611f221 100644 --- a/client/src/app/+accounts/accounts.component.ts +++ b/client/src/app/+accounts/accounts.component.ts | |||
@@ -35,34 +35,41 @@ export class AccountsComponent implements OnInit, OnDestroy { | |||
35 | private redirectService: RedirectService, | 35 | private redirectService: RedirectService, |
36 | private authService: AuthService, | 36 | private authService: AuthService, |
37 | private i18n: I18n | 37 | private i18n: I18n |
38 | ) {} | 38 | ) { |
39 | } | ||
39 | 40 | ||
40 | ngOnInit () { | 41 | ngOnInit () { |
41 | this.routeSub = this.route.params | 42 | this.routeSub = this.route.params |
42 | .pipe( | 43 | .pipe( |
43 | map(params => params[ 'accountId' ]), | 44 | map(params => params[ 'accountId' ]), |
44 | distinctUntilChanged(), | 45 | distinctUntilChanged(), |
45 | switchMap(accountId => this.accountService.getAccount(accountId)), | 46 | switchMap(accountId => this.accountService.getAccount(accountId)), |
46 | tap(account => { | 47 | tap(account => { |
47 | this.account = account | 48 | this.account = account |
48 | 49 | ||
49 | this.isAccountManageable = this.account.userId && this.account.userId === this.authService.getUser().id | 50 | if (this.authService.isLoggedIn()) { |
50 | 51 | this.authService.userInformationLoaded.subscribe( | |
51 | this.accountFollowerTitle = this.i18n( | 52 | () => { |
52 | '{{followers}} direct account followers', | 53 | this.isAccountManageable = this.account.userId && this.account.userId === this.authService.getUser().id |
53 | { followers: this.subscribersDisplayFor(account.followersCount) } | 54 | |
54 | ) | 55 | this.accountFollowerTitle = this.i18n( |
55 | 56 | '{{followers}} direct account followers', | |
56 | this.getUserIfNeeded(account) | 57 | { followers: this.subscribersDisplayFor(account.followersCount) } |
57 | }), | 58 | ) |
58 | switchMap(account => this.videoChannelService.listAccountVideoChannels(account)), | 59 | } |
59 | catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ])) | 60 | ) |
60 | ) | 61 | } |
61 | .subscribe( | 62 | |
62 | videoChannels => this.videoChannels = videoChannels.data, | 63 | this.getUserIfNeeded(account) |
63 | 64 | }), | |
64 | err => this.notifier.error(err.message) | 65 | switchMap(account => this.videoChannelService.listAccountVideoChannels(account)), |
65 | ) | 66 | catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ])) |
67 | ) | ||
68 | .subscribe( | ||
69 | videoChannels => this.videoChannels = videoChannels.data, | ||
70 | |||
71 | err => this.notifier.error(err.message) | ||
72 | ) | ||
66 | } | 73 | } |
67 | 74 | ||
68 | ngOnDestroy () { | 75 | ngOnDestroy () { |
@@ -97,11 +104,8 @@ export class AccountsComponent implements OnInit, OnDestroy { | |||
97 | 104 | ||
98 | const user = this.authService.getUser() | 105 | const user = this.authService.getUser() |
99 | if (user.hasRight(UserRight.MANAGE_USERS)) { | 106 | if (user.hasRight(UserRight.MANAGE_USERS)) { |
100 | forkJoin([ | 107 | this.userService.getUser(account.userId).subscribe( |
101 | this.userService.getUser(account.userId), | 108 | accountUser => this.accountUser = accountUser, |
102 | this.authService.userInformationLoaded.pipe(first()) | ||
103 | ]).subscribe( | ||
104 | ([ accountUser ]) => this.accountUser = accountUser, | ||
105 | 109 | ||
106 | err => this.notifier.error(err.message) | 110 | err => this.notifier.error(err.message) |
107 | ) | 111 | ) |
diff --git a/client/src/app/+video-channels/video-channels.component.html b/client/src/app/+video-channels/video-channels.component.html index 065fc2c04..f0bb083ca 100644 --- a/client/src/app/+video-channels/video-channels.component.html +++ b/client/src/app/+video-channels/video-channels.component.html | |||
@@ -16,7 +16,7 @@ | |||
16 | </div> | 16 | </div> |
17 | 17 | ||
18 | <div class="right-buttons"> | 18 | <div class="right-buttons"> |
19 | <a *ngIf="isManageable" [routerLink]="[ '/my-account/video-channels/update', videoChannel.nameWithHost ]" class="btn btn-outline-tertiary mr-2" i18n>Manage</a> | 19 | <a *ngIf="isChannelManageable" [routerLink]="[ '/my-account/video-channels/update', videoChannel.nameWithHost ]" class="btn btn-outline-tertiary mr-2" i18n>Manage</a> |
20 | <my-subscribe-button #subscribeButton [videoChannels]="[videoChannel]"></my-subscribe-button> | 20 | <my-subscribe-button #subscribeButton [videoChannels]="[videoChannel]"></my-subscribe-button> |
21 | </div> | 21 | </div> |
22 | </div> | 22 | </div> |
diff --git a/client/src/app/+video-channels/video-channels.component.ts b/client/src/app/+video-channels/video-channels.component.ts index 493a6d499..7b335b13f 100644 --- a/client/src/app/+video-channels/video-channels.component.ts +++ b/client/src/app/+video-channels/video-channels.component.ts | |||
@@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router' | |||
3 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | 3 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' |
4 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' | 4 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' |
5 | import { RestExtractor } from '@app/shared' | 5 | import { RestExtractor } from '@app/shared' |
6 | import { catchError, distinctUntilChanged, map, switchMap } from 'rxjs/operators' | 6 | import { catchError, distinctUntilChanged, map, switchMap, tap } from 'rxjs/operators' |
7 | import { Subscription } from 'rxjs' | 7 | import { Subscription } from 'rxjs' |
8 | import { AuthService, Notifier } from '@app/core' | 8 | import { AuthService, Notifier } from '@app/core' |
9 | import { Hotkey, HotkeysService } from 'angular2-hotkeys' | 9 | import { Hotkey, HotkeysService } from 'angular2-hotkeys' |
@@ -19,6 +19,7 @@ export class VideoChannelsComponent implements OnInit, OnDestroy { | |||
19 | 19 | ||
20 | videoChannel: VideoChannel | 20 | videoChannel: VideoChannel |
21 | hotkeys: Hotkey[] | 21 | hotkeys: Hotkey[] |
22 | isChannelManageable = false | ||
22 | 23 | ||
23 | private routeSub: Subscription | 24 | private routeSub: Subscription |
24 | 25 | ||
@@ -40,7 +41,17 @@ export class VideoChannelsComponent implements OnInit, OnDestroy { | |||
40 | switchMap(videoChannelName => this.videoChannelService.getVideoChannel(videoChannelName)), | 41 | switchMap(videoChannelName => this.videoChannelService.getVideoChannel(videoChannelName)), |
41 | catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ])) | 42 | catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ])) |
42 | ) | 43 | ) |
43 | .subscribe(videoChannel => this.videoChannel = videoChannel) | 44 | .subscribe(videoChannel => { |
45 | this.videoChannel = videoChannel | ||
46 | |||
47 | if (this.authService.isLoggedIn()) { | ||
48 | this.authService.userInformationLoaded | ||
49 | .subscribe(() => { | ||
50 | const channelUserId = this.videoChannel.ownerAccount.userId | ||
51 | this.isChannelManageable = channelUserId && channelUserId === this.authService.getUser().id | ||
52 | }) | ||
53 | } | ||
54 | }) | ||
44 | 55 | ||
45 | this.hotkeys = [ | 56 | this.hotkeys = [ |
46 | new Hotkey('S', (event: KeyboardEvent): boolean => { | 57 | new Hotkey('S', (event: KeyboardEvent): boolean => { |