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

GDAP Invites #2749

Merged
merged 2 commits into from
Jul 30, 2024
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
7 changes: 6 additions & 1 deletion src/_nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,12 @@ const _nav = [
{
component: CNavItem,
name: 'Invite Wizard',
to: '/tenant/administration/gdap-invite',
to: '/tenant/administration/gdap-invite-wizard',
},
{
component: CNavItem,
name: 'Invite List',
to: '/tenant/administration/gdap-invites',
},
{
component: CNavItem,
Expand Down
3 changes: 2 additions & 1 deletion src/importsMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ import React from 'react'
"/cipp/setup": React.lazy(() => import('./views/cipp/Setup')),
"/tenant/administration/securescore": React.lazy(() => import('./views/tenant/administration/SecureScore')),
"/tenant/administration/gdap": React.lazy(() => import('./views/tenant/administration/GDAPWizard')),
"/tenant/administration/gdap-invite": React.lazy(() => import('./views/tenant/administration/GDAPInviteWizard')),
"/tenant/administration/gdap-invite-wizard": React.lazy(() => import('./views/tenant/administration/GDAPInviteWizard')),
"/tenant/administration/gdap-invites": React.lazy(() => import('./views/tenant/administration/ListGDAPInvites')),
"/tenant/administration/gdap-role-wizard": React.lazy(() => import('./views/tenant/administration/GDAPRoleWizard')),
"/tenant/administration/gdap-roles": React.lazy(() => import('./views/tenant/administration/ListGDAPRoles')),
"/tenant/administration/gdap-relationships": React.lazy(() => import('././views/tenant/administration/ListGDAPRelationships')),
Expand Down
8 changes: 7 additions & 1 deletion src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -999,11 +999,17 @@
"allowedRoles": ["admin"]
},
{
"path": "/tenant/administration/gdap-invite",
"path": "/tenant/administration/gdap-invite-wizard",
"name": "GDAP Invite Wizard",
"component": "views/tenant/administration/GDAPInviteWizard",
"allowedRoles": ["admin"]
},
{
"path": "/tenant/administration/gdap-invites",
"name": "GDAP Invites",
"component": "views/tenant/administration/ListGDAPInvites",
"allowedRoles": ["admin"]
},
{
"path": "/tenant/administration/gdap-role-wizard",
"name": "GDAP Role Wizard",
Expand Down
28 changes: 26 additions & 2 deletions src/views/tenant/administration/GDAPInviteWizard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const Error = ({ name }) => (
render={({ meta: { touched, error } }) =>
touched && error ? (
<CCallout color="danger">
<FontAwesomeIcon icon={faExclamationTriangle} color="danger" />
<FontAwesomeIcon icon={faExclamationTriangle} color="danger" className="me-2" />
{error}
</CCallout>
) : null
Expand All @@ -40,7 +40,31 @@ Error.propTypes = {
name: PropTypes.string.isRequired,
}

const requiredArray = (value) => (value && value.length !== 0 ? undefined : 'Required')
const requiredArray = (value) => {
if (value && value.length !== 0) {
/// group each item in value by roleDefinitionId and select Role name where count is greater than 1
const duplicateRoles = value
.map((item) => item.roleDefinitionId)
.filter((item, index, self) => index !== self.indexOf(item))
console.log(duplicateRoles)

if (duplicateRoles.length > 0) {
var duplicates = value.filter((item) => duplicateRoles.includes(item.roleDefinitionId))
/// get unique list of duplicate roles
duplicates = duplicates
.filter(
(role, index, self) =>
index === self.findIndex((t) => t.roleDefinitionId === role.roleDefinitionId),
)
.map((role) => role.RoleName)
return `Duplicate GDAP Roles selected, remove one of the mapped groups for the listed roles to continue: ${duplicates}`
} else {
return undefined
}
} else {
return 'You must select at least one GDAP Role'
}
}

const GDAPInviteWizard = () => {
const defaultRolesArray = [
Expand Down
63 changes: 63 additions & 0 deletions src/views/tenant/administration/ListGDAPInvites.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import React from 'react'
import { CippPageList } from 'src/components/layout'
import { TitleButton } from 'src/components/buttons'
import { cellGenericFormatter } from 'src/components/tables/CellGenericFormat'
import { cellDateFormatter } from 'src/components/tables'

const ListGDAPInvites = () => {
const columns = [
{
name: 'Created',
selector: (row) => row['Timestamp'],
sortable: true,
exportSelector: 'Timestamp',
cell: cellDateFormatter({ format: 'short' }),
},
{
name: 'Relationship ID',
selector: (row) => row['RowKey'],
sortable: true,
exportSelector: 'RowKey',
cell: cellGenericFormatter(),
},
{
name: 'Invite URL',
selector: (row) => row['InviteUrl'],
exportSelector: 'InviteUrl',
cell: cellGenericFormatter(),
},
{
name: 'Onboarding URL',
selector: (row) => row['OnboardingUrl'],
exportSelector: 'OnboardingUrl',
cell: cellGenericFormatter(),
},
{
name: 'Role Mapping',
selector: (row) => row['RoleMappings'],
exportSelector: 'RoleMappings',
cell: cellGenericFormatter(),
},
]
return (
<div>
<CippPageList
capabilities={{ allTenants: true, helpContext: 'https://google.com' }}
title="GDAP Invite List"
tenantSelector={false}
datatable={{
keyField: 'id',
columns,
reportName: `GDAP-Invite-List`,
path: '/api/ListGDAPInvite',
tableProps: {
selectableRows: true,
keyField: 'RowKey',
},
}}
/>
</div>
)
}

export default ListGDAPInvites
Loading