Skip to content

Commit

Permalink
Merge pull request KelvinTegelaar#1571 from johnduprey/dev
Browse files Browse the repository at this point in the history
User license fix
  • Loading branch information
KelvinTegelaar authored Jun 14, 2023
2 parents df4b52a + 08ed857 commit ee7427f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
3 changes: 3 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import routes from 'src/routes'
import { Helmet } from 'react-helmet'
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)

// Containers
const DefaultLayout = React.lazy(() => import('./layout/DefaultLayout'))
Expand Down
3 changes: 0 additions & 3 deletions src/components/tables/CellDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import React from 'react'
import moment from 'moment'
import PropTypes from 'prop-types'
import { CTooltip } from '@coreui/react'
import TimeAgo from 'javascript-time-ago'
import en from 'javascript-time-ago/locale/en.json'
TimeAgo.addDefaultLocale(en)
import ReactTimeAgo from 'react-time-ago'

/**
Expand Down
23 changes: 16 additions & 7 deletions src/components/tables/CippTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,10 @@ export default function CippTable({

if (!disablePDFExport || !disableCSVExport) {
const keys = []
const exportFormatter = {}
columns.map((col) => {
if (col.exportSelector) keys.push(col.exportSelector)
if (col.exportFormatter) exportFormatter[col.exportSelector] = col.exportFormatter
return null
})

Expand All @@ -340,15 +342,22 @@ export default function CippTable({
keys.reduce((acc, curr) => {
const key = curr.split('/')
if (key.length > 1) {
const parent = key[0]
const subkey = key[1]
if (obj[parent] !== null && obj[parent][subkey] !== null) {
acc[curr] = obj[parent][subkey]
} else {
acc[curr] = 'n/a'
var property = obj
for (var x = 0; x < key.length; x++) {
if (property[key[x]] !== null) {
property = property[key[x]]
} else {
property = 'n/a'
break
}
}
acc[curr] = property
} else {
acc[curr] = obj[curr]
if (typeof exportFormatter[curr] === 'function') {
acc[curr] = exportFormatter[curr]({ cell: obj[curr] })
} else {
acc[curr] = obj[curr]
}
}
return acc
}, {}),
Expand Down
4 changes: 0 additions & 4 deletions src/components/utilities/CippActionsOffcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ import { CippOffcanvasTable } from 'src/components/tables'
import { useLazyGenericGetRequestQuery, useLazyGenericPostRequestQuery } from 'src/store/api/app'
import { Link, useNavigate } from 'react-router-dom'
import { stringCamelCase } from 'src/components/utilities/CippCamelCase'
import TimeAgo from 'javascript-time-ago'

import en from 'javascript-time-ago/locale/en.json'
TimeAgo.addDefaultLocale(en)
import ReactTimeAgo from 'react-time-ago'

export default function CippActionsOffcanvas(props) {
Expand Down
4 changes: 0 additions & 4 deletions src/views/home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ import Skeleton from 'react-loading-skeleton'
import { UniversalSearch } from 'src/components/utilities/UniversalSearch'
import { ActionContentCard } from 'src/components/contentcards'
import { useSelector } from 'react-redux'
import TimeAgo from 'javascript-time-ago'
import allStandardsList from 'src/data/standards'

import en from 'javascript-time-ago/locale/en.json'
TimeAgo.addDefaultLocale(en)
import ReactTimeAgo from 'react-time-ago'

const Home = () => {
Expand Down
3 changes: 2 additions & 1 deletion src/views/identity/administration/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { cellBooleanFormatter, CellTip } from 'src/components/tables'
import { CippPageList } from 'src/components/layout'
import { TitleButton } from 'src/components/buttons'
import { CippActionsOffcanvas } from 'src/components/utilities'
import { cellLicenseFormatter } from 'src/components/tables/CellLicense'
import { cellLicenseFormatter, CellLicense } from 'src/components/tables/CellLicense'
import M365Licenses from 'src/data/M365Licenses'

const Offcanvas = (row, rowIndex, formatExtraData) => {
Expand Down Expand Up @@ -276,6 +276,7 @@ const Users = (row) => {
name: 'Licenses',
selector: (row) => row['assignedLicenses'],
exportSelector: 'assignedLicenses',
exportFormatter: CellLicense,
cell: cellLicenseFormatter(),
sortable: true,
grow: 5,
Expand Down

0 comments on commit ee7427f

Please sign in to comment.