]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Move delete, delete & redraft actions to options
authorkimsible <kimsible@users.noreply.github.com>
Fri, 7 Aug 2020 15:49:56 +0000 (17:49 +0200)
committerChocobozzz <chocobozzz@cpy.re>
Fri, 14 Aug 2020 13:03:38 +0000 (15:03 +0200)
client/src/app/+videos/+video-watch/comment/video-comment.component.html
client/src/app/+videos/+video-watch/comment/video-comment.component.scss
client/src/app/+videos/+video-watch/comment/video-comment.component.ts

index fdb555d18e88df4c1ff07e588826d8e0be223dcd..8e44d005226830ac1b8b7c0ee164682fe6e3695b 100644 (file)
         ></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>
index 151e3ba3ac69a1586df76ad3d19c995bb93c214f..61fd24c70972b72df9e14e1b6cce2fac6fa13b45 100644 (file)
       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);
         }
       }
index 50713290969b63800b5a6447ec35800e99210c7c..c2964d3702c122a4700a5c6534c236ae39693edc 100644 (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
     }
   }