-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1fca718
commit 5456ed3
Showing
9 changed files
with
287 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 48 additions & 50 deletions
98
src/Configuration/Customers/CustomerDetailView/EnterpriseCustomerUsersTable.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,62 @@ | ||
import { useParams } from 'react-router-dom'; | ||
import { Container, DataTable, TextFilter } from '@openedx/paragon'; | ||
import { DataTable, TextFilter } from '@openedx/paragon'; | ||
import { EnterpriseCustomerUserDetail, LearnerCell, AdministratorCell } from './EnterpriseCustomerUserDetail'; | ||
import useEnterpriseUsersTableData from '../data/hooks/useCustomerUsersTableData'; | ||
import useCustomerUsersTableData from '../data/hooks/useCustomerUsersTableData'; | ||
|
||
const EnterpriseCustomerUsersTable = () => { | ||
const { id } = useParams(); | ||
const { | ||
isLoading, | ||
enterpriseUsersTableData, | ||
fetchEnterpriseUsersData, | ||
} = useEnterpriseUsersTableData(id); | ||
} = useCustomerUsersTableData(id); | ||
return ( | ||
<Container> | ||
<h2>Associated users ({ enterpriseUsersTableData.itemCount })</h2> | ||
<div> | ||
<h2>Associated users ({enterpriseUsersTableData.itemCount})</h2> | ||
<hr /> | ||
<DataTable | ||
isLoading={isLoading} | ||
isExpandable | ||
isSortable | ||
manualSortBy | ||
isPaginated | ||
manualPagination | ||
isFilterable | ||
manualFilters | ||
initialState={{ | ||
pageSize: 8, | ||
pageIndex: 0, | ||
sortBy: [], | ||
filters: [], | ||
}} | ||
defaultColumnValues={{ Filter: TextFilter }} | ||
fetchData={fetchEnterpriseUsersData} | ||
data={enterpriseUsersTableData.results} | ||
itemCount={enterpriseUsersTableData.itemCount} | ||
pageCount={enterpriseUsersTableData.pageCount} | ||
columns={[ | ||
{ | ||
id: 'userDetails', | ||
Header: 'User details', | ||
accessor: 'userDetails', | ||
Cell: EnterpriseCustomerUserDetail, | ||
}, | ||
{ | ||
id: 'administrator', | ||
Header: 'Administrator', | ||
accessor: 'administrator', | ||
disableFilters: true, | ||
Cell: AdministratorCell, | ||
}, | ||
{ | ||
id: 'learner', | ||
Header: 'Learner', | ||
accessor: 'learner', | ||
disableFilters: true, | ||
Cell: LearnerCell, | ||
}, | ||
]} | ||
/> | ||
</Container> | ||
<DataTable | ||
isLoading={isLoading} | ||
isExpandable | ||
isPaginated | ||
manualPagination | ||
isFilterable | ||
manualFilters | ||
initialState={{ | ||
pageSize: 8, | ||
pageIndex: 0, | ||
sortBy: [], | ||
filters: [], | ||
}} | ||
defaultColumnValues={{ Filter: TextFilter }} | ||
fetchData={fetchEnterpriseUsersData} | ||
data={enterpriseUsersTableData.results} | ||
itemCount={enterpriseUsersTableData.itemCount} | ||
pageCount={enterpriseUsersTableData.pageCount} | ||
columns={[ | ||
{ | ||
id: 'details', | ||
Header: 'User details', | ||
accessor: 'details', | ||
Cell: EnterpriseCustomerUserDetail, | ||
}, | ||
{ | ||
id: 'administrator', | ||
Header: 'Administrator', | ||
accessor: 'administrator', | ||
disableFilters: true, | ||
Cell: AdministratorCell, | ||
}, | ||
{ | ||
id: 'learner', | ||
Header: 'Learner', | ||
accessor: 'learner', | ||
disableFilters: true, | ||
Cell: LearnerCell, | ||
}, | ||
]} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default EnterpriseCustomerUsersTable; | ||
export default EnterpriseCustomerUsersTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/Configuration/Customers/CustomerDetailView/tests/EnterpriseCustomerUserDetail.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* eslint-disable react/prop-types */ | ||
import { | ||
screen, | ||
render, | ||
} from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import { | ||
EnterpriseCustomerUserDetail, | ||
AdministratorCell, | ||
LearnerCell, | ||
} from '../EnterpriseCustomerUserDetail'; | ||
|
||
describe('EnterpriseCustomerUserDetail', () => { | ||
it('renders enterprise customer detail', () => { | ||
const enterpriseCustomerUser = { | ||
original: { | ||
enterpriseCustomerUser: { | ||
username: 'ash ketchum', | ||
email: 'ash@ketchum.org', | ||
}, | ||
}, | ||
}; | ||
render(<EnterpriseCustomerUserDetail row={enterpriseCustomerUser} />); | ||
expect(screen.getByText('ash ketchum')).toBeInTheDocument(); | ||
expect(screen.getByText('ash@ketchum.org')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders pending enterprise customer detail', () => { | ||
const pendingEnterpriseCustomerUser = { | ||
original: { | ||
pendingEnterpriseCustomerUser: { | ||
userEmail: 'pending@customer.org', | ||
}, | ||
}, | ||
}; | ||
render(<EnterpriseCustomerUserDetail row={pendingEnterpriseCustomerUser} />); | ||
expect(screen.getByText('pending@customer.org')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders AdministratorCell there is a pending admin', () => { | ||
const pendingAdmin = { | ||
original: { | ||
pendingEnterpriseCustomerUser: { | ||
isPendingAdmin: true, | ||
}, | ||
roleAssignments: ['enterprise_learner'], | ||
}, | ||
}; | ||
render(<AdministratorCell row={pendingAdmin} />); | ||
expect(screen.getByText('Pending')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders AdministratorCell there is a registered admin', () => { | ||
const adminRow = { | ||
original: { | ||
pendingEnterpriseCustomerUser: { | ||
isPendingAdmin: false, | ||
}, | ||
roleAssignments: ['enterprise_admin'], | ||
}, | ||
}; | ||
render(<AdministratorCell row={adminRow} />); | ||
expect(screen.queryByText('Pending')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('renders LearnerCell when there is a registered learner and not pending', () => { | ||
const learnerRow = { | ||
original: { | ||
pendingEnterpriseCustomerUser: null, | ||
enterpriseCustomerUser: { | ||
username: 'ash ketchum', | ||
email: 'ash@ketchum.org', | ||
}, | ||
roleAssignments: ['enterprise_learner'], | ||
}, | ||
}; | ||
render(<LearnerCell row={learnerRow} />); | ||
expect(screen.queryByText('Pending')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('renders LearnerCell for pending user', () => { | ||
const pendingLearnerRow = { | ||
original: { | ||
pendingEnterpriseCustomerUser: { | ||
isPendingLearner: true, | ||
userEmail: 'pending@customer.org', | ||
}, | ||
enterpriseCustomerUser: null, | ||
}, | ||
}; | ||
render(<LearnerCell row={pendingLearnerRow} />); | ||
expect(screen.queryByText('Pending')).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.