mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Apply PR suggestions
This commit is contained in:
parent
f775f3cf22
commit
0663c0731f
3 changed files with 12 additions and 16 deletions
|
@ -11,11 +11,14 @@ import ServerConnections from './ServerConnections';
|
|||
import toast from './toast/toast';
|
||||
import * as userSettings from '../scripts/settings/userSettings';
|
||||
|
||||
function getDeleteCommandName(type) {
|
||||
function getDeleteLabel(type) {
|
||||
switch (type) {
|
||||
case 'Series':
|
||||
return globalize.translate('DeleteSeries');
|
||||
|
||||
case 'Episode':
|
||||
return globalize.translate('DeleteEpisode');
|
||||
|
||||
case 'Playlist':
|
||||
case 'BoxSet':
|
||||
return globalize.translate('Delete');
|
||||
|
@ -175,7 +178,7 @@ export function getCommands(options) {
|
|||
|
||||
if (item.CanDelete && options.deleteItem !== false) {
|
||||
commands.push({
|
||||
name: getDeleteCommandName(item.Type),
|
||||
name: getDeleteLabel(item.Type),
|
||||
id: 'delete',
|
||||
icon: 'delete'
|
||||
});
|
||||
|
|
|
@ -9,40 +9,32 @@ function alertText(options) {
|
|||
return alert(options);
|
||||
}
|
||||
|
||||
function getDeleteText(item) {
|
||||
function getDeletionConfirmContent(item) {
|
||||
if (item.Type === 'Series') {
|
||||
const totalEpisodes = item.RecursiveItemCount;
|
||||
|
||||
return {
|
||||
title: globalize.translate('HeaderDeleteSeries'),
|
||||
text: globalize.translate('ConfirmDeleteSeries', totalEpisodes),
|
||||
confirmText: globalize.translate('DeleteEntireSeries', totalEpisodes)
|
||||
confirmText: globalize.translate('DeleteEntireSeries', totalEpisodes),
|
||||
primary: 'delete'
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
title: globalize.translate('HeaderDeleteItem'),
|
||||
text: globalize.translate('ConfirmDeleteItem'),
|
||||
confirmText: globalize.translate('Delete')
|
||||
|
||||
confirmText: globalize.translate('Delete'),
|
||||
primary: 'delete'
|
||||
};
|
||||
}
|
||||
|
||||
export function deleteItem(options) {
|
||||
const item = options.item;
|
||||
const parentId = item.SeasonId || item.SeriesId || item.ParentId;
|
||||
const { confirmText, text, title } = getDeleteText(item);
|
||||
|
||||
const apiClient = ServerConnections.getApiClient(item.ServerId);
|
||||
|
||||
return confirm({
|
||||
|
||||
title,
|
||||
text,
|
||||
confirmText,
|
||||
primary: 'delete'
|
||||
|
||||
}).then(function () {
|
||||
return confirm(getDeletionConfirmContent(item)).then(function () {
|
||||
return apiClient.deleteItem(item.Id).then(function () {
|
||||
if (options.navigate) {
|
||||
if (parentId) {
|
||||
|
|
|
@ -185,6 +185,7 @@
|
|||
"DeleteImageConfirmation": "Are you sure you wish to delete this image?",
|
||||
"DeleteMedia": "Delete media",
|
||||
"DeleteSeries": "Delete Series",
|
||||
"DeleteEpisode": "Delete Episode",
|
||||
"DeleteUser": "Delete User",
|
||||
"DeleteUserConfirmation": "Are you sure you wish to delete this user?",
|
||||
"Depressed": "Depressed",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue