Don't display remove file icon in some cases
This commit is contained in:
parent
9f244885f0
commit
367a9dc699
|
@ -109,6 +109,7 @@
|
||||||
{{ file.resolution.label }}: {{ file.size | bytes: 1 }}
|
{{ file.resolution.label }}: {{ file.size | bytes: 1 }}
|
||||||
|
|
||||||
<my-global-icon
|
<my-global-icon
|
||||||
|
*ngIf="canRemoveOneFile(video)"
|
||||||
i18n-ngbTooltip ngbTooltip="Delete this file" iconName="delete" role="button"
|
i18n-ngbTooltip ngbTooltip="Delete this file" iconName="delete" role="button"
|
||||||
(click)="removeVideoFile(video, file, 'webtorrent')"
|
(click)="removeVideoFile(video, file, 'webtorrent')"
|
||||||
></my-global-icon>
|
></my-global-icon>
|
||||||
|
@ -124,6 +125,7 @@
|
||||||
{{ file.resolution.label }}: {{ file.size | bytes: 1 }}
|
{{ file.resolution.label }}: {{ file.size | bytes: 1 }}
|
||||||
|
|
||||||
<my-global-icon
|
<my-global-icon
|
||||||
|
*ngIf="canRemoveOneFile(video)"
|
||||||
i18n-ngbTooltip ngbTooltip="Delete this file" iconName="delete" role="button"
|
i18n-ngbTooltip ngbTooltip="Delete this file" iconName="delete" role="button"
|
||||||
(click)="removeVideoFile(video, file, 'hls')"
|
(click)="removeVideoFile(video, file, 'hls')"
|
||||||
></my-global-icon>
|
></my-global-icon>
|
||||||
|
|
|
@ -166,6 +166,10 @@ export class VideoListComponent extends RestTable implements OnInit {
|
||||||
return video.files.length !== 0
|
return video.files.length !== 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canRemoveOneFile (video: Video) {
|
||||||
|
return video.canRemoveOneFile(this.authUser)
|
||||||
|
}
|
||||||
|
|
||||||
getFilesSize (video: Video) {
|
getFilesSize (video: Video) {
|
||||||
let files = video.files
|
let files = video.files
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { AuthUser } from '@app/core'
|
import { AuthUser } from '@app/core'
|
||||||
import { User } from '@app/core/users/user.model'
|
import { User } from '@app/core/users/user.model'
|
||||||
import { durationToString, prepareIcu, getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers'
|
import { durationToString, getAbsoluteAPIUrl, getAbsoluteEmbedUrl, prepareIcu } from '@app/helpers'
|
||||||
import { Actor } from '@app/shared/shared-main/account/actor.model'
|
import { Actor } from '@app/shared/shared-main/account/actor.model'
|
||||||
import { buildVideoWatchPath } from '@shared/core-utils'
|
import { buildVideoWatchPath, getAllFiles } from '@shared/core-utils'
|
||||||
import { peertubeTranslate } from '@shared/core-utils/i18n'
|
import { peertubeTranslate } from '@shared/core-utils/i18n'
|
||||||
import {
|
import {
|
||||||
ActorImage,
|
ActorImage,
|
||||||
|
@ -240,6 +240,13 @@ export class Video implements VideoServerModel {
|
||||||
return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.SEE_ALL_VIDEOS))
|
return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.SEE_ALL_VIDEOS))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canRemoveOneFile (user: AuthUser) {
|
||||||
|
return this.isLocal &&
|
||||||
|
user && user.hasRight(UserRight.MANAGE_VIDEO_FILES) &&
|
||||||
|
this.state.id !== VideoState.TO_TRANSCODE &&
|
||||||
|
getAllFiles(this).length > 1
|
||||||
|
}
|
||||||
|
|
||||||
canRemoveFiles (user: AuthUser) {
|
canRemoveFiles (user: AuthUser) {
|
||||||
return this.isLocal &&
|
return this.isLocal &&
|
||||||
user && user.hasRight(UserRight.MANAGE_VIDEO_FILES) &&
|
user && user.hasRight(UserRight.MANAGE_VIDEO_FILES) &&
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import { basename, join } from 'path'
|
import { basename, join } from 'path'
|
||||||
import { ffprobePromise, getVideoStream } from '@server/helpers/ffmpeg'
|
import { ffprobePromise, getVideoStream } from '@server/helpers/ffmpeg'
|
||||||
import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist, getAllFiles, testImage } from '@server/tests/shared'
|
import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist, testImage } from '@server/tests/shared'
|
||||||
import { wait } from '@shared/core-utils'
|
import { getAllFiles, wait } from '@shared/core-utils'
|
||||||
import {
|
import {
|
||||||
HttpStatusCode,
|
HttpStatusCode,
|
||||||
LiveVideo,
|
LiveVideo,
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import { canDoQuickTranscode } from '@server/helpers/ffmpeg'
|
import { canDoQuickTranscode } from '@server/helpers/ffmpeg'
|
||||||
import { generateHighBitrateVideo, generateVideoWithFramerate, getAllFiles } from '@server/tests/shared'
|
import { generateHighBitrateVideo, generateVideoWithFramerate } from '@server/tests/shared'
|
||||||
import { buildAbsoluteFixturePath, getMaxBitrate, getMinLimitBitrate, omit } from '@shared/core-utils'
|
import { buildAbsoluteFixturePath, getAllFiles, getMaxBitrate, getMinLimitBitrate, omit } from '@shared/core-utils'
|
||||||
import {
|
import {
|
||||||
buildFileMetadata,
|
buildFileMetadata,
|
||||||
getAudioStream,
|
getAudioStream,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import { expectStartWith, getAllFiles } from '@server/tests/shared'
|
import { expectStartWith } from '@server/tests/shared'
|
||||||
import { areObjectStorageTestsDisabled } from '@shared/core-utils'
|
import { areObjectStorageTestsDisabled, getAllFiles } from '@shared/core-utils'
|
||||||
import { VideoStudioTask } from '@shared/models'
|
import { VideoStudioTask } from '@shared/models'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
|
import { getAllFiles } from '@shared/core-utils'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
createSingleServer,
|
createSingleServer,
|
||||||
|
@ -11,7 +12,6 @@ import {
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '@shared/server-commands'
|
} from '@shared/server-commands'
|
||||||
import { getAllFiles } from '../shared'
|
|
||||||
|
|
||||||
describe('Test update host scripts', function () {
|
describe('Test update host scripts', function () {
|
||||||
let server: PeerTubeServer
|
let server: PeerTubeServer
|
||||||
|
|
|
@ -241,16 +241,6 @@ async function uploadRandomVideoOnServers (
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllFiles (video: VideoDetails) {
|
|
||||||
const files = video.files
|
|
||||||
|
|
||||||
if (video.streamingPlaylists[0]) {
|
|
||||||
return files.concat(video.streamingPlaylists[0].files)
|
|
||||||
}
|
|
||||||
|
|
||||||
return files
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
@ -258,6 +248,5 @@ export {
|
||||||
checkUploadVideoParam,
|
checkUploadVideoParam,
|
||||||
uploadRandomVideoOnServers,
|
uploadRandomVideoOnServers,
|
||||||
checkVideoFilesWereRemoved,
|
checkVideoFilesWereRemoved,
|
||||||
saveVideoInServers,
|
saveVideoInServers
|
||||||
getAllFiles
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,21 @@
|
||||||
|
import { VideoDetails } from '../../models/videos/video.model'
|
||||||
import { VideoPrivacy } from '../../models/videos/video-privacy.enum'
|
import { VideoPrivacy } from '../../models/videos/video-privacy.enum'
|
||||||
|
|
||||||
function getAllPrivacies () {
|
function getAllPrivacies () {
|
||||||
return [ VideoPrivacy.PUBLIC, VideoPrivacy.INTERNAL, VideoPrivacy.PRIVATE, VideoPrivacy.UNLISTED ]
|
return [ VideoPrivacy.PUBLIC, VideoPrivacy.INTERNAL, VideoPrivacy.PRIVATE, VideoPrivacy.UNLISTED ]
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
function getAllFiles (video: Partial<Pick<VideoDetails, 'files' | 'streamingPlaylists'>>) {
|
||||||
getAllPrivacies
|
const files = video.files
|
||||||
|
|
||||||
|
if (video.streamingPlaylists[0]) {
|
||||||
|
return files.concat(video.streamingPlaylists[0].files)
|
||||||
|
}
|
||||||
|
|
||||||
|
return files
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
getAllPrivacies,
|
||||||
|
getAllFiles
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue