Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from KelvinTegelaar:main #93

Merged
merged 5 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 53 additions & 55 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React, { Suspense } from 'react'
import { BrowserRouter, Route, Routes, Navigate } from 'react-router-dom'
import { BrowserRouter, Route, Routes, Navigate, useLocation } from 'react-router-dom'
import { PrivateRoute, FullScreenLoading, ErrorBoundary } from 'src/components/utilities'
import 'src/scss/style.scss'
import { Helmet } from 'react-helmet-async'
import { Helmet, HelmetProvider } from 'react-helmet-async'
import Skeleton from 'react-loading-skeleton'
import TimeAgo from 'javascript-time-ago'
import en from 'javascript-time-ago/locale/en.json'
TimeAgo.addDefaultLocale(en)
import { library } from '@fortawesome/fontawesome-svg-core'
import { fas } from '@fortawesome/free-solid-svg-icons'
import routes from 'src/routes'
import { useAuthCheck } from './components/utilities/CippauthCheck'
import importsMap from './importsMap'

library.add(fas)
Expand All @@ -32,59 +31,58 @@ const Logout = React.lazy(() => import('./views/pages/login/Logout'))
const App = () => {
return (
<BrowserRouter>
<Suspense fallback={<FullScreenLoading />}>
<Helmet>
<title>CIPP</title>
</Helmet>
<Routes>
<Route exact path="/LogoutRedirect" name="LogoutRedirect" element={<PageLogOut />} />
<Route exact path="/401" name="Page 401" element={<Page401 />} />
<Route exact path="/403" name="Page 403" element={<Page403 />} />
<Route exact path="/404" name="Page 404" element={<Page404 />} />
<Route exact path="/500" name="Page 500" element={<Page500 />} />
<Route exact path="/login" name="Login" element={<Login />} />
<Route exact path="/logout" name="Logout" element={<Logout />} />
<Route
path="/"
element={
<PrivateRoute>
<DefaultLayout />
</PrivateRoute>
}
>
{routes.map((route, idx) => {
const allowedRoles = route.allowedRoles
const Routecomponent = dynamicImport(route.path)
//console.log('route', route)
//console.log('Routecomponent', Routecomponent)
return (
route.component && (
<Route
key={`route-${idx}`}
path={route.path}
exact={route.exact}
name={route.name}
element={
<PrivateRoute allowedRoles={allowedRoles}>
<Suspense fallback={<Skeleton />}>
<Helmet>
<title>CIPP - {route.name}</title>
</Helmet>
<ErrorBoundary key={route.name}>
<Routecomponent />
</ErrorBoundary>
</Suspense>
</PrivateRoute>
}
/>
<HelmetProvider>
<Suspense fallback={<FullScreenLoading />}>
<Helmet>
<title>CIPP</title>
</Helmet>
<Routes>
<Route exact path="/LogoutRedirect" name="LogoutRedirect" element={<PageLogOut />} />
<Route exact path="/401" name="Page 401" element={<Page401 />} />
<Route exact path="/403" name="Page 403" element={<Page403 />} />
<Route exact path="/404" name="Page 404" element={<Page404 />} />
<Route exact path="/500" name="Page 500" element={<Page500 />} />
<Route exact path="/login" name="Login" element={<Login />} />
<Route exact path="/logout" name="Logout" element={<Logout />} />
<Route
path="/"
element={
<PrivateRoute>
<DefaultLayout />
</PrivateRoute>
}
>
{routes.map((route, idx) => {
const allowedRoles = route.allowedRoles
const Routecomponent = dynamicImport(route.path)
//console.log('route', route)
//console.log('Routecomponent', Routecomponent)
return (
route.component && (
<Route
key={`route-${idx}`}
path={route.path}
exact={route.exact}
name={route.name}
element={
<PrivateRoute allowedRoles={allowedRoles}>
<Suspense fallback={<Skeleton />}>
<ErrorBoundary key={route.name}>
<Routecomponent />
</ErrorBoundary>
</Suspense>
</PrivateRoute>
}
/>
)
)
)
})}
<Route path="/" element={<Navigate to="/home" replace={true} />} />
</Route>
<Route path="*" name="Page 404" element={<Page404 />} />
</Routes>
</Suspense>
})}
<Route path="/" element={<Navigate to="/home" replace={true} />} />
</Route>
<Route path="*" name="Page 404" element={<Page404 />} />
</Routes>
</Suspense>
</HelmetProvider>
</BrowserRouter>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useNavFavouriteCheck.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const useNavFavouriteCheck = (navigation) => {
var items = []

recentPages.map((path) => {
const item = routes.find((route) => route.path === path)
const item = routes.find((route) => route.path.toLowerCase() === path.toLowerCase())
if (item?.path) {
items.push({
name: item.name,
Expand Down
46 changes: 31 additions & 15 deletions src/layout/DefaultLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { toggleSwitcher } from 'src/store/features/switcher'
import { useHotkeys } from 'react-hotkeys-hook'
import { useMediaPredicate } from 'react-media-hook'
import { setRecentPages } from 'src/store/features/app'
import routes from 'src/routes'
import { Helmet } from 'react-helmet-async'

const DefaultLayout = () => {
const preferredTheme = useMediaPredicate('(prefers-color-scheme: dark)') ? 'impact' : 'cyberdrain'
Expand All @@ -17,6 +19,15 @@ const DefaultLayout = () => {
const dispatch = useDispatch()
const location = useLocation()

const [title, setTitle] = useState('CIPP')
useEffect(() => {
let route = routes.find((route) => route.path.toLowerCase() === location.pathname.toLowerCase())
if (route?.name) {
console.log(route)
setTitle(route.name)
}
}, [setTitle, location.pathname])

let theme
if (themePreference === 'default') {
theme = preferredTheme
Expand Down Expand Up @@ -70,24 +81,29 @@ const DefaultLayout = () => {
)

return (
<div>
<FastSwitcherModal />
<ModalRoot />
<Toasts />
<>
<Helmet>
<title>CIPP - {title}</title>
</Helmet>
<div>
<FastSwitcherModal />
<ModalRoot />
<Toasts />

<AppSidebar />
<div className="wrapper d-flex flex-column min-vh-100">
<AppHeader />
<div className="body flex-grow-1 px-xl-3">
<CContainer fluid>
<Suspense fallback={<FullScreenLoading />}>
<Outlet />
</Suspense>
</CContainer>
<AppSidebar />
<div className="wrapper d-flex flex-column min-vh-100">
<AppHeader />
<div className="body flex-grow-1 px-xl-3">
<CContainer fluid>
<Suspense fallback={<FullScreenLoading />}>
<Outlet />
</Suspense>
</CContainer>
</div>
<AppFooter />
</div>
<AppFooter />
</div>
</div>
</>
)
}

Expand Down
8 changes: 4 additions & 4 deletions src/views/email-exchange/tools/MailTest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ const MailTest = () => {
},
{
name: 'SPF',
selector: (row) => row?.AuthResult.filter((x) => x?.Name === 'spf')[0].Status == 'pass',
selector: (row) => row?.AuthResult.filter((x) => x?.Name === 'spf')[0]?.Status == 'pass',
cell: cellBooleanFormatter(),
},
{
name: 'DKIM',
selector: (row) => row?.AuthResult.filter((x) => x?.Name === 'dkim')[0].Status == 'pass',
selector: (row) => row?.AuthResult.filter((x) => x?.Name === 'dkim')[0]?.Status == 'pass',
cell: cellBooleanFormatter(),
},
{
name: 'DMARC',
selector: (row) => row?.AuthResult.filter((x) => x?.Name === 'dmarc')[0].Status == 'pass',
selector: (row) => row?.AuthResult.filter((x) => x?.Name === 'dmarc')[0]?.Status == 'pass',
cell: cellBooleanFormatter(),
},
{
name: 'Comp Auth',
selector: (row) => row?.AuthResult.filter((x) => x?.Name === 'compauth')[0].Status == 'pass',
selector: (row) => row?.AuthResult.filter((x) => x?.Name === 'compauth')[0]?.Status == 'pass',
cell: cellBooleanFormatter(),
},
{
Expand Down