Apply review feedback

This commit is contained in:
viown
2025-06-27 01:54:09 +03:00
parent 92cdfcc1ea
commit 2b9b5530f3
3 changed files with 15 additions and 3 deletions

View File

@@ -47,7 +47,7 @@ const PluginCard = ({ plugin, configurationPage }: IProps) => {
const navigateToPluginSettings = useCallback(() => {
navigate(pluginPage);
}, [ navigate, location, configurationPage ]);
}, [ navigate, pluginPage ]);
const onEnablePlugin = useCallback(() => {
if (plugin.Id && plugin.Version) {

View File

@@ -1,5 +1,5 @@
/** A mapping of category names used by the plugin repository to translation keys. */
export const CATEGORY_LABELS = {
export const CATEGORY_LABELS: Record<string, string> = {
Administration: 'HeaderAdmin',
Anime: 'Anime',
Authentication: 'LabelAuthProvider', // Legacy

View File

@@ -14,6 +14,7 @@ import TextField from '@mui/material/TextField';
import IconButton from '@mui/material/IconButton';
import Settings from '@mui/icons-material/Settings';
import { Link } from 'react-router-dom';
import { CATEGORY_LABELS } from 'apps/dashboard/features/plugins/constants/categoryLabels';
export const Component = () => {
const { data: packages, isPending: isPackagesPending } = usePackages();
@@ -29,6 +30,17 @@ export const Component = () => {
setSearchQuery(e.target.value);
}, []);
const getCategoryLabel = (category: string) => {
const categoryKey = category.replace(/\s/g, '');
if (CATEGORY_LABELS[categoryKey]) {
return globalize.translate(CATEGORY_LABELS[categoryKey]);
}
console.warn('[AvailablePlugins] unmapped category label', category);
return category;
};
if (isPackagesPending) {
return <Loading />;
}
@@ -62,7 +74,7 @@ export const Component = () => {
{packageCategories.map(category => (
<Stack key={category} spacing={2}>
<Typography variant='h2'>{category}</Typography>
<Typography variant='h2'>{getCategoryLabel(category)}</Typography>
<Grid container spacing={2} columns={{ xs: 1, sm: 4, md: 9, lg: 8, xl: 10 }}>
{getPackagesByCategory(filteredPackages, category).map(pkg => (