Skip to content

Commit a0a7ae3

Browse files
authored
Merge pull request #11 from k-grube/master
Add redux hot reload and immutable state middleware
2 parents 4d15533 + 6f867da commit a0a7ae3

29 files changed

+22195
-35
lines changed

package-lock.json

Lines changed: 20304 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"eslint-plugin-prettier": "^4.0.0",
6666
"prettier": "2.4.1",
6767
"react-scripts": "^4.0.3",
68+
"redux-immutable-state-invariant": "^2.1.0",
6869
"sass": "^1.43.2"
6970
},
7071
"engines": {

public/version_latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.3.0
1+
1.5.0

src/components/cipp/CellNullText.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
4+
export default function CellNullText({ cell }) {
5+
return cell ?? 'n/a'
6+
}
7+
8+
CellNullText.propTypes = {
9+
cell: PropTypes.string,
10+
}

src/components/cipp/CellProgressBar.js

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,33 @@ import { CProgress, CProgressBar } from '@coreui/react'
22
import PropTypes from 'prop-types'
33
import React from 'react'
44

5-
const CellProgressBar = ({ value }) => {
5+
const CellProgressBar = ({ value, reverse = false }) => {
66
let color
7-
switch (value) {
8-
case value <= 40:
9-
color = 'danger'
10-
break
11-
case value <= 75:
12-
color = 'warning'
13-
break
14-
case value > 75:
15-
color = 'success'
16-
break
17-
default:
18-
color = 'danger'
7+
if (!reverse) {
8+
switch (value) {
9+
case value <= 40:
10+
color = 'danger'
11+
break
12+
case value <= 75:
13+
color = 'warning'
14+
break
15+
case value > 75:
16+
color = 'success'
17+
break
18+
default:
19+
color = 'danger'
20+
}
21+
} else {
22+
switch (value) {
23+
case value >= 95:
24+
color = 'danger'
25+
break
26+
case value >= 90:
27+
color = 'warning'
28+
break
29+
default:
30+
color = 'success'
31+
}
1932
}
2033
return (
2134
<CProgress className="mb-3">
@@ -28,6 +41,7 @@ const CellProgressBar = ({ value }) => {
2841

2942
CellProgressBar.propTypes = {
3043
value: PropTypes.number,
44+
reverse: PropTypes.bool,
3145
}
3246

3347
export default CellProgressBar

src/hooks/useQuery.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react'
2+
import { useLocation } from 'react-router-dom'
3+
4+
function useQuery() {
5+
const { search } = useLocation()
6+
7+
return React.useMemo(() => new URLSearchParams(search), [search])
8+
}
9+
10+
export default useQuery

src/routes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const Home = React.lazy(() => import('./views/home/Home'))
44
const ViewProfile = React.lazy(() => import('./views/profile/ViewProfile'))
55
const Settings = React.lazy(() => import('./views/profile/Settings'))
66
const Users = React.lazy(() => import('./views/identity/administration/Users'))
7+
const EditUser = React.lazy(() => import('./views/identity/administration/EditUser'))
8+
const ViewUser = React.lazy(() => import('./views/identity/administration/ViewUser'))
79
const Groups = React.lazy(() => import('./views/identity/administration/Groups'))
810
const Devices = React.lazy(() => import('./views/identity/reports/Devices'))
911
const MFAReport = React.lazy(() => import('./views/identity/reports/MFAReport'))
@@ -61,6 +63,8 @@ const routes = [
6163
{ path: '/profile/view', name: 'View', component: ViewProfile },
6264
{ path: '/profile/settings', name: 'Settings', component: Settings },
6365
{ path: '/identity', name: 'Identity' },
66+
{ path: '/identity/administration/users/edit', name: 'Edit User', component: EditUser },
67+
{ path: '/identity/administration/users/view', name: 'View User', component: ViewUser },
6468
{ path: '/identity/administration', name: 'Administration' },
6569
{ path: '/identity/administration/users', name: 'Users', component: Users },
6670
{ path: '/identity/administration/groups', name: 'Groups', component: Groups },

src/store/middleware.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ export default function clientMiddleware(client) {
3636
}
3737

3838
// this will catch all errors, or any actions with prop `error` set
39+
// set action.hideToastError to `true` to ignore this middleware
3940
export function errorMiddleware() {
4041
return ({ dispatch, getState }) =>
4142
(next) =>
4243
(action) => {
43-
if (action.error) {
44+
if (action.error && !action.hideToastError) {
4445
console.error(action)
4546
const message =
4647
(action && action.error && action.error.message) || 'A generic error has occurred.'

0 commit comments

Comments
 (0)