Don't allow video edition if not enabled

pull/4867/head
Chocobozzz 2022-03-18 16:31:12 +01:00
parent 68e72ba90c
commit 22e909224c
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 10 additions and 6 deletions

View File

@ -9,7 +9,7 @@ import { AdvancedInputFilter } from '@app/shared/shared-forms'
import { DropdownAction, Video, VideoService } from '@app/shared/shared-main'
import { LiveStreamInformationComponent } from '@app/shared/shared-video-live'
import { MiniatureDisplayOptions, SelectionType, VideosSelectionComponent } from '@app/shared/shared-video-miniature'
import { VideoChannel, VideoSortField, VideoState } from '@shared/models'
import { VideoChannel, VideoSortField } from '@shared/models'
import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.component'
@Component({
@ -207,7 +207,7 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook {
{
label: $localize`Editor`,
linkBuilder: ({ video }) => [ '/video-editor/edit', video.uuid ],
isDisplayed: ({ video }) => video.state.id === VideoState.PUBLISHED,
isDisplayed: ({ video }) => video.isEditableBy(this.authService.getUser(), this.serverService.getHTMLConfig().videoEditor.enabled),
iconName: 'film'
},
{

View File

@ -228,6 +228,12 @@ export class Video implements VideoServerModel {
return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.UPDATE_ANY_VIDEO))
}
isEditableBy (user: AuthUser, videoEditorEnabled: boolean) {
return videoEditorEnabled &&
this.state?.id === VideoState.PUBLISHED &&
this.isUpdatableBy(user)
}
canRemoveFiles (user: AuthUser) {
return this.isLocal &&
user.hasRight(UserRight.MANAGE_VIDEO_FILES) &&

View 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,
@ -153,9 +153,7 @@ 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().videoEditor.enabled)
}
isVideoRemovable () {