Skip to content

Commit

Permalink
Merge pull request #656 from KelvinTegelaar/dev
Browse files Browse the repository at this point in the history
Upgrading Dev to Release
  • Loading branch information
KelvinTegelaar authored Jan 21, 2022
2 parents 905323e + 0eb8a02 commit f31e643
Show file tree
Hide file tree
Showing 16 changed files with 156 additions and 77 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"test": "react-scripts test",
"test:cov": "npm test -- --coverage --watchAll=false",
"test:debug": "react-scripts --inspect-brk test --runInBand",
"start-api": "swa start --ssl --ssl-cert ./.vscode/cert.crt --ssl-key ./.vscode/key.key --swa-config-location . http://localhost:3000 --api-location http://localhost:7071 --swa-config-location .vscode",
"start-api": "swa start --ssl --ssl-cert ./.vscode/cert.crt --ssl-key ./.vscode/key.key --swa-config-location .vscode http://localhost:3000 --api-location http://localhost:7071",
"prepare": "husky install"
},
"config": {
Expand Down
30 changes: 30 additions & 0 deletions src/components/tables/CippTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,34 @@ FilterComponent.propTypes = {
onClear: PropTypes.func,
}

const customSort = (rows, selector, direction) => {
return rows.sort((a, b) => {
// use the selector to resolve your field names by passing the sort comparitors
let aField
let bField
if (typeof selector(a) === 'string') {
aField = selector(a).toLowerCase()
} else {
aField = selector(a)
}
if (typeof selector(b) === 'string') {
bField = selector(b).toLowerCase()
} else {
bField = selector(b)
}

let comparison = 0

if (aField > bField) {
comparison = 1
} else if (aField < bField) {
comparison = -1
}

return direction === 'desc' ? comparison * -1 : comparison
})
}

export default function CippTable({
data,
isFetching = false,
Expand All @@ -49,6 +77,7 @@ export default function CippTable({
expandableRowsHideExpander,
expandOnRowClicked,
selectableRows,
sortFunction = customSort,
onSelectedRowsChange,
highlightOnHover = true,
disableDefaultActions = false,
Expand Down Expand Up @@ -179,6 +208,7 @@ export default function CippTable({
expandOnRowClicked={expandOnRowClicked}
defaultSortAsc
defaultSortFieldId={1}
sortFunction={customSort}
paginationPerPage={25}
progressPending={isFetching}
progressComponent={<CSpinner color="info" component="div" />}
Expand Down
27 changes: 5 additions & 22 deletions src/scss/_themes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,10 @@
--cui-dark-rgb: var(--cyberdrain-dark-rgb);
--cui-white-rgb: rgb(255 255 255);
--cui-black-rgb: rgb(0 0 0);
--cui-font-sans-serif:
system-ui,
-apple-system,
'Segoe UI',
roboto,
'Helvetica Neue',
arial,
'Noto Sans',
'Liberation Sans',
sans-serif,
'Apple Color Emoji',
'Segoe UI Emoji',
'Segoe UI Symbol',
'Noto Color Emoji';
--cui-font-monospace:
sfmono-regular,
menlo,
monaco,
consolas,
'Liberation Mono',
'Courier New',
--cui-font-sans-serif: system-ui, -apple-system, 'Segoe UI', roboto, 'Helvetica Neue', arial,
'Noto Sans', 'Liberation Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
'Segoe UI Symbol', 'Noto Color Emoji';
--cui-font-monospace: sfmono-regular, menlo, monaco, consolas, 'Liberation Mono', 'Courier New',
monospace;
--cui-gradient: linear-gradient(180deg, rgb(255 255 255 / 15%), rgb(255 255 255 / 0%));
--cui-body-font-family: var(--cui-font-sans-serif);
Expand All @@ -97,7 +80,7 @@
--cui-card-cap-color: var(--cyberdrain-light);
--cui-card-cap-bg: var(--cyberdrain-accent-blue);
--cui-border-radius: 0;
--cui-badge-color: var(--cyberdrain-dark);
--cui-badge-color: var(--cyberdrain-light);

// CIPP theme-independent variables.
--cipp-border-radius: 0;
Expand Down
20 changes: 0 additions & 20 deletions src/store/api/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ export const appApi = baseApi.injectEndpoints({
Permissions: true,
},
}),
transformResponse: (result) => {
if (!result) {
return []
}
if (!Array.isArray(result.Results)) {
return [result.Results]
}
return result.Results
},
}),
execNotificationConfig: builder.query({
query: ({
Expand Down Expand Up @@ -75,17 +66,6 @@ export const appApi = baseApi.injectEndpoints({
},
method: 'post',
}),
transformResponse: (response) => {
if (!response?.Results) {
return []
}
return response?.Results.map((res) =>
res
.replace('<br>', '')
.split(': ')
.reduce((pv, cv) => ({ tenantDomain: pv, result: cv })),
)
},
}),
execClearCache: builder.query({
query: () => ({
Expand Down
30 changes: 21 additions & 9 deletions src/views/cipp/CIPPSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ export default CIPPSettings
const checkAccessColumns = [
{
name: 'Tenant Domain',
selector: (row) => row['tenantDomain'],
selector: (row) => row['TenantName'],
},
{
name: 'Result',
selector: (row) => row['result'],
selector: (row) => row['Status'],
},
]

Expand Down Expand Up @@ -143,7 +143,10 @@ const GeneralSettings = () => {

const handleClearCache = useConfirmModal({
body: <div>Are you sure you want to clear the cache?</div>,
onConfirm: () => clearCache(),
onConfirm: () => {
clearCache()
localStorage.clear()
},
})

const tableProps = {
Expand Down Expand Up @@ -171,9 +174,17 @@ const GeneralSettings = () => {
)}
Run Permissions Check
</CButton>
{permissionsResult.status === 'fulfilled' && (
// @todo make this pretty after API is fixed
<div>{permissionsResult.data.map((result) => result)}</div>
{permissionsResult.isSuccess && (
<div>
{permissionsResult.data.Results.MissingPermissions
? 'Your Secure Application Model is missing the following delegated permissions:'
: 'Your Secure Application Model has all required permissions'}
<CListGroup flush>
{permissionsResult.data.Results.MissingPermissions.map((r, index) => (
<CListGroupItem key={index}>{r}</CListGroupItem>
))}
</CListGroup>
</div>
)}
</CCardBody>
</CCard>
Expand All @@ -184,8 +195,9 @@ const GeneralSettings = () => {
<CCardTitle>Clear Cache</CCardTitle>
</CCardHeader>
<CCardBody>
Click the button below to clear the tenant cache file, the Best Practice Analyser
cache and the Domain Analyser Cache. <br />
Click the button below to clear the all caches the application uses. This includes the
Best Practice Analyser, Tenant Cache, Domain Analyser, and personal settings such as
theme and usage location <br />
<CButton
onClick={() => handleClearCache()}
disabled={clearCacheResult.isFetching}
Expand Down Expand Up @@ -236,7 +248,7 @@ const GeneralSettings = () => {
<CippTable
columns={checkAccessColumns}
tableProps={tableProps}
data={accessCheckResult.data}
data={accessCheckResult.data.Results}
/>
)}
</CCardBody>
Expand Down
2 changes: 1 addition & 1 deletion src/views/endpoint/defender/ListDefender.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const DefenderState = () => {
reportName: `${tenant?.defaultDomainName}-DefenderStatus-List`,
path: '/api/ListDefenderState',
columns,
params: { TenantFilter: tenant?.defaultDomainName },
params: { TenantFilter: tenant?.customerId },
}}
/>
)
Expand Down
4 changes: 3 additions & 1 deletion src/views/identity/administration/AddUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ const AddUser = () => {
<CippPage tenantSelector={true} title="Add User">
{postResults.isSuccess && (
<CAlert color="success" dismissible>
{postResults.data?.Results}
{postResults.data?.Results.map((result, index) => (
<li key={index}>{result}</li>
))}
</CAlert>
)}
<CRow>
Expand Down
2 changes: 2 additions & 0 deletions src/views/identity/administration/User365Management.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ export default function User365Management({ tenantDomain, userId, className }) {
label: 'View in Azure AD',
link: azureADLink,
icon: faUsers,
target: '_blank',
},
{
label: 'View in Endpoint Manager',
link: endpointManagerLink,
icon: faLaptop,
target: '_blank',
},
]
return (
Expand Down
13 changes: 13 additions & 0 deletions src/views/identity/administration/UserSigninLogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,55 +63,68 @@ export default function UserSigninLogs({ userId, tenantDomain, className = null
{
name: 'Date',
selector: (row) => row['Date'],
exportSelector: 'Date',
},
{
name: 'Application',
selector: (row) => row['Application'],
exportSelector: 'Application',
},
{
name: 'Login Status',
selector: (row) => row['LoginStatus'],
exportSelector: 'LoginStatus',
},
{
name: 'Conditional Access Status',
selector: (row) => row['ConditionalAccessStatus'],
exportSelector: 'ConditionalAccessStatus',
},
{
name: 'Overall Login Status',
selector: (row) => row['OverallLoginStatus'],
exportSelector: 'OverallLoginStatus',
},
{
name: 'IP Address',
selector: (row) => row['IPAddress'],
exportSelector: 'IPAddress',
},
{
name: 'Town',
selector: (row) => row['Town'],
exportSelector: 'Town',
},
{
name: 'State',
selector: (row) => row['State'],
exportSelector: 'State',
},
{
name: 'Country',
selector: (row) => row['Country'],
exportSelector: 'Country',
},
{
name: 'Device',
selector: (row) => row['Device'],
exportSelector: 'Device',
},
{
name: 'Device Compliant',
selector: (row) => row['DeviceCompliant'],
cell: cellBooleanFormatter,
exportSelector: 'DeviceCompliant',
},
{
name: 'OS',
selector: (row) => row['OS'],
exportSelector: 'OS',
},
{
name: 'Browser',
selector: (row) => row['Browser'],
exportSelector: 'Browser',
},
{
name: 'Applied CAPs',
Expand Down
3 changes: 3 additions & 0 deletions src/views/identity/administration/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const Offcanvas = (row, rowIndex, formatExtraData) => {
{ label: 'Given Name', value: `${row.givenName}` },
{ label: 'Surname', value: `${row.surname}` },
{ label: 'Job Title', value: `${row.jobTitle}` },
{ label: 'Licenses', value: `${row.LicJoined}` },
{ label: 'Business Phone', value: `${row.businessPhones}` },
{ label: 'Mobile Phone', value: `${row.mobilePhone}` },
{ label: 'Mail', value: `${row.mail}` },
Expand Down Expand Up @@ -122,12 +123,14 @@ const columns = [
selector: (row) => row['displayName'],
sortable: true,
exportSelector: 'displayName',
minWidth: '300px',
},
{
name: 'Email',
selector: (row) => row['mail'],
sortable: true,
exportSelector: 'mail',
minWidth: '350px',
},
{
name: 'User Type',
Expand Down
25 changes: 23 additions & 2 deletions src/views/identity/administration/ViewBEC.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import { useLazyExecBecCheckQuery } from 'src/store/api/users'
import useQuery from 'src/hooks/useQuery'
import { Link } from 'react-router-dom'
import { CippTable } from 'src/components/tables'
import { useLazyGenericPostRequestQuery } from 'src/store/api/app'

const ViewBec = () => {
let query = useQuery()
const userId = query.get('userId')
const tenantDomain = query.get('tenantDomain')

const [execBecRemediate, execRemediateResults] = useLazyGenericPostRequestQuery()
const [execBecView, results] = useLazyExecBecCheckQuery()
const { data: alerts = {}, isFetching, error, isSuccess } = results
useEffect(() => {
Expand Down Expand Up @@ -207,7 +208,27 @@ const ViewBec = () => {
<li>Disconnect all current sessions</li>
<li>Disable all inbox rules for the user</li>
</p>
<CButton>Remediate User</CButton>
<CButton
onClick={() =>
execBecRemediate({
path: '/api/execBecRemediate',
values: { userId: userId, tenantFilter: tenantDomain },
})
}
>
Remediate User
</CButton>
{!execRemediateResults.isSuccess && execRemediateResults.isError && (
<CCallout color="danger">Error. Could not remediate user</CCallout>
)}
{execRemediateResults.isFetching && (
<CCallout color="info">
<CSpinner />
</CCallout>
)}
{execRemediateResults.isSuccess && (
<CCallout color="info">{execRemediateResults.data?.Results}</CCallout>
)}
</CCardBody>
</CCard>
</CCol>
Expand Down
2 changes: 0 additions & 2 deletions src/views/identity/reports/MFAReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const columns = [
selector: (row) => row['PerUser'],
name: 'Per user MFA Status',
sortable: true,
cell: cellBooleanFormatter(),
exportSelector: 'PerUser',
},
{
Expand All @@ -35,7 +34,6 @@ const columns = [
selector: (row) => row['CoveredByCA'],
name: 'Enforced via Conditional Access',
sortable: true,
cell: cellBooleanFormatter(),
exportSelector: 'CoveredByCA',
},
{
Expand Down
Loading

0 comments on commit f31e643

Please sign in to comment.