Skip to content

Commit 6463a60

Browse files
Merge pull request #1765 from KelvinTegelaar/dev
Dev to release
2 parents 66a0288 + e93d815 commit 6463a60

File tree

23 files changed

+1209
-696
lines changed

23 files changed

+1209
-696
lines changed

public/version_latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.2.1
1+
4.3.0

src/_nav.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,11 @@ const _nav = [
663663
name: 'Settings',
664664
to: '/cipp/settings',
665665
},
666+
{
667+
component: CNavItem,
668+
name: 'Scheduler',
669+
to: '/cipp/scheduler',
670+
},
666671
{
667672
component: CNavItem,
668673
name: 'SAM Setup Wizard',

src/adminRoutes.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ const GDAPRelationships = React.lazy(() =>
1111
import('./views/tenant/administration/ListGDAPRelationships'),
1212
)
1313
const appapproval = React.lazy(() => import('src/views/cipp/AppApproval'))
14+
const Scheduler = React.lazy(() => import('src/views/cipp/Scheduler'))
1415

1516
const adminRoutes = [
1617
{ path: '/cipp', name: 'CIPP' },
1718
{ path: '/cipp/cipp', name: 'CIPP' },
1819
{ path: '/cipp/settings', name: 'Settings', component: CIPPSettings },
1920
{ path: '/cipp/setup', name: 'Setup', component: Setup },
21+
{ path: '/cipp/scheduler', name: 'Scheduler', component: Scheduler },
22+
2023
{ path: '/tenant/administration/gdap', name: 'GDAP Wizard', component: GDAP },
2124
{ path: '/tenant/administration/gdap-invite', name: 'GDAP Invite Wizard', component: GDAPInvite },
2225
{

src/components/forms/RFFComponents.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ export const RFFCFormSwitch = ({
8888
className = 'mb-3',
8989
validate,
9090
disabled = false,
91+
initialValue,
9192
}) => {
9293
return (
93-
<Field name={name} type="checkbox" validate={validate}>
94+
<Field initialValue={initialValue} name={name} type="checkbox" validate={validate}>
9495
{({ meta, input }) => (
9596
<ConditionWrapper
9697
condition={helpText}

src/components/layout/AppHeader.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
CHeaderToggler,
1212
CImage,
1313
CSidebarBrand,
14+
CButton,
1415
} from '@coreui/react'
1516
import { AppHeaderDropdown, AppHeaderSearch } from 'src/components/header'
1617
import { TenantSelector } from '../utilities'
@@ -22,8 +23,12 @@ import { faCaretSquareLeft, faCaretSquareRight } from '@fortawesome/free-solid-s
2223
import { toggleSidebarShow } from 'src/store/features/app'
2324
import { useMediaPredicate } from 'react-media-hook'
2425
import { useLoadAlertsDashQuery } from 'src/store/api/app'
26+
import { Link } from 'react-router-dom'
27+
import { useLocation } from 'react-router-dom'
28+
2529
const AppHeader = () => {
2630
const dispatch = useDispatch()
31+
const location = useLocation()
2732
const sidebarShow = useSelector((state) => state.app.sidebarShow)
2833
const currentTheme = useSelector((state) => state.app.currentTheme)
2934
const preferredTheme = useMediaPredicate('(prefers-color-scheme: dark)') ? 'impact' : 'cyberdrain'
@@ -57,6 +62,16 @@ const AppHeader = () => {
5762
</CSidebarBrand>
5863
<CHeaderNav className="p-md-2 flex-grow-1">
5964
<TenantSelector NavSelector={true} />
65+
<CNavItem>
66+
<a
67+
target="_blank"
68+
href={`https://docs.cipp.app/user-documentation${location.pathname}`}
69+
>
70+
<CButton variant="ghost">
71+
<FontAwesomeIcon icon={'question'} size="lg" />
72+
</CButton>
73+
</a>
74+
</CNavItem>
6075
<CNavItem>
6176
<AppHeaderSearch />
6277
</CNavItem>

src/components/tables/CellBadge.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@ import React from 'react'
33
import { CBadge } from '@coreui/react'
44

55
export const CellBadge = ({ label = '', color = '', children, ...rest }) => {
6+
//Create a case select, and return the color based on the label
7+
switch (label.toLowerCase()) {
8+
case 'planned':
9+
color = 'info'
10+
break
11+
case 'failed':
12+
color = 'danger'
13+
break
14+
case 'completed':
15+
color = 'success'
16+
break
17+
case 'banned':
18+
color = 'danger'
19+
break
20+
case 'running':
21+
color = 'primary'
22+
}
23+
624
return (
725
<CBadge color={color} {...rest}>
826
{label}

src/components/tables/CellDate.js

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ import PropTypes from 'prop-types'
44
import { CTooltip } from '@coreui/react'
55
import ReactTimeAgo from 'react-time-ago'
66

7-
/**
8-
*
9-
* @param format ['short', 'long', 'relative']
10-
* @param value
11-
* @returns {JSX.Element}
12-
* @constructor
13-
*/
147
export const CellDate = ({ format = 'short', showTime = true, showDate = true, cell }) => {
158
if (!cell || (!showTime && !showDate)) {
169
return <div />
@@ -21,25 +14,29 @@ export const CellDate = ({ format = 'short', showTime = true, showDate = true, c
2114
locale = navigator.language
2215
}
2316

24-
// cheatsheet
25-
// https://devhints.io/wip/intl-datetime
26-
const dateTimeArgs = [
27-
[locale, 'default'], // add fallback option if locale doesn't load properly
28-
]
17+
// Convert cell value to a number and check if it's a Unix timestamp
18+
const possibleUnixTimestamp = Number(cell)
19+
const isUnixTimestamp = !isNaN(possibleUnixTimestamp) && possibleUnixTimestamp > 1000000000
20+
let dateObject
21+
22+
if (isUnixTimestamp) {
23+
dateObject = moment.unix(possibleUnixTimestamp).toDate()
24+
} else {
25+
dateObject = moment(cell).toDate()
26+
}
27+
28+
const dateTimeArgs = [[locale, 'default']]
2929

3030
const dateTimeFormatOptions = {}
31-
if (format == 'relative') {
31+
32+
if (format === 'relative') {
3233
try {
33-
return (
34-
<CTooltip content={cell}>
35-
<ReactTimeAgo date={cell} />
36-
</CTooltip>
37-
)
34+
return <ReactTimeAgo date={dateObject} />
3835
} catch (error) {
39-
console.error('Error formatting date, fallback to string value', { date: cell, error })
36+
console.error('Error formatting date, fallback to string value', { date: dateObject, error })
4037
return (
41-
<CTooltip content={cell}>
42-
<div>{String(cell)}</div>
38+
<CTooltip content={dateObject.toString()}>
39+
<div>{String(dateObject)}</div>
4340
</CTooltip>
4441
)
4542
}
@@ -56,16 +53,14 @@ export const CellDate = ({ format = 'short', showTime = true, showDate = true, c
5653
let formatted
5754

5855
try {
59-
// lots of dates returned are unreliably parsable (e.g. non ISO8601 format)
60-
// fallback using moment to parse into date object
61-
formatted = new Intl.DateTimeFormat(...dateTimeArgs).format(moment(cell).toDate())
56+
formatted = new Intl.DateTimeFormat(...dateTimeArgs).format(dateObject)
6257
} catch (error) {
63-
console.error('Error formatting date, fallback to string value', { date: cell, error })
64-
formatted = cell
58+
console.error('Error formatting date, fallback to string value', { date: dateObject, error })
59+
formatted = dateObject.toString()
6560
}
6661

6762
return (
68-
<CTooltip content={cell}>
63+
<CTooltip content={dateObject.toString()}>
6964
<div>{String(formatted)}</div>
7065
</CTooltip>
7166
)
@@ -74,7 +69,7 @@ export const CellDate = ({ format = 'short', showTime = true, showDate = true, c
7469

7570
CellDate.propTypes = {
7671
format: PropTypes.oneOf(['short', 'medium', 'long', 'full', 'relative']),
77-
cell: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
72+
cell: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.instanceOf(Date)]),
7873
showTime: PropTypes.bool,
7974
showDate: PropTypes.bool,
8075
}

0 commit comments

Comments
 (0)