Fix is managaeble error
This commit is contained in:
parent
36619ac8f5
commit
496b02e38f
|
@ -16,24 +16,24 @@
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<span *ngIf="user?.blocked" [ngbTooltip]="user.blockedReason" class="badge badge-danger" i18n>Banned</span>
|
<span *ngIf="accountUser?.blocked" [ngbTooltip]="accountUser.blockedReason" class="badge badge-danger" i18n>Banned</span>
|
||||||
<span *ngIf="account.mutedByUser" class="badge badge-danger" i18n>Muted</span>
|
<span *ngIf="account.mutedByUser" class="badge badge-danger" i18n>Muted</span>
|
||||||
<span *ngIf="account.mutedServerByUser" class="badge badge-danger" i18n>Instance muted</span>
|
<span *ngIf="account.mutedServerByUser" class="badge badge-danger" i18n>Instance muted</span>
|
||||||
<span *ngIf="account.mutedByInstance" class="badge badge-danger" i18n>Muted by your instance</span>
|
<span *ngIf="account.mutedByInstance" class="badge badge-danger" i18n>Muted by your instance</span>
|
||||||
<span *ngIf="account.mutedServerByInstance" class="badge badge-danger" i18n>Instance muted by your instance</span>
|
<span *ngIf="account.mutedServerByInstance" class="badge badge-danger" i18n>Instance muted by your instance</span>
|
||||||
|
|
||||||
<my-user-moderation-dropdown
|
<my-user-moderation-dropdown
|
||||||
buttonSize="small" [account]="account" [user]="user" placement="bottom-left auto"
|
buttonSize="small" [account]="account" [user]="accountUser" placement="bottom-left auto"
|
||||||
(userChanged)="onUserChanged()" (userDeleted)="onUserDeleted()"
|
(userChanged)="onUserChanged()" (userDeleted)="onUserDeleted()"
|
||||||
></my-user-moderation-dropdown>
|
></my-user-moderation-dropdown>
|
||||||
</div>
|
</div>
|
||||||
<div class="actor-followers" i18n-title [title]="subscribersDisplayFor(account.followersCount) + ' to the account actor'">
|
<div class="actor-followers" [title]="accountFollowerTitle">
|
||||||
{{ subscribersDisplayFor(naiveAggregatedSubscribers) }}
|
{{ subscribersDisplayFor(naiveAggregatedSubscribers) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="right-buttons">
|
<div class="right-buttons">
|
||||||
<a *ngIf="isManageable" routerLink="/my-account" class="btn btn-outline-tertiary mr-2" i18n>Manage</a>
|
<a *ngIf="isAccountManageable" routerLink="/my-account" class="btn btn-outline-tertiary mr-2" i18n>Manage</a>
|
||||||
<my-subscribe-button *ngIf="videoChannels" [account]="account" [videoChannels]="videoChannels"></my-subscribe-button>
|
<my-subscribe-button *ngIf="videoChannels" [account]="account" [videoChannels]="videoChannels"></my-subscribe-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -17,12 +17,10 @@
|
||||||
|
|
||||||
a {
|
a {
|
||||||
@include peertube-button-outline;
|
@include peertube-button-outline;
|
||||||
height: auto;
|
|
||||||
line-height: 32px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my-subscribe-button {
|
my-subscribe-button {
|
||||||
height: min-content;
|
min-height: 30px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ import { ActivatedRoute } from '@angular/router'
|
||||||
import { AccountService } from '@app/shared/account/account.service'
|
import { AccountService } from '@app/shared/account/account.service'
|
||||||
import { Account } from '@app/shared/account/account.model'
|
import { Account } from '@app/shared/account/account.model'
|
||||||
import { RestExtractor, UserService } from '@app/shared'
|
import { RestExtractor, UserService } from '@app/shared'
|
||||||
import { catchError, distinctUntilChanged, map, switchMap, tap } from 'rxjs/operators'
|
import { catchError, distinctUntilChanged, first, map, switchMap, tap } from 'rxjs/operators'
|
||||||
import { Subscription } from 'rxjs'
|
import { forkJoin, Subscription } from 'rxjs'
|
||||||
import { AuthService, Notifier, RedirectService } from '@app/core'
|
import { AuthService, Notifier, RedirectService } from '@app/core'
|
||||||
import { User, UserRight } from '../../../../shared'
|
import { User, UserRight } from '../../../../shared'
|
||||||
import { I18n } from '@ngx-translate/i18n-polyfill'
|
import { I18n } from '@ngx-translate/i18n-polyfill'
|
||||||
|
@ -17,9 +17,12 @@ import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
|
||||||
})
|
})
|
||||||
export class AccountsComponent implements OnInit, OnDestroy {
|
export class AccountsComponent implements OnInit, OnDestroy {
|
||||||
account: Account
|
account: Account
|
||||||
user: User
|
accountUser: User
|
||||||
videoChannels: VideoChannel[] = []
|
videoChannels: VideoChannel[] = []
|
||||||
|
|
||||||
|
isAccountManageable = false
|
||||||
|
accountFollowerTitle = ''
|
||||||
|
|
||||||
private routeSub: Subscription
|
private routeSub: Subscription
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
|
@ -42,6 +45,14 @@ export class AccountsComponent implements OnInit, OnDestroy {
|
||||||
switchMap(accountId => this.accountService.getAccount(accountId)),
|
switchMap(accountId => this.accountService.getAccount(accountId)),
|
||||||
tap(account => {
|
tap(account => {
|
||||||
this.account = account
|
this.account = account
|
||||||
|
|
||||||
|
this.isAccountManageable = this.account.userId && this.account.userId === this.authService.getUser().id
|
||||||
|
|
||||||
|
this.accountFollowerTitle = this.i18n(
|
||||||
|
'{{followers}} direct account followers',
|
||||||
|
{ followers: this.subscribersDisplayFor(account.followersCount) }
|
||||||
|
)
|
||||||
|
|
||||||
this.getUserIfNeeded(account)
|
this.getUserIfNeeded(account)
|
||||||
}),
|
}),
|
||||||
switchMap(account => this.videoChannelService.listAccountVideoChannels(account)),
|
switchMap(account => this.videoChannelService.listAccountVideoChannels(account)),
|
||||||
|
@ -65,11 +76,6 @@ export class AccountsComponent implements OnInit, OnDestroy {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
get isManageable () {
|
|
||||||
if (!this.authService.isLoggedIn()) return false
|
|
||||||
return this.user.id === this.authService.getUser().id
|
|
||||||
}
|
|
||||||
|
|
||||||
onUserChanged () {
|
onUserChanged () {
|
||||||
this.getUserIfNeeded(this.account)
|
this.getUserIfNeeded(this.account)
|
||||||
}
|
}
|
||||||
|
@ -87,17 +93,18 @@ export class AccountsComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getUserIfNeeded (account: Account) {
|
private getUserIfNeeded (account: Account) {
|
||||||
if (!account.userId) return
|
if (!account.userId || !this.authService.isLoggedIn()) return
|
||||||
if (!this.authService.isLoggedIn()) return
|
|
||||||
|
|
||||||
const user = this.authService.getUser()
|
const user = this.authService.getUser()
|
||||||
if (user.hasRight(UserRight.MANAGE_USERS)) {
|
if (user.hasRight(UserRight.MANAGE_USERS)) {
|
||||||
this.userService.getUser(account.userId)
|
forkJoin([
|
||||||
.subscribe(
|
this.userService.getUser(account.userId),
|
||||||
user => this.user = user,
|
this.authService.userInformationLoaded.pipe(first())
|
||||||
|
]).subscribe(
|
||||||
|
([ accountUser ]) => this.accountUser = accountUser,
|
||||||
|
|
||||||
err => this.notifier.error(err.message)
|
err => this.notifier.error(err.message)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue