mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #4883 from Ch1nkara/add-user-permission-to-edit-subtitles
Add support for subtitle management permission
This commit is contained in:
commit
e7d9e8c737
4 changed files with 41 additions and 5 deletions
|
@ -214,11 +214,7 @@ export function getCommands(options) {
|
|||
});
|
||||
}
|
||||
|
||||
if (canEdit && 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',
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { appHost } from './apphost';
|
||||
import globalize from '../scripts/globalize';
|
||||
import { CollectionType } from '@jellyfin/sdk/lib/generated-client/models/collection-type';
|
||||
import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind';
|
||||
import { LocationType } from '@jellyfin/sdk/lib/generated-client/models/location-type';
|
||||
import { RecordingStatus } from '@jellyfin/sdk/lib/generated-client/models/recording-status';
|
||||
import { MediaType } from '@jellyfin/sdk/lib/generated-client/models/media-type';
|
||||
|
||||
export function getDisplayName(item, options = {}) {
|
||||
if (!item) {
|
||||
|
@ -155,6 +159,33 @@ export function canEditImages (user, item) {
|
|||
return itemType !== 'Timer' && itemType !== 'SeriesTimer' && canEdit(user, item) && !isLocalItem(item);
|
||||
}
|
||||
|
||||
export function canEditSubtitles (user, item) {
|
||||
if (item.MediaType !== MediaType.Video) {
|
||||
return false;
|
||||
}
|
||||
const itemType = item.Type;
|
||||
if (itemType === BaseItemKind.Recording && item.Status !== RecordingStatus.Completed) {
|
||||
return false;
|
||||
}
|
||||
if (itemType === BaseItemKind.TvChannel
|
||||
|| itemType === BaseItemKind.Program
|
||||
|| itemType === 'Timer'
|
||||
|| itemType === 'SeriesTimer'
|
||||
|| itemType === BaseItemKind.UserRootFolder
|
||||
|| itemType === BaseItemKind.UserView
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (isLocalItem(item)) {
|
||||
return false;
|
||||
}
|
||||
if (item.LocationType === LocationType.Virtual) {
|
||||
return false;
|
||||
}
|
||||
return user.Policy.EnableSubtitleManagement
|
||||
|| user.Policy.IsAdministrator;
|
||||
}
|
||||
|
||||
export function canShare (item, user) {
|
||||
if (item.Type === 'Program') {
|
||||
return false;
|
||||
|
@ -300,6 +331,7 @@ export default {
|
|||
canIdentify: canIdentify,
|
||||
canEdit: canEdit,
|
||||
canEditImages: canEditImages,
|
||||
canEditSubtitles,
|
||||
canShare: canShare,
|
||||
enableDateAddedDisplay: enableDateAddedDisplay,
|
||||
canMarkPlayed: canMarkPlayed,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue