Merge pull request #1494 from automatisch/aut-551

feat: hide notifications page in mation instances
This commit is contained in:
Ali BARIN
2023-12-15 18:00:08 +01:00
committed by GitHub
2 changed files with 42 additions and 8 deletions

View File

@@ -12,6 +12,7 @@ import * as URLS from 'config/urls';
import useVersion from 'hooks/useVersion'; import useVersion from 'hooks/useVersion';
import AppBar from 'components/AppBar'; import AppBar from 'components/AppBar';
import Drawer from 'components/Drawer'; import Drawer from 'components/Drawer';
import useAutomatischInfo from 'hooks/useAutomatischInfo';
type PublicLayoutProps = { type PublicLayoutProps = {
children: React.ReactNode; children: React.ReactNode;
@@ -38,7 +39,22 @@ const drawerLinks = [
}, },
]; ];
const generateDrawerBottomLinks = ({ notificationBadgeContent = 0 }) => [ type GenerateDrawerBottomLinksOptions = {
isMation: boolean;
loading: boolean;
notificationBadgeContent: number;
};
const generateDrawerBottomLinks = ({
isMation,
loading,
notificationBadgeContent = 0,
}: GenerateDrawerBottomLinksOptions) => {
if (loading || isMation) {
return [];
}
return [
{ {
Icon: NotificationsIcon, Icon: NotificationsIcon,
primary: 'settingsDrawer.notifications', primary: 'settingsDrawer.notifications',
@@ -46,11 +62,13 @@ const generateDrawerBottomLinks = ({ notificationBadgeContent = 0 }) => [
badgeContent: notificationBadgeContent, badgeContent: notificationBadgeContent,
}, },
]; ];
};
export default function PublicLayout({ export default function PublicLayout({
children, children,
}: PublicLayoutProps): React.ReactElement { }: PublicLayoutProps): React.ReactElement {
const version = useVersion(); const version = useVersion();
const { isMation, loading } = useAutomatischInfo();
const theme = useTheme(); const theme = useTheme();
const matchSmallScreens = useMediaQuery(theme.breakpoints.down('lg')); const matchSmallScreens = useMediaQuery(theme.breakpoints.down('lg'));
const [isDrawerOpen, setDrawerOpen] = React.useState(!matchSmallScreens); const [isDrawerOpen, setDrawerOpen] = React.useState(!matchSmallScreens);
@@ -60,6 +78,8 @@ export default function PublicLayout({
const drawerBottomLinks = generateDrawerBottomLinks({ const drawerBottomLinks = generateDrawerBottomLinks({
notificationBadgeContent: version.newVersionCount, notificationBadgeContent: version.newVersionCount,
loading,
isMation,
}); });
return ( return (

View File

@@ -1,4 +1,5 @@
import * as React from 'react'; import * as React from 'react';
import { useNavigate } from 'react-router-dom';
import Box from '@mui/material/Box'; import Box from '@mui/material/Box';
import Stack from '@mui/material/Stack'; import Stack from '@mui/material/Stack';
@@ -7,6 +8,8 @@ import Container from 'components/Container';
import NotificationCard from 'components/NotificationCard'; import NotificationCard from 'components/NotificationCard';
import PageTitle from 'components/PageTitle'; import PageTitle from 'components/PageTitle';
import useFormatMessage from 'hooks/useFormatMessage'; import useFormatMessage from 'hooks/useFormatMessage';
import useAutomatischInfo from 'hooks/useAutomatischInfo';
import * as URLS from 'config/urls';
interface INotification { interface INotification {
name: string; name: string;
@@ -16,8 +19,19 @@ interface INotification {
} }
export default function Updates(): React.ReactElement { export default function Updates(): React.ReactElement {
const navigate = useNavigate();
const formatMessage = useFormatMessage(); const formatMessage = useFormatMessage();
const { notifications } = useNotifications(); const { notifications } = useNotifications();
const { isMation, loading } = useAutomatischInfo();
React.useEffect(
function redirectToHomepageInMation() {
if (!loading && isMation) {
navigate(URLS.DASHBOARD);
}
},
[loading, isMation]
);
return ( return (
<Box sx={{ py: 3 }}> <Box sx={{ py: 3 }}>