-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPaper.tsx
More file actions
44 lines (42 loc) · 1.5 KB
/
Paper.tsx
File metadata and controls
44 lines (42 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Box, Card, Container } from '@mui/material'
import LoadingScreen from 'components/LoadingScreen'
import React, { useEffect } from 'react'
import { useLocation } from 'react-router-dom'
import Error from 'components/Error'
import { useAppDispatch, useAppSelector } from 'redux/hooks'
import { setError } from 'redux/reducers'
import ConfigureGitModal from 'components/modals/ConfigureGitModal'
import MainLayout from './Base'
interface Props {
loading?: boolean
comp?: React.ReactElement
title?: string
children?: any
}
export default function ({ loading, comp, title, children }: Props): React.ReactElement {
const location = useLocation()
// grafana iframe background color
const dashboardStyle =
location.pathname === '/' ? { backgroundColor: 'background.contrast' } : { backgroundColor: 'transparent' }
const dispatch = useAppDispatch()
const globalError = useAppSelector(({ global: { error } }) => error)
useEffect(() => {
// clear global error when pathname changes to prevent the error from reappearing
if (globalError) dispatch(setError(undefined))
}, [location.pathname])
return (
<MainLayout title={title}>
<Container maxWidth='lg'>
<Card sx={{ ...dashboardStyle }}>
<Error />
{loading && !globalError && <LoadingScreen />}
<Box sx={{ display: globalError && 'none' }}>
{!loading && comp}
{children}
</Box>
</Card>
</Container>
<ConfigureGitModal />
</MainLayout>
)
}