2024-08-06 23:28:49 -04:00
|
|
|
import Extension from '@mui/icons-material/Extension';
|
|
|
|
import Folder from '@mui/icons-material/Folder';
|
|
|
|
import Public from '@mui/icons-material/Public';
|
2022-11-28 16:39:13 -05:00
|
|
|
import List from '@mui/material/List';
|
|
|
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
|
|
import ListItemText from '@mui/material/ListItemText';
|
|
|
|
import ListSubheader from '@mui/material/ListSubheader';
|
2024-08-06 23:28:49 -04:00
|
|
|
import React, { useEffect } from 'react';
|
2022-11-28 16:39:13 -05:00
|
|
|
|
2023-09-27 02:07:40 -04:00
|
|
|
import ListItemLink from 'components/ListItemLink';
|
2024-08-14 13:31:34 -04:00
|
|
|
import globalize from 'lib/globalize';
|
2022-11-28 16:39:13 -05:00
|
|
|
import Dashboard from 'utils/dashboard';
|
2024-08-06 23:28:49 -04:00
|
|
|
import { useConfigurationPages } from 'apps/dashboard/features/plugins/api/useConfigurationPages';
|
2022-11-28 16:39:13 -05:00
|
|
|
|
|
|
|
const PluginDrawerSection = () => {
|
2024-08-06 23:28:49 -04:00
|
|
|
const {
|
|
|
|
data: pagesInfo,
|
|
|
|
error
|
|
|
|
} = useConfigurationPages({ enableInMainMenu: true });
|
2022-11-28 16:39:13 -05:00
|
|
|
|
|
|
|
useEffect(() => {
|
2024-08-06 23:28:49 -04:00
|
|
|
if (error) console.error('[PluginDrawerSection] unable to fetch plugin config pages', error);
|
|
|
|
}, [ error ]);
|
2022-11-28 16:39:13 -05:00
|
|
|
|
|
|
|
return (
|
|
|
|
<List
|
|
|
|
aria-labelledby='plugins-subheader'
|
|
|
|
subheader={
|
|
|
|
<ListSubheader component='div' id='plugins-subheader'>
|
|
|
|
{globalize.translate('TabPlugins')}
|
|
|
|
</ListSubheader>
|
|
|
|
}
|
|
|
|
>
|
2024-08-06 23:28:49 -04:00
|
|
|
<ListItemLink
|
|
|
|
to='/dashboard/plugins'
|
|
|
|
includePaths={[ '/configurationpage' ]}
|
|
|
|
excludePaths={pagesInfo?.map(p => `/${Dashboard.getPluginUrl(p.Name)}`)}
|
|
|
|
>
|
|
|
|
<ListItemIcon>
|
|
|
|
<Extension />
|
|
|
|
</ListItemIcon>
|
|
|
|
<ListItemText primary={globalize.translate('TabMyPlugins')} />
|
|
|
|
</ListItemLink>
|
|
|
|
|
|
|
|
<ListItemLink
|
|
|
|
to='/dashboard/plugins/catalog'
|
|
|
|
includePaths={[ '/dashboard/plugins/repositories' ]}
|
|
|
|
>
|
|
|
|
<ListItemIcon>
|
|
|
|
<Public />
|
|
|
|
</ListItemIcon>
|
|
|
|
<ListItemText primary={globalize.translate('TabCatalog')} />
|
|
|
|
</ListItemLink>
|
|
|
|
|
|
|
|
{pagesInfo?.map(pageInfo => (
|
|
|
|
<ListItemLink
|
|
|
|
key={pageInfo.PluginId}
|
|
|
|
to={`/${Dashboard.getPluginUrl(pageInfo.Name)}`}
|
|
|
|
>
|
|
|
|
<ListItemIcon>
|
|
|
|
{/* TODO: Support different icons? */}
|
|
|
|
<Folder />
|
|
|
|
</ListItemIcon>
|
|
|
|
<ListItemText primary={pageInfo.DisplayName} />
|
|
|
|
</ListItemLink>
|
|
|
|
))}
|
2022-11-28 16:39:13 -05:00
|
|
|
</List>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default PluginDrawerSection;
|