From 7c279a12a7b866b8b1d1b2e90ee9f1643765d719 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Wed, 30 Oct 2024 10:39:05 -0400 Subject: [PATCH] Update plugin category labels --- .../plugins/constants/categoryLabels.ts | 14 ++++++++ .../dashboard/plugins/available/index.js | 35 +++++++++---------- 2 files changed, 30 insertions(+), 19 deletions(-) create mode 100644 src/apps/dashboard/features/plugins/constants/categoryLabels.ts diff --git a/src/apps/dashboard/features/plugins/constants/categoryLabels.ts b/src/apps/dashboard/features/plugins/constants/categoryLabels.ts new file mode 100644 index 00000000000..290a9d31141 --- /dev/null +++ b/src/apps/dashboard/features/plugins/constants/categoryLabels.ts @@ -0,0 +1,14 @@ +/** A mapping of category names used by the plugin repository to translation keys. */ +export const CATEGORY_LABELS = { + Administrative: 'HeaderAdmin', // TODO: Add better translation + Authentication: 'LabelAuthProvider', // Legacy + Books: 'Books', + Channel: 'Channels', // Unused? + General: 'General', + LiveTV: 'LiveTV', + Metadata: 'LabelMetadata', // Legacy + MoviesAndShows: 'Movies', // TODO: Add better translation + Music: 'TabMusic', + Subtitles: 'Subtitles', + Other: 'Other' +}; diff --git a/src/controllers/dashboard/plugins/available/index.js b/src/controllers/dashboard/plugins/available/index.js index 34d93ff6e32..f8b05197b55 100644 --- a/src/controllers/dashboard/plugins/available/index.js +++ b/src/controllers/dashboard/plugins/available/index.js @@ -1,12 +1,14 @@ import escapeHTML from 'escape-html'; -import loading from '../../../../components/loading/loading'; -import globalize from '../../../../lib/globalize'; -import '../../../../components/cardbuilder/card.scss'; -import '../../../../elements/emby-button/emby-button'; -import '../../../../elements/emby-checkbox/emby-checkbox'; -import '../../../../elements/emby-select/emby-select'; -import { getDefaultBackgroundClass } from '../../../../components/cardbuilder/cardBuilderUtils'; +import { CATEGORY_LABELS } from 'apps/dashboard/features/plugins/constants/categoryLabels'; +import { getDefaultBackgroundClass } from 'components/cardbuilder/cardBuilderUtils'; +import loading from 'components/loading/loading'; +import globalize from 'lib/globalize'; + +import 'components/cardbuilder/card.scss'; +import 'elements/emby-button/emby-button'; +import 'elements/emby-checkbox/emby-checkbox'; +import 'elements/emby-select/emby-select'; function reloadList(page) { loading.show(); @@ -23,19 +25,14 @@ function reloadList(page) { } function getHeaderText(category) { - category = category.replace(' ', ''); - // TODO: Replace with switch - if (category === 'Channel') { - category = 'Channels'; - } else if (category === 'Theme') { - category = 'Themes'; - } else if (category === 'LiveTV') { - category = 'LiveTV'; - } else if (category === 'ScreenSaver') { - category = 'HeaderScreenSavers'; + const categoryKey = category.replaceAll(' ', ''); + + if (CATEGORY_LABELS[categoryKey]) { + return globalize.translate(CATEGORY_LABELS[categoryKey]); } - return globalize.translate(category); + console.warn('[AvailablePlugins] unmapped category label', category); + return category; } function populateList(options) { @@ -43,7 +40,7 @@ function populateList(options) { const installedPlugins = options.installedPlugins; availablePlugins.forEach(function (plugin, index, array) { - plugin.category = plugin.category || 'General'; + plugin.category = plugin.category || 'Other'; plugin.categoryDisplayName = getHeaderText(plugin.category); array[index] = plugin; });