diff --git a/src/apps/dashboard/components/drawer/AppDrawer.tsx b/src/apps/dashboard/components/drawer/AppDrawer.tsx index fda5b5f2d4..1b03f58fe5 100644 --- a/src/apps/dashboard/components/drawer/AppDrawer.tsx +++ b/src/apps/dashboard/components/drawer/AppDrawer.tsx @@ -29,8 +29,8 @@ const AppDrawer: FC = ({ - + ); diff --git a/src/apps/dashboard/components/drawer/sections/AdvancedDrawerSection.tsx b/src/apps/dashboard/components/drawer/sections/AdvancedDrawerSection.tsx index 452ea2a950..ddbee11841 100644 --- a/src/apps/dashboard/components/drawer/sections/AdvancedDrawerSection.tsx +++ b/src/apps/dashboard/components/drawer/sections/AdvancedDrawerSection.tsx @@ -1,31 +1,18 @@ import Article from '@mui/icons-material/Article'; -import ExpandLess from '@mui/icons-material/ExpandLess'; -import ExpandMore from '@mui/icons-material/ExpandMore'; -import Extension from '@mui/icons-material/Extension'; import Lan from '@mui/icons-material/Lan'; import Schedule from '@mui/icons-material/Schedule'; import VpnKey from '@mui/icons-material/VpnKey'; -import Collapse from '@mui/material/Collapse'; import List from '@mui/material/List'; import ListItem from '@mui/material/ListItem'; import ListItemIcon from '@mui/material/ListItemIcon'; import ListItemText from '@mui/material/ListItemText'; import ListSubheader from '@mui/material/ListSubheader'; import React from 'react'; -import { useLocation } from 'react-router-dom'; import ListItemLink from 'components/ListItemLink'; import globalize from 'scripts/globalize'; -const isPluginPath = (path: string) => ( - path.startsWith('/dashboard/plugins') - || path === '/configurationpage' -); - const AdvancedDrawerSection = () => { - const location = useLocation(); - const isPluginSectionOpen = isPluginPath(location.pathname); - return ( { - - - - - - - {isPluginSectionOpen ? : } - - - - - - - - - - - - diff --git a/src/apps/dashboard/components/drawer/sections/PluginDrawerSection.tsx b/src/apps/dashboard/components/drawer/sections/PluginDrawerSection.tsx index fe1ac2613b..d50cf8b08a 100644 --- a/src/apps/dashboard/components/drawer/sections/PluginDrawerSection.tsx +++ b/src/apps/dashboard/components/drawer/sections/PluginDrawerSection.tsx @@ -1,41 +1,26 @@ -import { ConfigurationPageInfo } from '@jellyfin/sdk/lib/generated-client'; -import { getDashboardApi } from '@jellyfin/sdk/lib/utils/api/dashboard-api'; -import { Folder } from '@mui/icons-material'; +import Extension from '@mui/icons-material/Extension'; +import Folder from '@mui/icons-material/Folder'; +import Public from '@mui/icons-material/Public'; import List from '@mui/material/List'; -import ListItem from '@mui/material/ListItem'; import ListItemIcon from '@mui/material/ListItemIcon'; import ListItemText from '@mui/material/ListItemText'; import ListSubheader from '@mui/material/ListSubheader'; -import React, { useEffect, useState } from 'react'; +import React, { useEffect } from 'react'; import ListItemLink from 'components/ListItemLink'; -import { useApi } from 'hooks/useApi'; import globalize from 'scripts/globalize'; import Dashboard from 'utils/dashboard'; +import { useConfigurationPages } from 'apps/dashboard/features/plugins/api/useConfigurationPages'; const PluginDrawerSection = () => { - const { api } = useApi(); - const [ pagesInfo, setPagesInfo ] = useState([]); + const { + data: pagesInfo, + error + } = useConfigurationPages({ enableInMainMenu: true }); useEffect(() => { - const fetchPluginPages = async () => { - if (!api) return; - - const pagesResponse = await getDashboardApi(api) - .getConfigurationPages({ enableInMainMenu: true }); - - setPagesInfo(pagesResponse.data); - }; - - fetchPluginPages() - .catch(err => { - console.error('[PluginDrawerSection] unable to fetch plugin config pages', err); - }); - }, [ api ]); - - if (!api || pagesInfo.length < 1) { - return null; - } + if (error) console.error('[PluginDrawerSection] unable to fetch plugin config pages', error); + }, [ error ]); return ( { } > - { - pagesInfo.map(pageInfo => ( - - - - {/* TODO: Support different icons? */} - - - - - - )) - } + `/${Dashboard.getPluginUrl(p.Name)}`)} + > + + + + + + + + + + + + + + {pagesInfo?.map(pageInfo => ( + + + {/* TODO: Support different icons? */} + + + + + ))} ); };