]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-video-miniature / video-actions-dropdown.component.ts
index abbfc63f81f814a6ae92fca6fec2dacd50ef5682..ed6a4afc0f90c3980c0531f2fe223c91a33e38ef 100644 (file)
@@ -2,7 +2,7 @@ import { Component, EventEmitter, Input, OnChanges, Output, ViewChild } from '@a
 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 { VideoCaption, VideoState } from '@shared/models'
+import { VideoCaption } from '@shared/models'
 import {
   Actor,
   DropdownAction,
@@ -29,7 +29,8 @@ export type VideoActionsDisplayType = {
   liveInfo?: boolean
   removeFiles?: boolean
   transcoding?: boolean
-  editor?: boolean
+  studio?: boolean
+  stats?: boolean
 }
 
 @Component({
@@ -61,9 +62,11 @@ export class VideoActionsDropdownComponent implements OnChanges {
     liveInfo: false,
     removeFiles: false,
     transcoding: false,
-    editor: true
+    studio: true,
+    stats: true
   }
   @Input() placement = 'left'
+  @Input() moreActions: DropdownAction<{ video: Video }>[][] = []
 
   @Input() label: string
 
@@ -153,9 +156,11 @@ export class VideoActionsDropdownComponent implements OnChanges {
   }
 
   isVideoEditable () {
-    return this.serverService.getHTMLConfig().videoEditor.enabled &&
-      this.video.state?.id === VideoState.PUBLISHED &&
-      this.video.isUpdatableBy(this.user)
+    return this.video.isEditableBy(this.user, this.serverService.getHTMLConfig().videoStudio.enabled)
+  }
+
+  isVideoStatsAvailable () {
+    return this.video.canSeeStats(this.user)
   }
 
   isVideoRemovable () {
@@ -339,10 +344,16 @@ export class VideoActionsDropdownComponent implements OnChanges {
           isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.update && this.isVideoUpdatable()
         },
         {
-          label: $localize`Editor`,
-          linkBuilder: ({ video }) => [ '/video-editor/edit', video.uuid ],
+          label: $localize`Studio`,
+          linkBuilder: ({ video }) => [ '/studio/edit', video.uuid ],
           iconName: 'film',
-          isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.editor && this.isVideoEditable()
+          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`,
@@ -410,5 +421,7 @@ export class VideoActionsDropdownComponent implements OnChanges {
         }
       ]
     ]
+
+    this.videoActions = this.videoActions.concat(this.moreActions)
   }
 }