<commit_before>import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { KalturaEntryStatus, KalturaExternalMediaEntry, KalturaMediaEntry, KalturaMediaType, KalturaSourceType } from 'kaltura-ngx-client';
import { ActionTypes, EntryStore, NotificationTypes } from './entry-store.service';
import { EntrySectionsListWidget } from './entry-sections-list/entry-sections-list-widget.service';
import { EntryMetadataWidget } from './entry-metadata/entry-metadata-widget.service';
import { EntryPreviewWidget } from './entry-preview/entry-preview-widget.service';
import { EntryDetailsWidget } from './entry-details/entry-details-widget.service';
import { EntryCaptionsWidget } from './entry-captions/entry-captions-widget.service';
import { EntryAccessControlWidget } from './entry-access-control/entry-access-control-widget.service';
import { EntryClipsWidget } from './entry-clips/entry-clips-widget.service';
import { EntryRelatedWidget } from './entry-related/entry-related-widget.service';
import { EntryLiveWidget } from './entry-live/entry-live-widget.service';
import { EntryFlavoursWidget } from './entry-flavours/entry-flavours-widget.service';
import { EntryThumbnailsWidget } from './entry-thumbnails/entry-thumbnails-widget.service';
import { EntrySchedulingWidget } from './entry-scheduling/entry-scheduling-widget.service';
import { EntryUsersWidget } from './entry-users/entry-users-widget.service';
import { EntryWidgetsManager } from './entry-widgets-manager';
import { AreaBlockerMessage, AreaBlockerMessageButton, PopupWidgetComponent } from '@kaltura-ng/kaltura-ui';
import { AppLocalization } from '@kaltura-ng/mc-shared';
import { Observable } from 'rxjs';
import { EntriesStore } from 'app-shared/content-shared/entries/entries-store/entries-store.service';
import { EntryDistributionWidget } from './entry-distribution/entry-distribution-widget.service';
import { EntryAdvertisementsWidget } from './entry-advertisements/entry-advertisements-widget.service';
import { KMCPermissions, KMCPermissionsService } from 'app-shared/kmc-shared/kmc-permissions';
import { ContentEntryViewSections, ContentEntryViewService } from 'app-shared/kmc-shared/kmc-views/details-views';
import { cancelOnDestroy, tag } from '@kaltura-ng/kaltura-common';
import { ClipAndTrimAppViewService, LiveDashboardAppViewService } from 'app-shared/kmc-shared/kmc-views/component-views';
import { CustomMenuItem } from 'app-shared/content-shared/entries/entries-list/entries-list.component';
import { PreviewAndEmbedEvent } from 'app-shared/kmc-shared/events';
import { AppEventsService } from 'app-shared/kmc-shared';
import { ContentEntriesAppService } from '../content-entries-app.service';
import { BrowserService } from 'app-shared/kmc-shell/providers';
import { KalturaLogger } from '@kaltura-ng/kaltura-logger';
import { AnalyticsNewMainViewService } from 'app-shared/kmc-shared/kmc-views';

@Component({
	selector: 'kEntry',
	templateUrl: './entry.component.html',
	styleUrls: ['./entry.component.scss'],
	providers : [
		EntryStore,
		EntryWidgetsManager,
		EntrySectionsListWidget,
		EntryUsersWidget,
		EntryThumbnailsWidget,
		EntrySchedulingWidget,
		EntryRelatedWidget,
		EntryFlavoursWidget,
		EntryLiveWidget,
		EntryClipsWidget,
		EntryCaptionsWidget,
		EntryAccessControlWidget,
		EntryMetadataWidget,
		EntryDetailsWidget,
		EntryPreviewWidget,
		EntryDistributionWidget,
		EntryAdvertisementsWidget,
        KalturaLogger.createLogger('EntryComponent')
	]
})
export class EntryComponent implements OnInit, OnDestroy {
    @ViewChild('liveDashboard', { static: true }) _liveDashboard: PopupWidgetComponent;
    @ViewChild('clipAndTrim', { static: true }) _clipAndTrim: PopupWidgetComponent;
    @ViewChild('bulkActionsPopup', { static: true }) _bulkActionsPopup: PopupWidgetComponent;
	public _entryName: string;
	public _entryType: KalturaMediaType;
	public _sourceType: KalturaSourceType;
    public _entry: KalturaMediaEntry;
	public _showLoader = false;
	public _areaBlockerMessage: AreaBlockerMessage;
	public _currentEntryId: string;
	public _enablePrevButton: boolean;
	public _enableNextButton: boolean;
	public _entryHasChanges : boolean;
	public _kmcPermissions = KMCPermissions;
    public _items: CustomMenuItem[] = [
        {
            label: this._appLocalization.get('applications.content.table.liveDashboard'),
            commandName: 'liveDashboard',
            styleClass: '',
            disabled: !this._liveDashboardAppViewService.isAvailable()
        },
        {
            label: this._appLocalization.get('applications.content.table.download'),
            commandName: 'download',
            styleClass: ''
        },
        {
            label: this._appLocalization.get('applications.content.table.previewAndEmbed'),
            commandName: 'preview',
            styleClass: ''
        },
        {
            label: this._appLocalization.get('applications.content.table.editor'),
            commandName: 'editor',
            styleClass: ''
        },
        {
            label: this._appLocalization.get('applications.content.table.delete'),
            commandName: 'delete',
            styleClass: 'kDanger'
        }
    ];
    public _menuItems: CustomMenuItem[] = [];

	public get _isSaveDisabled(): boolean {
    const editAccessControlAllowed = this._permissionsService.hasAnyPermissions([
      KMCPermissions.CONTENT_MANAGE_ASSIGN_CATEGORIES,
      KMCPermissions.CONTENT_MANAGE_RECONVERT,
      KMCPermissions.CONTENT_MANAGE_ENTRY_USERS,
      KMCPermissions.CONTENT_MANAGE_METADATA,
      KMCPermissions.CONTENT_MANAGE_SCHEDULE,
      KMCPermissions.CONTENT_MANAGE_THUMBNAIL,
      KMCPermissions.CONTENT_MANAGE_ACCESS_CONTROL,
      KMCPermissions.CONTENT_MODERATE_METADATA,
      KMCPermissions.CONTENT_MANAGE_CUSTOM_DATA,
      KMCPermissions.LIVE_STREAM_UPDATE,
    ]);

		return !this._entryStore.entryIsDirty || !editAccessControlAllowed;
	}

    public _analyticsAllowed: boolean;

	constructor(entryWidgetsManager: EntryWidgetsManager,
	            widget1: EntrySectionsListWidget,
	            widget2: EntryUsersWidget,
	            widget3: EntryThumbnailsWidget,
	            widget4: EntrySchedulingWidget,
	            widget5: EntryRelatedWidget,
	            widget6: EntryFlavoursWidget,
	            widget7: EntryLiveWidget,
	            widget8: EntryClipsWidget,
	            widget9: EntryCaptionsWidget,
	            widget10: EntryAccessControlWidget,
	            widget11: EntryMetadataWidget,
	            widget12: EntryDetailsWidget,
	            widget13: EntryPreviewWidget,
	            widget14: EntryDistributionWidget,
	            widget15: EntryAdvertisementsWidget,
	            private _permissionsService: KMCPermissionsService,
	            private _entriesStore: EntriesStore,
	            private _appLocalization: AppLocalization,
	            public _entryStore: EntryStore,
                private _contentEntryViewService: ContentEntryViewService,
                private _liveDashboardAppViewService: LiveDashboardAppViewService,
                private _contentEntriesAppService: ContentEntriesAppService,
                private _clipAndTrimAppViewService: ClipAndTrimAppViewService,
                private _browserService: BrowserService,
                private _appEvents: AppEventsService,
                private _entryRoute: ActivatedRoute,
                private _logger: KalturaLogger,
                private _analyticsNewMainViewService: AnalyticsNewMainViewService,
                private _router: Router) {
		entryWidgetsManager.registerWidgets([
			widget1, widget2, widget3, widget4, widget5, widget6, widget7,
			widget8, widget9, widget10, widget11, widget12, widget13, widget14,
			widget15
		]);
	}

	ngOnDestroy() {
	}

    private _hideMenuItems(entry: KalturaMediaEntry,
                           { commandName }: { commandName: string }): boolean {
        const { sourceType, status, mediaType } = entry;
        const isReadyStatus = status === KalturaEntryStatus.ready;
        const isPreviewCommand = commandName === 'preview';
        const isKalturaLiveStream = (sourceType === KalturaSourceType.liveStream || sourceType === KalturaSourceType.manualLiveStream);
        const isLiveDashboardCommand = commandName === 'liveDashboard';
        const cannotDeleteEntry = commandName === 'delete' && !this._permissionsService.hasPermission(KMCPermissions.CONTENT_MANAGE_DELETE);
        const isDownloadCommand = commandName === 'download';
        const isExternalMedia = entry instanceof KalturaExternalMediaEntry;
        const isNotVideoAudioImage = [KalturaMediaType.video, KalturaMediaType.audio, KalturaMediaType.image].indexOf(mediaType) === -1;
        return !(
            (!isReadyStatus && isPreviewCommand) || // hide if trying to share & embed entry that isn't ready
            // hide live-dashboard menu item for entry that isn't kaltura live or has permission to access new analytics
            (isLiveDashboardCommand && (!isKalturaLiveStream)) ||
            (isDownloadCommand && (isNotVideoAudioImage || isExternalMedia)) ||
            cannotDeleteEntry
        );
    }

    private _buildMenu(entry: KalturaMediaEntry): void {
        this._menuItems = this._items
            .filter(item => this._hideMenuItems(entry, item))
            .map(item => {
                switch (item.commandName) {
                    case 'preview':
                        item.disabled = entry.status === KalturaEntryStatus.noContent;
                        item.command = () => this._appEvents.publish(new PreviewAndEmbedEvent(entry));
                        break;
                    case 'liveDashboard':
                        item.command = () => this._liveDashboard.open();
                        break;
                    case 'editor':
                        item.disabled = !this._clipAndTrimAppViewService.isAvailable({
                            entry: entry,<commit_msg>chore: remove legacy live dashboard from entry details actions menu button<commit_after>import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { KalturaEntryStatus, KalturaExternalMediaEntry, KalturaMediaEntry, KalturaMediaType, KalturaSourceType } from 'kaltura-ngx-client';
import { ActionTypes, EntryStore, NotificationTypes } from './entry-store.service';
import { EntrySectionsListWidget } from './entry-sections-list/entry-sections-list-widget.service';
import { EntryMetadataWidget } from './entry-metadata/entry-metadata-widget.service';
import { EntryPreviewWidget } from './entry-preview/entry-preview-widget.service';
import { EntryDetailsWidget } from './entry-details/entry-details-widget.service';
import { EntryCaptionsWidget } from './entry-captions/entry-captions-widget.service';
import { EntryAccessControlWidget } from './entry-access-control/entry-access-control-widget.service';
import { EntryClipsWidget } from './entry-clips/entry-clips-widget.service';
import { EntryRelatedWidget } from './entry-related/entry-related-widget.service';
import { EntryLiveWidget } from './entry-live/entry-live-widget.service';
import { EntryFlavoursWidget } from './entry-flavours/entry-flavours-widget.service';
import { EntryThumbnailsWidget } from './entry-thumbnails/entry-thumbnails-widget.service';
import { EntrySchedulingWidget } from './entry-scheduling/entry-scheduling-widget.service';
import { EntryUsersWidget } from './entry-users/entry-users-widget.service';
import { EntryWidgetsManager } from './entry-widgets-manager';
import { AreaBlockerMessage, AreaBlockerMessageButton, PopupWidgetComponent } from '@kaltura-ng/kaltura-ui';
import { AppLocalization } from '@kaltura-ng/mc-shared';
import { Observable } from 'rxjs';
import { EntriesStore } from 'app-shared/content-shared/entries/entries-store/entries-store.service';
import { EntryDistributionWidget } from './entry-distribution/entry-distribution-widget.service';
import { EntryAdvertisementsWidget } from './entry-advertisements/entry-advertisements-widget.service';
import { KMCPermissions, KMCPermissionsService } from 'app-shared/kmc-shared/kmc-permissions';
import { ContentEntryViewSections, ContentEntryViewService } from 'app-shared/kmc-shared/kmc-views/details-views';
import { cancelOnDestroy, tag } from '@kaltura-ng/kaltura-common';
import { ClipAndTrimAppViewService, LiveDashboardAppViewService } from 'app-shared/kmc-shared/kmc-views/component-views';
import { CustomMenuItem } from 'app-shared/content-shared/entries/entries-list/entries-list.component';
import { PreviewAndEmbedEvent } from 'app-shared/kmc-shared/events';
import { AppEventsService } from 'app-shared/kmc-shared';
import { ContentEntriesAppService } from '../content-entries-app.service';
import { BrowserService } from 'app-shared/kmc-shell/providers';
import { KalturaLogger } from '@kaltura-ng/kaltura-logger';
import { AnalyticsNewMainViewService } from 'app-shared/kmc-shared/kmc-views';

@Component({
	selector: 'kEntry',
	templateUrl: './entry.component.html',
	styleUrls: ['./entry.component.scss'],
	providers : [
		EntryStore,
		EntryWidgetsManager,
		EntrySectionsListWidget,
		EntryUsersWidget,
		EntryThumbnailsWidget,
		EntrySchedulingWidget,
		EntryRelatedWidget,
		EntryFlavoursWidget,
		EntryLiveWidget,
		EntryClipsWidget,
		EntryCaptionsWidget,
		EntryAccessControlWidget,
		EntryMetadataWidget,
		EntryDetailsWidget,
		EntryPreviewWidget,
		EntryDistributionWidget,
		EntryAdvertisementsWidget,
        KalturaLogger.createLogger('EntryComponent')
	]
})
export class EntryComponent implements OnInit, OnDestroy {
    @ViewChild('liveDashboard', { static: true }) _liveDashboard: PopupWidgetComponent;
    @ViewChild('clipAndTrim', { static: true }) _clipAndTrim: PopupWidgetComponent;
    @ViewChild('bulkActionsPopup', { static: true }) _bulkActionsPopup: PopupWidgetComponent;
	public _entryName: string;
	public _entryType: KalturaMediaType;
	public _sourceType: KalturaSourceType;
    public _entry: KalturaMediaEntry;
	public _showLoader = false;
	public _areaBlockerMessage: AreaBlockerMessage;
	public _currentEntryId: string;
	public _enablePrevButton: boolean;
	public _enableNextButton: boolean;
	public _entryHasChanges : boolean;
	public _kmcPermissions = KMCPermissions;
    public _items: CustomMenuItem[] = [
        {
            label: this._appLocalization.get('applications.content.table.download'),
            commandName: 'download',
            styleClass: ''
        },
        {
            label: this._appLocalization.get('applications.content.table.previewAndEmbed'),
            commandName: 'preview',
            styleClass: ''
        },
        {
            label: this._appLocalization.get('applications.content.table.editor'),
            commandName: 'editor',
            styleClass: ''
        },
        {
            label: this._appLocalization.get('applications.content.table.delete'),
            commandName: 'delete',
            styleClass: 'kDanger'
        }
    ];
    public _menuItems: CustomMenuItem[] = [];

	public get _isSaveDisabled(): boolean {
    const editAccessControlAllowed = this._permissionsService.hasAnyPermissions([
      KMCPermissions.CONTENT_MANAGE_ASSIGN_CATEGORIES,
      KMCPermissions.CONTENT_MANAGE_RECONVERT,
      KMCPermissions.CONTENT_MANAGE_ENTRY_USERS,
      KMCPermissions.CONTENT_MANAGE_METADATA,
      KMCPermissions.CONTENT_MANAGE_SCHEDULE,
      KMCPermissions.CONTENT_MANAGE_THUMBNAIL,
      KMCPermissions.CONTENT_MANAGE_ACCESS_CONTROL,
      KMCPermissions.CONTENT_MODERATE_METADATA,
      KMCPermissions.CONTENT_MANAGE_CUSTOM_DATA,
      KMCPermissions.LIVE_STREAM_UPDATE,
    ]);

		return !this._entryStore.entryIsDirty || !editAccessControlAllowed;
	}

    public _analyticsAllowed: boolean;

	constructor(entryWidgetsManager: EntryWidgetsManager,
	            widget1: EntrySectionsListWidget,
	            widget2: EntryUsersWidget,
	            widget3: EntryThumbnailsWidget,
	            widget4: EntrySchedulingWidget,
	            widget5: EntryRelatedWidget,
	            widget6: EntryFlavoursWidget,
	            widget7: EntryLiveWidget,
	            widget8: EntryClipsWidget,
	            widget9: EntryCaptionsWidget,
	            widget10: EntryAccessControlWidget,
	            widget11: EntryMetadataWidget,
	            widget12: EntryDetailsWidget,
	            widget13: EntryPreviewWidget,
	            widget14: EntryDistributionWidget,
	            widget15: EntryAdvertisementsWidget,
	            private _permissionsService: KMCPermissionsService,
	            private _entriesStore: EntriesStore,
	            private _appLocalization: AppLocalization,
	            public _entryStore: EntryStore,
                private _contentEntryViewService: ContentEntryViewService,
                private _liveDashboardAppViewService: LiveDashboardAppViewService,
                private _contentEntriesAppService: ContentEntriesAppService,
                private _clipAndTrimAppViewService: ClipAndTrimAppViewService,
                private _browserService: BrowserService,
                private _appEvents: AppEventsService,
                private _entryRoute: ActivatedRoute,
                private _logger: KalturaLogger,
                private _analyticsNewMainViewService: AnalyticsNewMainViewService,
                private _router: Router) {
		entryWidgetsManager.registerWidgets([
			widget1, widget2, widget3, widget4, widget5, widget6, widget7,
			widget8, widget9, widget10, widget11, widget12, widget13, widget14,
			widget15
		]);
	}

	ngOnDestroy() {
	}

    private _hideMenuItems(entry: KalturaMediaEntry,
                           { commandName }: { commandName: string }): boolean {
        const { sourceType, status, mediaType } = entry;
        const isReadyStatus = status === KalturaEntryStatus.ready;
        const isPreviewCommand = commandName === 'preview';
        const isKalturaLiveStream = (sourceType === KalturaSourceType.liveStream || sourceType === KalturaSourceType.manualLiveStream);
        const cannotDeleteEntry = commandName === 'delete' && !this._permissionsService.hasPermission(KMCPermissions.CONTENT_MANAGE_DELETE);
        const isDownloadCommand = commandName === 'download';
        const isExternalMedia = entry instanceof KalturaExternalMediaEntry;
        const isNotVideoAudioImage = [KalturaMediaType.video, KalturaMediaType.audio, KalturaMediaType.image].indexOf(mediaType) === -1;
        return !(
            (!isReadyStatus && isPreviewCommand) || // hide if trying to share & embed entry that isn't ready
            (isDownloadCommand && (isNotVideoAudioImage || isExternalMedia)) ||
            cannotDeleteEntry
        );
    }

    private _buildMenu(entry: KalturaMediaEntry): void {
        this._menuItems = this._items
            .filter(item => this._hideMenuItems(entry, item))
            .map(item => {
                switch (item.commandName) {
                    case 'preview':
                        item.disabled = entry.status === KalturaEntryStatus.noContent;
                        item.command = () => this._appEvents.publish(new PreviewAndEmbedEvent(entry));
                        break;
                    case 'editor':
                        item.disabled = !this._clipAndTrimAppViewService.isAvailable({
                            entry: entry,
{'fraction_non_alphanumeric': 0.09586929716399507, 'fraction_numerical': 0.0044184134812988085, 'mean_word_length': 3.4829571625978812, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1790729', 'n_tokens_mistral': 5494, 'n_tokens_neox': 5283, 'n_words': 978}