Move delete, delete & redraft actions to options

This commit is contained in:
kimsible 2020-08-07 17:49:56 +02:00 committed by Chocobozzz
parent f63c03fb6e
commit 45ae994a44
3 changed files with 32 additions and 16 deletions

View File

@ -41,12 +41,10 @@
></div>
<div class="comment-actions">
<div *ngIf="isUserLoggedIn()" (click)="onWantToReply()" class="comment-action-reply" i18n>Reply</div>
<div *ngIf="isRemovableByUser()" (click)="onWantToDelete()" class="comment-action-delete" i18n>Delete</div>
<div *ngIf="isRedraftableByUser()" (click)="onWantToRedraft()" class="comment-action-redraft" i18n>Delete & re-draft</div>
<div *ngIf="isUserLoggedIn()" tabindex=0 (click)="onWantToReply()" class="comment-action-reply" i18n>Reply</div>
<my-user-moderation-dropdown
[prependActions]="prependModerationActions"
[prependActions]="prependModerationActions" tabindex=0
buttonSize="small" [account]="commentAccount" [user]="commentUser" i18n-label label="Options" placement="bottom-left auto"
></my-user-moderation-dropdown>
</div>

View File

@ -118,14 +118,12 @@
display: flex;
::ng-deep .dropdown-toggle,
.comment-action-reply,
.comment-action-delete,
.comment-action-redraft {
.comment-action-reply {
color: pvar(--greyForegroundColor);
cursor: pointer;
margin-right: 10px;
&:hover {
&:hover, &:active, &:focus, &:focus-visible {
color: pvar(--mainForegroundColor);
}
}

View File

@ -115,6 +115,10 @@ export class VideoCommentComponent implements OnInit, OnChanges {
return this.comment.account && this.isUserLoggedIn() && this.user.account.id === this.comment.account.id && this.comment.totalReplies === 0
}
isReportableByUser() {
return this.comment.account && this.isUserLoggedIn() && this.comment.isDeleted === false && this.authService.getUser().account.id !== this.comment.account.id
}
switchToDefaultAvatar ($event: Event) {
($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL()
}
@ -146,14 +150,30 @@ export class VideoCommentComponent implements OnInit, OnChanges {
this.comment.account = null
}
if (this.isUserLoggedIn() && this.comment.isDeleted === false && this.authService.getUser().account.id !== this.comment.account.id) {
this.prependModerationActions = [
{
label: $localize`Report comment`,
handler: () => this.showReportModal()
}
]
} else {
this.prependModerationActions = []
if (this.isReportableByUser()) {
this.prependModerationActions.push({
label: $localize`Report comment`,
handler: () => this.showReportModal()
})
}
if (this.isRemovableByUser()) {
this.prependModerationActions.push({
label: $localize`Remove comment`,
handler: () => this.onWantToDelete()
})
}
if (this.isRedraftableByUser()) {
this.prependModerationActions.push({
label: $localize`Remove & re-draft comment`,
handler: () => this.onWantToRedraft()
})
}
if (this.prependModerationActions.length === 0) {
this.prependModerationActions = undefined
}
}