Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission Checks #1815

Merged
merged 3 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/components/buttons/TableModalButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react'
import { CButton } from '@coreui/react'
import { ModalService } from '../utilities'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCheckCircle } from '@fortawesome/free-solid-svg-icons'
import { cellGenericFormatter } from '../tables/CellGenericFormat'

export default function TableModalButton({ data, title, className }) {
const handleTable = (data) => {
const QueryColumns = []
const columns = Object.keys(data[0]).map((key) => {
QueryColumns.push({
name: key,
selector: (row) => row[key], // Accessing the property using the key
sortable: true,
exportSelector: key,
cell: cellGenericFormatter(),
})
})
ModalService.open({
data: data,
componentType: 'table',
componentProps: {
columns: QueryColumns,
keyField: 'id',
},
title: title,
size: 'lg',
})
}
const buttonClass = 'btn ' + className

return (
<CButton className={buttonClass} onClick={() => handleTable(data)}>
<>
{title} ({data.length})
</>
</CButton>
)
}
3 changes: 2 additions & 1 deletion src/components/buttons/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ExportCsvButton from 'src/components/buttons/CsvButton'
import ExportPDFButton from 'src/components/buttons/PdfButton'
import TitleButton from 'src/components/buttons/TitleButton'
import TableModalButton from 'src/components/buttons/TableModalButton'

export { ExportCsvButton, ExportPDFButton, TitleButton }
export { ExportCsvButton, ExportPDFButton, TitleButton, TableModalButton }
38 changes: 37 additions & 1 deletion src/views/cipp/CIPPSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import Skeleton from 'react-loading-skeleton'
import { Buffer } from 'buffer'
import Extensions from 'src/data/Extensions.json'
import { CellDelegatedPrivilege } from 'src/components/tables/CellDelegatedPrivilege'
import { TableModalButton } from 'src/components/buttons'

const CIPPSettings = () => {
const [active, setActive] = useState(1)
Expand Down Expand Up @@ -387,10 +388,28 @@ const GeneralSettings = () => {
</CListGroup>
</>
)}
{permissionsResult.data.Results?.MissingGroups.length > 0 && (
<>
Your SAM User is missing the following group memberships.
<CListGroup flush>
{permissionsResult.data.Results?.MissingGroups?.map((r, index) => (
<CListGroupItem key={index}>{r}</CListGroupItem>
))}
</CListGroup>
</>
)}
{permissionsResult.data.Results?.CIPPGroupCount == 0 && (
<>
NOTE: M365 GDAP groups were not set up by CIPP, review the SAM user groups
below.
</>
)}
</CCallout>
{permissionsResult.data.Results?.AccessTokenDetails?.Name !== '' && (
<>
<CButton onClick={() => setTokenOffcanvasVisible(true)}>Details</CButton>
<CButton className="me-3" onClick={() => setTokenOffcanvasVisible(true)}>
Details
</CButton>
<CippListOffcanvas
title="Details"
placement="end"
Expand All @@ -402,6 +421,23 @@ const GeneralSettings = () => {
/>
</>
)}
{permissionsResult.data.Results?.Memberships !== '' && (
<>
<TableModalButton
className="me-3"
data={permissionsResult.data.Results?.Memberships.filter(
(p) => p['@odata.type'] == '#microsoft.graph.group',
)}
title="Groups"
/>
<TableModalButton
data={permissionsResult.data.Results?.Memberships.filter(
(p) => p['@odata.type'] == '#microsoft.graph.directoryRole',
)}
title="Roles"
/>
</>
)}
</>
)}
</CCardBody>
Expand Down
Loading