Merge pull request #1494 from automatisch/aut-551
feat: hide notifications page in mation instances
This commit is contained in:
@@ -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,19 +39,36 @@ const drawerLinks = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const generateDrawerBottomLinks = ({ notificationBadgeContent = 0 }) => [
|
type GenerateDrawerBottomLinksOptions = {
|
||||||
{
|
isMation: boolean;
|
||||||
Icon: NotificationsIcon,
|
loading: boolean;
|
||||||
primary: 'settingsDrawer.notifications',
|
notificationBadgeContent: number;
|
||||||
to: URLS.UPDATES,
|
};
|
||||||
badgeContent: notificationBadgeContent,
|
|
||||||
},
|
const generateDrawerBottomLinks = ({
|
||||||
];
|
isMation,
|
||||||
|
loading,
|
||||||
|
notificationBadgeContent = 0,
|
||||||
|
}: GenerateDrawerBottomLinksOptions) => {
|
||||||
|
if (loading || isMation) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
Icon: NotificationsIcon,
|
||||||
|
primary: 'settingsDrawer.notifications',
|
||||||
|
to: URLS.UPDATES,
|
||||||
|
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 (
|
||||||
|
@@ -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 }}>
|
||||||
|
Reference in New Issue
Block a user