Skip to content

Commit

Permalink
Tenant Onboarding v2
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDuprey committed May 14, 2024
1 parent 31403fd commit 7f546ca
Show file tree
Hide file tree
Showing 7 changed files with 370 additions and 175 deletions.
2 changes: 1 addition & 1 deletion src/_nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const _nav = [
{
component: CNavItem,
name: 'Tenant Onboarding',
to: '/tenant/administration/tenant-onboarding-wizard',
to: '/tenant/administration/tenant-onboarding',
},
{
component: CNavItem,
Expand Down
4 changes: 3 additions & 1 deletion src/components/tables/CippTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export default function CippTable({
filterlist,
showFilter = true,
endpointName,
defaultSortAsc = true,
tableProps: {
keyField = 'id',
theme = 'cyberdrain',
Expand Down Expand Up @@ -989,7 +990,7 @@ export default function CippTable({
expandableRowsComponent={expandableRowsComponent}
highlightOnHover={highlightOnHover}
expandOnRowClicked={expandOnRowClicked}
defaultSortAsc
defaultSortAsc={defaultSortAsc}
defaultSortFieldId={1}
sortFunction={customSort}
paginationPerPage={tablePageSize}
Expand Down Expand Up @@ -1050,6 +1051,7 @@ export const CippTablePropTypes = {
disableCSVExport: PropTypes.bool,
error: PropTypes.object,
filterlist: PropTypes.arrayOf(PropTypes.object),
defaultSortAsc: PropTypes.bool,
}

CippTable.propTypes = CippTablePropTypes
1 change: 1 addition & 0 deletions src/importsMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ import React from 'react'
"/tenant/administration/gdap-status": React.lazy(() => import('./views/tenant/administration/ListGDAPQueue')),
"/tenant/standards/list-standards": React.lazy(() => import('./views/tenant/standards/ListStandards')),
"/tenant/administration/tenant-offboarding-wizard": React.lazy(() => import('./views/tenant/administration/TenantOffboardingWizard')),
"/tenant/administration/tenant-onboarding": React.lazy(() => import('./views/tenant/administration/TenantOnboarding')),
"/tenant/administration/tenant-onboarding-wizard": React.lazy(() => import('./views/tenant/administration/TenantOnboardingWizard')),
}
export default importsMap
6 changes: 6 additions & 0 deletions src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,12 @@
"component": "views/tenant/administration/TenantOffboardingWizard",
"allowedRoles": ["admin"]
},
{
"path": "/tenant/administration/tenant-onboarding",
"name": "Tenant Onboarding",
"component": "views/tenant/administration/TenantOnboarding",
"allowedRoles": ["admin"]
},
{
"path": "/tenant/administration/tenant-onboarding-wizard",
"name": "Tenant Onboarding",
Expand Down
153 changes: 153 additions & 0 deletions src/views/tenant/administration/TenantOnboarding.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import { CBadge, CTooltip } from '@coreui/react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import React from 'react'
import { TitleButton } from 'src/components/buttons'
import { CippPageList } from 'src/components/layout'
import { CellBadge, cellDateFormatter } from 'src/components/tables'
import { cellGenericFormatter } from 'src/components/tables/CellGenericFormat'

const TenantOnboarding = () => {
const titleButton = (
<TitleButton
href="/tenant/administration/tenant-onboarding-wizard"
title="Start Tenant Onboarding"
/>
)
function ucfirst(str) {
return str.charAt(0).toUpperCase() + str.slice(1)
}
function getBadgeColor(status) {
switch (status.toLowerCase()) {
case 'queued':
return 'info'
case 'failed':
return 'danger'
case 'succeeded':
return 'success'
case 'running':
return 'primary'
}
}
function getLatestStep(steps) {
var activeSteps = steps?.filter((step) => step.Status !== 'pending')
var currentStep = activeSteps[activeSteps.length - 1]
var color = 'info'
var icon = 'me-2 info-circle'
var spin = false
switch (currentStep?.Status) {
case 'succeeded':
color = 'me-2 text-success'
icon = 'check-circle'
break
case 'failed':
color = 'me-2 text-danger'
icon = 'times-circle'
break
case 'running':
color = 'me-2 text-primary'
icon = 'sync'
spin = true
break
}
return (
<CTooltip content={currentStep?.Message ?? ''}>
<div>
<FontAwesomeIcon icon={icon} spin={spin} className={color} />
{currentStep?.Title}
</div>
</CTooltip>
)
}
const columns = [
{
name: 'Last Update',
selector: (row) => row.Timestamp,
sortable: true,
exportSelector: 'Timestamp',
cell: cellDateFormatter({ format: 'short' }),
},
{
name: 'Tenant',
selector: (row) => row?.Relationship?.customer?.displayName,
sortable: true,
cell: cellGenericFormatter(),
exportSelector: 'Relationship/customer/displayName',
},
{
name: 'Status',
selector: (row) => row?.Status,
sortable: true,
exportSelector: 'Status',
cell: (row) => CellBadge({ label: ucfirst(row?.Status), color: getBadgeColor(row?.Status) }),
},
{
name: 'Onboarding Step',
selector: (row) => row?.OnboardingSteps,
cell: (row) => getLatestStep(row?.OnboardingSteps),
},
{
name: 'Logs',
selector: (row) => row?.Logs,
sortable: false,
cell: cellGenericFormatter(),
},
]
return (
<div>
<CippPageList
capabilities={{ allTenants: true, helpContext: 'https://google.com' }}
title="Tenant Onboarding"
tenantSelector={false}
titleButton={titleButton}
datatable={{
filterlist: [
{
filterName: 'Running',
filter: 'Complex: Status eq Running',
},
{
filterName: 'Pending',
filter: 'Complex: Status eq Pending',
},
{
filterName: 'Failed',
filter: 'Complex: Status eq Failed',
},
],
tableProps: {
selectableRows: true,
actionsList: [
{
label: 'Cancel Onboarding',
modal: true,
modalType: 'POST',
modalBody: {
id: '!RowKey',
},
modalUrl: `/api/ExecOnboardTenant?Cancel=true`,
modalMessage: 'Are you sure you want to cancel these onboardings?',
},
{
label: 'Retry Onboarding',
modal: true,
modalType: 'POST',
modalBody: {
id: '!RowKey',
},
modalUrl: `/api/ExecOnboardTenant?Retry=true`,
modalMessage: 'Are you sure you want to retry these onboardings?',
},
],
},
keyField: 'id',
columns,
reportName: `Tenant-Onboarding`,
path: '/api/ListTenantOnboarding',
defaultSortAsc: false,
}}
/>
</div>
)
}

export default TenantOnboarding
Loading

0 comments on commit 7f546ca

Please sign in to comment.