diff --git a/src/components/itemContextMenu.js b/src/components/itemContextMenu.js index 809767be5b..ad2052a3e1 100644 --- a/src/components/itemContextMenu.js +++ b/src/components/itemContextMenu.js @@ -214,11 +214,7 @@ export function getCommands(options) { }); } - if ((canEdit || user.Policy.EnableSubtitleManagement) && item.MediaType === 'Video' && item.Type !== 'TvChannel' && item.Type !== 'Program' - && item.LocationType !== 'Virtual' - && !(item.Type === 'Recording' && item.Status !== 'Completed') - && options.editSubtitles !== false - ) { + if (itemHelper.canEditSubtitles(user, item) && options.editSubtitles !== false) { commands.push({ name: globalize.translate('EditSubtitles'), id: 'editsubtitles', diff --git a/src/components/itemHelper.js b/src/components/itemHelper.js index d763003fb9..18c97c7fd4 100644 --- a/src/components/itemHelper.js +++ b/src/components/itemHelper.js @@ -155,6 +155,33 @@ export function canEditImages (user, item) { return itemType !== 'Timer' && itemType !== 'SeriesTimer' && canEdit(user, item) && !isLocalItem(item); } +export function canEditSubtitles (user, item) { + if (item.MediaType !== 'Video') { + return false; + } + const itemType = item.Type; + if (itemType === 'Recording' && item.Status !== 'Completed') { + return false; + } + if (itemType === 'TvChannel' + || itemType === 'Program' + || itemType === 'Timer' + || itemType === 'SeriesTimer' + || itemType === 'UserRootFolder' + || itemType === 'UserView' + ) { + return false; + } + if (isLocalItem(item)) { + return false; + } + if (item.LocationType === 'Virtual') { + return false; + } + return user.Policy.EnableSubtitleManagement + || user.Policy.IsAdministrator; +} + export function canShare (item, user) { if (item.Type === 'Program') { return false; @@ -300,6 +327,7 @@ export default { canIdentify: canIdentify, canEdit: canEdit, canEditImages: canEditImages, + canEditSubtitles: canEditSubtitles, canShare: canShare, enableDateAddedDisplay: enableDateAddedDisplay, canMarkPlayed: canMarkPlayed,