import { VideoBlacklistComponent } from '@app/shared/video/modals/video-blacklist.component'
import { VideoBlacklistService } from '@app/shared/video-blacklist'
import { ScreenService } from '@app/shared/misc/screen.service'
+import { VideoCaption } from '@shared/models'
export type VideoActionsDisplayType = {
playlist?: boolean
styleUrls: [ './video-actions-dropdown.component.scss' ]
})
export class VideoActionsDropdownComponent implements OnChanges {
- @ViewChild('playlistDropdown') playlistDropdown: NgbDropdown
- @ViewChild('playlistAdd') playlistAdd: VideoAddToPlaylistComponent
+ @ViewChild('playlistDropdown', { static: false }) playlistDropdown: NgbDropdown
+ @ViewChild('playlistAdd', { static: false }) playlistAdd: VideoAddToPlaylistComponent
- @ViewChild('videoDownloadModal') videoDownloadModal: VideoDownloadComponent
- @ViewChild('videoReportModal') videoReportModal: VideoReportComponent
- @ViewChild('videoBlacklistModal') videoBlacklistModal: VideoBlacklistComponent
+ @ViewChild('videoDownloadModal', { static: false }) videoDownloadModal: VideoDownloadComponent
+ @ViewChild('videoReportModal', { static: false }) videoReportModal: VideoReportComponent
+ @ViewChild('videoBlacklistModal', { static: false }) videoBlacklistModal: VideoBlacklistComponent
@Input() video: Video | VideoDetails
+ @Input() videoCaptions: VideoCaption[] = []
@Input() displayOptions: VideoActionsDisplayType = {
playlist: false,
@Output() videoRemoved = new EventEmitter()
@Output() videoUnblacklisted = new EventEmitter()
@Output() videoBlacklisted = new EventEmitter()
+ @Output() modalOpened = new EventEmitter()
videoActions: DropdownAction<{ video: Video }>[][] = []
/* Show modals */
showDownloadModal () {
- this.videoDownloadModal.show(this.video as VideoDetails)
+ this.modalOpened.emit()
+
+ this.videoDownloadModal.show(this.video as VideoDetails, this.videoCaptions)
}
showReportModal () {
+ this.modalOpened.emit()
+
this.videoReportModal.show()
}
showBlacklistModal () {
+ this.modalOpened.emit()
+
this.videoBlacklistModal.show()
}
}
async removeVideo () {
+ this.modalOpened.emit()
+
const res = await this.confirmService.confirm(this.i18n('Do you really want to delete this video?'), this.i18n('Delete'))
if (res === false) return
}
private buildActions () {
- this.videoActions = []
-
- if (this.authService.isLoggedIn()) {
- this.videoActions.push([
+ this.videoActions = [
+ [
{
label: this.i18n('Save to playlist'),
handler: () => this.playlistDropdown.toggle(),
- isDisplayed: () => this.displayOptions.playlist,
+ isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.playlist,
iconName: 'playlist-add'
}
- ])
-
- this.videoActions.push([
+ ],
+ [
{
label: this.i18n('Download'),
handler: () => this.showDownloadModal(),
label: this.i18n('Update'),
linkBuilder: ({ video }) => [ '/videos/update', video.uuid ],
iconName: 'edit',
- isDisplayed: () => this.displayOptions.update && this.isVideoUpdatable()
+ isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.update && this.isVideoUpdatable()
},
{
label: this.i18n('Blacklist'),
handler: () => this.showBlacklistModal(),
iconName: 'no',
- isDisplayed: () => this.displayOptions.blacklist && this.isVideoBlacklistable()
+ isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.blacklist && this.isVideoBlacklistable()
},
{
label: this.i18n('Unblacklist'),
handler: () => this.unblacklistVideo(),
iconName: 'undo',
- isDisplayed: () => this.displayOptions.blacklist && this.isVideoUnblacklistable()
+ isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.blacklist && this.isVideoUnblacklistable()
},
{
label: this.i18n('Delete'),
handler: () => this.removeVideo(),
- isDisplayed: () => this.displayOptions.delete && this.isVideoRemovable(),
+ isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.delete && this.isVideoRemovable(),
iconName: 'delete'
}
- ])
-
- this.videoActions.push([
+ ],
+ [
{
label: this.i18n('Report'),
handler: () => this.showReportModal(),
- isDisplayed: () => this.displayOptions.report,
+ isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.report,
iconName: 'alert'
}
- ])
- }
+ ]
+ ]
}
}