Skip to content

Commit d812b3f

Browse files
Merge pull request #1519 from johnduprey/dev
GDAP Relationships
2 parents b23ad2f + 1cbfe22 commit d812b3f

File tree

4 files changed

+125
-23
lines changed

4 files changed

+125
-23
lines changed

src/_nav.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,11 @@ const _nav = [
689689
name: 'GDAP Migration Status',
690690
to: '/tenant/administration/gdap-status',
691691
},
692+
{
693+
component: CNavItem,
694+
name: 'GDAP Relationships',
695+
to: '/tenant/administration/gdap-relationships',
696+
},
692697
{
693698
component: CNavItem,
694699
name: 'Documentation',

src/adminRoutes.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const GDAPStatus = React.lazy(() => import('src/views/tenant/administration/List
66
const GDAP = React.lazy(() => import('src/views/tenant/administration/GDAPWizard'))
77
const GDAPRoleWizard = React.lazy(() => import('src/views/tenant/administration/GDAPRoleWizard'))
88
const GDAPRoles = React.lazy(() => import('src/views/tenant/administration/ListGDAPRoles'))
9+
const GDAPRelationships = React.lazy(() =>
10+
import('./views/tenant/administration/ListGDAPRelationships'),
11+
)
912
const appapproval = React.lazy(() => import('src/views/cipp/AppApproval'))
1013

1114
const adminRoutes = [
@@ -24,6 +27,11 @@ const adminRoutes = [
2427
name: 'GDAP Roles',
2528
component: GDAPRoles,
2629
},
30+
{
31+
path: '/tenant/administration/gdap-relationships',
32+
name: 'GDAP Relationships',
33+
component: GDAPRelationships,
34+
},
2735
{ path: '/tenant/administration/appapproval', name: 'App Approval', component: appapproval },
2836
{ path: '/tenant/administration/gdap-status', name: 'GDAP Status', component: GDAPStatus },
2937
{ path: '/tenant/standards/apply-standard', name: 'Apply Standard', component: ApplyStandard },

src/components/tables/CellDate.js

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ import React from 'react'
22
import moment from 'moment'
33
import PropTypes from 'prop-types'
44
import { CTooltip } from '@coreui/react'
5+
import TimeAgo from 'javascript-time-ago'
6+
import en from 'javascript-time-ago/locale/en.json'
7+
TimeAgo.addDefaultLocale(en)
8+
import ReactTimeAgo from 'react-time-ago'
59

610
/**
711
*
8-
* @param format ['short', 'long']
12+
* @param format ['short', 'long', 'relative']
913
* @param value
1014
* @returns {JSX.Element}
1115
* @constructor
@@ -27,35 +31,52 @@ export const CellDate = ({ format = 'short', showTime = true, showDate = true, c
2731
]
2832

2933
const dateTimeFormatOptions = {}
34+
if (format == 'relative') {
35+
try {
36+
return (
37+
<CTooltip content={cell}>
38+
<ReactTimeAgo date={cell} />
39+
</CTooltip>
40+
)
41+
} catch (error) {
42+
console.error('Error formatting date, fallback to string value', { date: cell, error })
43+
return (
44+
<CTooltip content={cell}>
45+
<div>{String(cell)}</div>
46+
</CTooltip>
47+
)
48+
}
49+
} else {
50+
if (showTime) {
51+
dateTimeFormatOptions.timeStyle = format
52+
}
53+
if (showDate) {
54+
dateTimeFormatOptions.dateStyle = format
55+
}
3056

31-
if (showTime) {
32-
dateTimeFormatOptions.timeStyle = format
33-
}
34-
if (showDate) {
35-
dateTimeFormatOptions.dateStyle = format
36-
}
57+
dateTimeArgs.push(dateTimeFormatOptions)
3758

38-
dateTimeArgs.push(dateTimeFormatOptions)
59+
let formatted
3960

40-
let formatted
41-
try {
42-
// lots of dates returned are unreliably parsable (e.g. non ISO8601 format)
43-
// fallback using moment to parse into date object
44-
formatted = new Intl.DateTimeFormat(...dateTimeArgs).format(moment(cell).toDate())
45-
} catch (error) {
46-
console.error('Error formatting date, fallback to string value', { date: cell, error })
47-
formatted = cell
48-
}
61+
try {
62+
// lots of dates returned are unreliably parsable (e.g. non ISO8601 format)
63+
// fallback using moment to parse into date object
64+
formatted = new Intl.DateTimeFormat(...dateTimeArgs).format(moment(cell).toDate())
65+
} catch (error) {
66+
console.error('Error formatting date, fallback to string value', { date: cell, error })
67+
formatted = cell
68+
}
4969

50-
return (
51-
<CTooltip content={cell}>
52-
<div>{String(formatted)}</div>
53-
</CTooltip>
54-
)
70+
return (
71+
<CTooltip content={cell}>
72+
<div>{String(formatted)}</div>
73+
</CTooltip>
74+
)
75+
}
5576
}
5677

5778
CellDate.propTypes = {
58-
format: PropTypes.oneOf(['short', 'medium', 'long', 'full']),
79+
format: PropTypes.oneOf(['short', 'medium', 'long', 'full', 'relative']),
5980
cell: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
6081
showTime: PropTypes.bool,
6182
showDate: PropTypes.bool,
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import React from 'react'
2+
import { useSelector } from 'react-redux'
3+
import { CSpinner, CCallout } from '@coreui/react'
4+
import { CippPageList } from 'src/components/layout'
5+
import { cellDateFormatter, cellNullTextFormatter } from 'src/components/tables'
6+
7+
const GDAPRelationships = () => {
8+
const columns = [
9+
{
10+
name: 'Tenant',
11+
selector: (row) => row.customer?.displayName,
12+
sortable: true,
13+
exportSelector: 'customer',
14+
cell: cellNullTextFormatter(),
15+
},
16+
{
17+
name: 'Relationship Name',
18+
selector: (row) => row['displayName'],
19+
sortable: true,
20+
exportSelector: 'displayName',
21+
},
22+
{
23+
name: 'Status',
24+
selector: (row) => row['status'],
25+
sortable: true,
26+
exportSelector: 'status',
27+
},
28+
{
29+
name: 'Created',
30+
selector: (row) => row['createdDateTime'],
31+
sortable: true,
32+
exportSelector: 'createdDateTime',
33+
cell: cellDateFormatter({ format: 'short' }),
34+
},
35+
{
36+
name: 'Activated',
37+
selector: (row) => row['activatedDateTime'],
38+
sortable: true,
39+
exportSelector: 'activatedDateTime',
40+
cell: cellDateFormatter({ format: 'short' }),
41+
},
42+
{
43+
name: 'End',
44+
selector: (row) => row['endDateTime'],
45+
sortable: true,
46+
exportSelector: 'endDateTime',
47+
cell: cellDateFormatter({ format: 'short' }),
48+
},
49+
]
50+
return (
51+
<div>
52+
<CippPageList
53+
capabilities={{ allTenants: true, helpContext: 'https://google.com' }}
54+
title="GDAP Relationship List"
55+
tenantSelector={false}
56+
datatable={{
57+
keyField: 'id',
58+
columns,
59+
reportName: `GDAP-Relationships`,
60+
path: '/api/ListGraphRequest',
61+
params: { Endpoint: 'tenantRelationships/delegatedAdminRelationships' },
62+
}}
63+
/>
64+
</div>
65+
)
66+
}
67+
68+
export default GDAPRelationships

0 commit comments

Comments
 (0)