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 #56

Merged
merged 22 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
479ebbb
Added default value support to standards number type
OfficialEsco Mar 25, 2024
74c6f27
Merge pull request #2281 from Ren-Roros-Digital/NumberDefaultValue
KelvinTegelaar Mar 29, 2024
fe66cd8
handle undefined/null columns
JohnDuprey Mar 29, 2024
bf6fd46
Merge remote-tracking branch 'upstream/dev' into dev
JohnDuprey Mar 30, 2024
ad3dcd9
favourites adding
KelvinTegelaar Mar 31, 2024
034beab
Merge remote-tracking branch 'upstream/dev' into dev
JohnDuprey Mar 31, 2024
e493d71
add dash header if favorites are set.
KelvinTegelaar Apr 2, 2024
d4ef10f
null safe props on mail test
JohnDuprey Apr 2, 2024
aa9bef4
Merge pull request #19 from KelvinTegelaar/dev
kris6673 Apr 2, 2024
1d60573
Merge remote-tracking branch 'upstream/dev' into dev
JohnDuprey Apr 2, 2024
73209c1
Update licenses
kris6673 Apr 2, 2024
f1934da
Fix Number defaultValue
OfficialEsco Apr 3, 2024
1e38409
Merge pull request #2292 from kris6673/dev
JohnDuprey Apr 3, 2024
6ffac04
preserve tableFilter in tenant selector
JohnDuprey Apr 3, 2024
199f0cb
Merge remote-tracking branch 'upstream/dev' into dev
JohnDuprey Apr 3, 2024
a61438f
Merge pull request #2296 from JohnDuprey/dev
JohnDuprey Apr 3, 2024
0faf5d5
Merge pull request #2294 from Ren-Roros-Digital/Fix-defaultValue
JohnDuprey Apr 3, 2024
8a36a89
Up version
JohnDuprey Apr 3, 2024
4a3e79d
Merge pull request #2297 from JohnDuprey/dev
JohnDuprey Apr 3, 2024
e3cb141
Merge pull request #2298 from KelvinTegelaar/dev
JohnDuprey Apr 3, 2024
043b6d3
Revert "Merge pull request #2298 from KelvinTegelaar/dev"
JohnDuprey Apr 3, 2024
57d0bf6
up version
JohnDuprey Apr 3, 2024
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
Prev Previous commit
Next Next commit
Revert "Merge pull request KelvinTegelaar#2298 from KelvinTegelaar/dev"
This reverts commit e3cb141, reversing
changes made to 1c3eb56.
  • Loading branch information
JohnDuprey committed Apr 3, 2024
commit 043b6d3446ec074275faefe2f14c03818ecb9411
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