Skip to content

Commit

Permalink
Revert "Merge remote-tracking branch 'upstream/main'"
Browse files Browse the repository at this point in the history
This reverts commit 8199cf4, reversing
changes made to d20db74.
  • Loading branch information
DChorn-ANS committed Apr 3, 2024
1 parent 8199cf4 commit 556d701
Show file tree
Hide file tree
Showing 22 changed files with 1,297 additions and 2,073 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cipp",
"version": "5.4.1",
"version": "5.4.0",
"description": "The CyberDrain Improved Partner Portal is a portal to help manage administration for Microsoft Partners.",
"homepage": "https://cipp.app/",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion public/version_latest.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.4.1
5.4.0
40 changes: 32 additions & 8 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@ import React, { Suspense } from 'react'
import { BrowserRouter, Route, Routes, Navigate } from 'react-router-dom'
import { PrivateRoute, FullScreenLoading, ErrorBoundary } from 'src/components/utilities'
import 'src/scss/style.scss'
import routes from 'src/routes'
import { Helmet } from 'react-helmet-async'
import adminRoutes from './adminRoutes'
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'

library.add(fas)
const dynamicImport = (path) => React.lazy(() => import(`./${path}`))

// Containers
const DefaultLayout = React.lazy(() => import('./layout/DefaultLayout'))

// Pages
const Page401 = React.lazy(() => import('./views/pages/page401/Page401'))
const Page403 = React.lazy(() => import('./views/pages/page403/Page403'))
const Page404 = React.lazy(() => import('./views/pages/page404/Page404'))
const Page500 = React.lazy(() => import('./views/pages/page500/Page500'))
const PageLogOut = React.lazy(() => import('src/views/pages/LogoutRedirect/PageLogOut'))
const Login = React.lazy(() => import('./views/pages/login/Login'))
const Logout = React.lazy(() => import('./views/pages/login/Logout'))

const App = () => {
return (
<BrowserRouter>
Expand All @@ -46,23 +50,43 @@ const App = () => {
}
>
{routes.map((route, idx) => {
const Component = dynamicImport(route.component)
const allowedRoles = route.allowedRoles
return (
Component && (
route.component && (
<Route
key={`route-${idx}`}
path={route.path}
exact={route.exact}
name={route.name}
element={
<Suspense fallback={<Skeleton />}>
<Helmet>
<title>CIPP - {route.name}</title>
</Helmet>
<ErrorBoundary key={route.name}>
<route.component />
</ErrorBoundary>
</Suspense>
}
/>
)
)
})}
{adminRoutes.map((route, idx) => {
return (
route.component && (
<Route
key={`route-${idx}`}
path={route.path}
exact={route.exact}
name={route.name}
element={
<PrivateRoute allowedRoles={allowedRoles}>
<PrivateRoute routeType="admin">
<Suspense fallback={<Skeleton />}>
<Helmet>
<title>CIPP - {route.name}</title>
</Helmet>
<ErrorBoundary key={route.name}>
<Component />
<route.component />
</ErrorBoundary>
</Suspense>
</PrivateRoute>
Expand Down
76 changes: 76 additions & 0 deletions src/adminRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React from 'react'

const CIPPSettings = React.lazy(() => import('src/views/cipp/app-settings/CIPPSettings'))
const Setup = React.lazy(() => import('src/views/cipp/Setup'))
const ApplyStandard = React.lazy(() => import('src/views/tenant/standards/ListStandards'))
const GDAPStatus = React.lazy(() => import('src/views/tenant/administration/ListGDAPQueue'))
const GDAP = React.lazy(() => import('src/views/tenant/administration/GDAPWizard'))
const GDAPInvite = React.lazy(() => import('src/views/tenant/administration/GDAPInviteWizard'))
const GDAPRoleWizard = React.lazy(() => import('src/views/tenant/administration/GDAPRoleWizard'))
const GDAPRoles = React.lazy(() => import('src/views/tenant/administration/ListGDAPRoles'))
const GDAPRelationships = React.lazy(() =>
import('./views/tenant/administration/ListGDAPRelationships'),
)
const appapproval = React.lazy(() => import('src/views/cipp/AppApproval'))
const TenantOffboardingWizard = React.lazy(() =>
import('src/views/tenant/administration/TenantOffboardingWizard'),
)
const TenantOnboardingWizard = React.lazy(() =>
import('src/views/tenant/administration/TenantOnboardingWizard'),
)

const adminRoutes = [
{ path: '/cipp', name: 'CIPP' },
{ path: '/cipp/cipp', name: 'CIPP' },
{ path: '/cipp/settings', name: 'Settings', component: CIPPSettings },
{ path: '/cipp/setup', name: 'Setup', component: Setup },

{ path: '/tenant/administration/gdap', name: 'GDAP Wizard', component: GDAP },
{
path: '/tenant/administration/gdap-invite',
name: 'GDAP Invite Wizard',
component: GDAPInvite,
},
{
path: '/tenant/administration/gdap-role-wizard',
name: 'GDAP Role Wizard',
component: GDAPRoleWizard,
},
{
path: '/tenant/administration/gdap-roles',
name: 'GDAP Roles',
component: GDAPRoles,
},
{
path: '/tenant/administration/gdap-relationships',
name: 'GDAP Relationships',
component: GDAPRelationships,
},
{
path: '/tenant/administration/appapproval',
name: 'App Approval',
component: appapproval,
},
{
path: '/tenant/administration/gdap-status',
name: 'GDAP Status',
component: GDAPStatus,
},
{
path: '/tenant/standards/list-standards',
name: 'List Standard',
component: ApplyStandard,
},
{
path: '/tenant/administration/tenant-offboarding-wizard',
name: 'Tenant Offboarding',
component: TenantOffboardingWizard,
},
{
path: '/tenant/administration/tenant-onboarding-wizard',
name: 'Tenant Onboarding',
component: TenantOnboardingWizard,
},
]

export default adminRoutes
3 changes: 1 addition & 2 deletions src/components/forms/RFFComponents.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,10 @@ export const RFFCFormInput = ({
spellCheck = true,
autoFocus = false,
hiddenValue,
defaultValue,
onChange,
}) => {
return (
<Field defaultValue={defaultValue} initialValue={hiddenValue} name={name} validate={validate}>
<Field initialValue={hiddenValue} name={name} validate={validate}>
{({ input, meta }) => {
const handleChange = onChange
? (e) => {
Expand Down
8 changes: 1 addition & 7 deletions src/components/layout/AppSidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import { AppSidebarNav } from 'src/components/layout'
import SimpleBar from 'simplebar-react'
import 'simplebar/dist/simplebar.min.css'
import navigation from 'src/_nav'
import { useAuthCheck } from '../utilities/CippauthCheck'
import routes from 'src/routes'
import { useRouteNavCompare } from 'src/hooks/useRouteNavCompare'
import { useNavFavouriteCheck } from 'src/hooks/useNavFavouriteCheck'

const AppSidebar = () => {
const i =
Expand All @@ -26,8 +22,6 @@ const AppSidebar = () => {
if (!i.includes('JGySCBt1QXmNc')) {
throw ''
}
const newNav = useRouteNavCompare(navigation)
const navwithFavourites = useNavFavouriteCheck(newNav)
return (
<CSidebar
onVisibleChange={(visible) => {
Expand All @@ -47,7 +41,7 @@ const AppSidebar = () => {
/>
<CSidebarNav>
<SimpleBar>
<AppSidebarNav items={navwithFavourites} />
<AppSidebarNav items={navigation} />
</SimpleBar>
</CSidebarNav>
</CSidebar>
Expand Down
7 changes: 1 addition & 6 deletions src/components/tables/CellTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ export default function cellTable(
columnProp = column
}

if (
!Array.isArray(columnProp) &&
typeof columnProp === 'object' &&
columnProp !== undefined &&
columnProp !== null
) {
if (!Array.isArray(columnProp) && typeof columnProp === 'object') {
columnProp = Object.keys(columnProp).map((key) => {
return {
[key]: columnProp[key],
Expand Down
27 changes: 0 additions & 27 deletions src/components/utilities/CippauthCheck.jsx

This file was deleted.

39 changes: 30 additions & 9 deletions src/components/utilities/PrivateRoute.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,41 @@
import React from 'react'
import { Navigate } from 'react-router-dom'
import { useLoadClientPrincipalQuery } from 'src/store/api/auth'
import { FullScreenLoading } from 'src/components/utilities'
import { useDispatch } from 'react-redux'
import { updateAccessToken } from 'src/store/features/auth'
import PropTypes from 'prop-types'
import { useAuthCheck } from './CippauthCheck'

export const PrivateRoute = ({ children, allowedRoles }) => {
const { isLoading, component: authComponent } = useAuthCheck(allowedRoles)
if (isLoading) {
export const PrivateRoute = ({ children, routeType }) => {
const dispatch = useDispatch()
const { data: profile, error, isFetching } = useLoadClientPrincipalQuery()
//console.log()
if (isFetching) {
return <FullScreenLoading />
}
if (authComponent) {
return authComponent

dispatch(updateAccessToken(profile))
let roles = null
if (null !== profile?.clientPrincipal) {
roles = profile?.clientPrincipal.userRoles
} else if (null === profile?.clientPrincipal) {
return <Navigate to={`/login?redirect_uri=${window.location.href}`} />
}
if (null === roles) {
return <Navigate to={`/login?redirect_uri=${window.location.href}`} />
} else {
const isAuthenticated =
roles.includes('admin') || roles.includes('editor') || (roles.includes('readonly') && !error)
const isAdmin = roles.includes('admin')
if (routeType === 'admin') {
return !isAdmin ? <Navigate to="/403" /> : children
} else {
return !isAuthenticated ? <Navigate to="/403" /> : children
}
}
return children
}

PrivateRoute.propTypes = {
children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]).isRequired,
allowedRoles: PropTypes.arrayOf(PropTypes.string),
children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]),
routeType: PropTypes.string,
}
8 changes: 1 addition & 7 deletions src/components/utilities/TenantSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,14 @@ const TenantSelector = ({ action, showAllTenantSelector = true, NavSelector = fa
const Paramcount = Array.from(searchParams).length
if (Paramcount <= 1) {
const customerId = searchParams.get('customerId')
const tableFilter = searchParams.get('tableFilter')
var newSearchParams = {}
if (tableFilter) {
newSearchParams.tableFilter = tableFilter
}
if (customerId && isSuccess) {
const currentTenant = tenants.filter((tenant) => tenant.customerId === customerId)
if (currentTenant.length > 0) {
dispatch(setCurrentTenant({ tenant: currentTenant[0] }))
}
}
if (!customerId && Object.keys(currentTenant).length > 0) {
newSearchParams.customerId = currentTenant?.customerId
updateSearchParams(newSearchParams)
updateSearchParams({ customerId: currentTenant?.customerId })
}
}
}, [dispatch, isSuccess, searchParams, currentTenant, tenants, updateSearchParams])
Expand Down
Loading

0 comments on commit 556d701

Please sign in to comment.