]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
Support ICU in TS components
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-video-miniature / video-actions-dropdown.component.ts
index 2ab9f47390db618455449ca5543fa4e81069ce4f..ed6a4afc0f90c3980c0531f2fe223c91a33e38ef 100644 (file)
@@ -1,8 +1,8 @@
 import { Component, EventEmitter, Input, OnChanges, Output, ViewChild } from '@angular/core'
-import { AuthService, ConfirmService, Notifier, ScreenService } from '@app/core'
+import { AuthService, ConfirmService, Notifier, ScreenService, ServerService } from '@app/core'
 import { BlocklistService, VideoBlockComponent, VideoBlockService, VideoReportComponent } from '@app/shared/shared-moderation'
 import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap'
-import { UserRight, VideoCaption, VideoState } from '@shared/models'
+import { VideoCaption } from '@shared/models'
 import {
   Actor,
   DropdownAction,
@@ -29,6 +29,8 @@ export type VideoActionsDisplayType = {
   liveInfo?: boolean
   removeFiles?: boolean
   transcoding?: boolean
+  studio?: boolean
+  stats?: boolean
 }
 
 @Component({
@@ -59,9 +61,12 @@ export class VideoActionsDropdownComponent implements OnChanges {
     mute: true,
     liveInfo: false,
     removeFiles: false,
-    transcoding: false
+    transcoding: false,
+    studio: true,
+    stats: true
   }
   @Input() placement = 'left'
+  @Input() moreActions: DropdownAction<{ video: Video }>[][] = []
 
   @Input() label: string
 
@@ -89,7 +94,8 @@ export class VideoActionsDropdownComponent implements OnChanges {
     private videoBlocklistService: VideoBlockService,
     private screenService: ScreenService,
     private videoService: VideoService,
-    private redundancyService: RedundancyService
+    private redundancyService: RedundancyService,
+    private serverService: ServerService
   ) { }
 
   get user () {
@@ -149,6 +155,14 @@ export class VideoActionsDropdownComponent implements OnChanges {
     return this.video.isUpdatableBy(this.user)
   }
 
+  isVideoEditable () {
+    return this.video.isEditableBy(this.user, this.serverService.getHTMLConfig().videoStudio.enabled)
+  }
+
+  isVideoStatsAvailable () {
+    return this.video.canSeeStats(this.user)
+  }
+
   isVideoRemovable () {
     return this.video.isRemovableBy(this.user)
   }
@@ -329,6 +343,18 @@ export class VideoActionsDropdownComponent implements OnChanges {
           iconName: 'edit',
           isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.update && this.isVideoUpdatable()
         },
+        {
+          label: $localize`Studio`,
+          linkBuilder: ({ video }) => [ '/studio/edit', video.uuid ],
+          iconName: 'film',
+          isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.studio && this.isVideoEditable()
+        },
+        {
+          label: $localize`Stats`,
+          linkBuilder: ({ video }) => [ '/stats/videos', video.uuid ],
+          iconName: 'stats',
+          isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.stats && this.isVideoStatsAvailable()
+        },
         {
           label: $localize`Block`,
           handler: () => this.showBlockModal(),
@@ -395,5 +421,7 @@ export class VideoActionsDropdownComponent implements OnChanges {
         }
       ]
     ]
+
+    this.videoActions = this.videoActions.concat(this.moreActions)
   }
 }