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

ENT-7512: LearnerCreditAllocationTable course title #1025

Merged
merged 10 commits into from
Sep 1, 2023
3 changes: 3 additions & 0 deletions src/components/learner-credit-management/BudgetCard-V2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const BudgetCard = ({
offer,
enterpriseUUID,
enterpriseSlug,
enableLearnerPortal,
}) => {
const {
start,
Expand Down Expand Up @@ -144,6 +145,7 @@ const BudgetCard = ({
fetchTableData={fetchOfferRedemptions}
enterpriseUUID={enterpriseUUID}
enterpriseSlug={enterpriseSlug}
enableLearnerPortal={enableLearnerPortal}
/>
)}
</Stack>
Expand All @@ -159,6 +161,7 @@ BudgetCard.propTypes = {
}).isRequired,
enterpriseUUID: PropTypes.string.isRequired,
enterpriseSlug: PropTypes.string.isRequired,
enableLearnerPortal: PropTypes.bool.isRequired,
};

export default BudgetCard;
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ const getEnrollmentDetailsAccessor = row => ({
courseKey: row.courseKey,
});

const FilterStatus = (rest) => <DataTable.FilterStatus showFilteredFields={false} {...rest} />;

const LearnerCreditAllocationTable = ({
isLoading,
tableData,
fetchTableData,
enterpriseUUID,
enterpriseSlug,
enableLearnerPortal,
}) => {
const defaultFilter = [];

Expand All @@ -35,6 +38,7 @@ const LearnerCreditAllocationTable = ({
manualFilters
isLoading={isLoading}
defaultColumnValues={{ Filter: TableTextFilter }}
FilterStatusComponent={FilterStatus}
/* eslint-disable */
columns={[
{
Expand All @@ -50,12 +54,16 @@ const LearnerCreditAllocationTable = ({
<>
<EmailAddressTableCell row={row} enterpriseUUID={enterpriseUUID} />
<div>
{enableLearnerPortal ? (
<Hyperlink
destination={`${getConfig().ENTERPRISE_LEARNER_PORTAL_URL}/${enterpriseSlug}/course/${row.original.courseKey}`}
target="_blank"
>
{row.original.courseTitle}
</Hyperlink>
) : (
row.original.courseTitle
)}
</div>
</>
),
Expand Down Expand Up @@ -106,6 +114,7 @@ const LearnerCreditAllocationTable = ({
LearnerCreditAllocationTable.propTypes = {
enterpriseUUID: PropTypes.string.isRequired,
enterpriseSlug: PropTypes.string.isRequired,
enableLearnerPortal: PropTypes.bool.isRequired,
isLoading: PropTypes.bool.isRequired,
tableData: PropTypes.shape({
results: PropTypes.arrayOf(PropTypes.shape({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const PAGE_TITLE = 'Learner Credit';
const MultipleBudgetsPage = ({
enterpriseUUID,
enterpriseSlug,
enableLearnerPortal,
}) => {
const { offers, isLoading } = useContext(EnterpriseSubsidiesContext);

Expand Down Expand Up @@ -66,6 +67,7 @@ const MultipleBudgetsPage = ({
offers={offers}
enterpriseUUID={enterpriseUUID}
enterpriseSlug={enterpriseSlug}
enableLearnerPortal={enableLearnerPortal}
/>
</>
);
Expand All @@ -74,11 +76,13 @@ const MultipleBudgetsPage = ({
const mapStateToProps = state => ({
enterpriseUUID: state.portalConfiguration.enterpriseId,
enterpriseSlug: state.portalConfiguration.enterpriseSlug,
enableLearnerPortal: state.portalConfiguration.enableLearnerPortal,
});

MultipleBudgetsPage.propTypes = {
enterpriseUUID: PropTypes.string.isRequired,
enterpriseSlug: PropTypes.string.isRequired,
enableLearnerPortal: PropTypes.bool.isRequired,
};

export default connect(mapStateToProps)(MultipleBudgetsPage);
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const MultipleBudgetsPicker = ({
offers,
enterpriseUUID,
enterpriseSlug,
enableLearnerPortal,
}) => (
<Stack>
<Row>
Expand All @@ -22,6 +23,7 @@ const MultipleBudgetsPicker = ({
offer={offer}
enterpriseUUID={enterpriseUUID}
enterpriseSlug={enterpriseSlug}
enableLearnerPortal={enableLearnerPortal}
/>
))}
</Col>
Expand All @@ -33,6 +35,7 @@ MultipleBudgetsPicker.propTypes = {
offers: PropTypes.arrayOf(PropTypes.shape()).isRequired,
enterpriseUUID: PropTypes.string.isRequired,
enterpriseSlug: PropTypes.string.isRequired,
enableLearnerPortal: PropTypes.bool.isRequired,
};

export default MultipleBudgetsPicker;
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('<LearnerCreditAllocationTable />', () => {
isLoading: false,
budgetType: 'OCM',
enterpriseSlug: 'test-enterprise-slug',
enableLearnerPortal: true,
tableData: {
results: [{
userEmail: '[email protected]',
Expand Down Expand Up @@ -77,6 +78,7 @@ describe('<LearnerCreditAllocationTable />', () => {
isLoading: false,
budgetType: 'OCM',
enterpriseSlug: 'test-enterprise-slug',
enableLearnerPortal: true,
tableData: {
results: [{
userEmail: '[email protected]',
Expand All @@ -100,4 +102,32 @@ describe('<LearnerCreditAllocationTable />', () => {

expect(courseLinkElement.getAttribute('href')).toBe(expectedLink);
});

it('does not render the course link if the learner portal is disabled', () => {
const props = {
enterpriseUUID: 'test-enterprise-id',
isLoading: false,
budgetType: 'OCM',
enterpriseSlug: 'test-enterprise-slug',
enableLearnerPortal: false,
tableData: {
results: [{
userEmail: '[email protected]',
courseTitle: 'course-title',
courseKey: 'course-v1:edX=CTL.SC101x.3T2019',
courseListPrice: 100,
enrollmentDate: '2-2-23',
courseProductLine: 'OCM',
}],
itemCount: 1,
pageCount: 1,
},
fetchTableData: jest.fn(),
};
props.fetchTableData.mockReturnValue(props.tableData);

render(<LearnerCreditAllocationTableWrapper {...props} />);
const courseTitleElement = screen.queryByText('course-title');
expect(courseTitleElement.closest('a')).toBeNull();
});
});