-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add enroll-by date to the assignment table (#1248)
* feat: Add enroll-by date to the assignment table * feat: adds internationlization on static text * chore: center column and cells * chore: UI feedback to match parity * chore: Update tests * chore: cleanup * chore: add test * chore: PR feedback * chore: keep datatable component headers arch in parity * chore: Hardcode apostrophe and more doublequote fixes * chore: PR feedback 2
- Loading branch information
1 parent
e9b406f
commit 2a326e7
Showing
26 changed files
with
292 additions
and
75 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
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
62 changes: 62 additions & 0 deletions
62
src/components/learner-credit-management/AssignmentEnrollByDateCell.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,62 @@ | ||
import PropTypes from 'prop-types'; | ||
import { | ||
Icon, IconButtonWithTooltip, Stack, | ||
} from '@openedx/paragon'; | ||
import { Warning } from '@openedx/paragon/icons'; | ||
import { defineMessages, useIntl } from '@edx/frontend-platform/i18n'; | ||
import { ENROLL_BY_DATE_DAYS_THRESHOLD, formatDate } from './data'; | ||
import { isTodayWithinDateThreshold } from '../../utils'; | ||
|
||
const messages = defineMessages({ | ||
tooltipContent: { | ||
id: 'lcm.budget.detail.page.assignments.table.columns.enroll-by-date.data.tooltip-content', | ||
defaultMessage: 'Enrollment deadline approaching', | ||
description: 'On hover tool tip message for an upcoming enrollment date', | ||
}, | ||
}); | ||
|
||
const ExpiringIconButtonWithTooltip = () => { | ||
const intl = useIntl(); | ||
return ( | ||
<IconButtonWithTooltip | ||
variant="warning" | ||
tooltipContent={intl.formatMessage(messages.tooltipContent)} | ||
tooltipPlacement="left" | ||
src={Warning} | ||
iconAs={Icon} | ||
size="inline" | ||
data-testid="upcoming-allocation-expiration-tooltip" | ||
/> | ||
); | ||
}; | ||
|
||
const AssignmentEnrollByDateCell = ({ row }) => { | ||
const { original: { earliestPossibleExpiration: { date } } } = row; | ||
|
||
const formattedEnrollByDate = formatDate(date); | ||
const isAssignmentExpiringSoon = isTodayWithinDateThreshold({ | ||
days: ENROLL_BY_DATE_DAYS_THRESHOLD, | ||
date, | ||
}); | ||
|
||
return ( | ||
<Stack direction="horizontal" gap={1}> | ||
{isAssignmentExpiringSoon && <ExpiringIconButtonWithTooltip />} | ||
<div> | ||
{formattedEnrollByDate} | ||
</div> | ||
</Stack> | ||
); | ||
}; | ||
|
||
AssignmentEnrollByDateCell.propTypes = { | ||
row: PropTypes.shape({ | ||
original: PropTypes.shape({ | ||
earliestPossibleExpiration: PropTypes.shape({ | ||
date: PropTypes.string.isRequired, | ||
}).isRequired, | ||
}).isRequired, | ||
}).isRequired, | ||
}; | ||
|
||
export default AssignmentEnrollByDateCell; |
42 changes: 42 additions & 0 deletions
42
src/components/learner-credit-management/AssignmentEnrollByDateHeader.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,42 @@ | ||
import React from 'react'; | ||
import { | ||
Stack, | ||
Icon, | ||
IconButtonWithTooltip, | ||
} from '@openedx/paragon'; | ||
import { InfoOutline } from '@openedx/paragon/icons'; | ||
import { defineMessages, useIntl } from '@edx/frontend-platform/i18n'; | ||
|
||
const messages = defineMessages({ | ||
header: { | ||
id: 'lcm.budget.detail.page.assignments.table.columns.enroll-by-date.header', | ||
defaultMessage: 'Enroll-by date', | ||
description: 'Column header for the enroll-by date column in the assignments table', | ||
}, | ||
headerTooltipContent: { | ||
id: 'lcm.budget.detail.page.assignments.table.columns.enroll-by-date.header.tooltip-content', | ||
defaultMessage: 'Failure to enroll by midnight of enrollment deadline date will release funds back into the budget', | ||
description: 'On hover tool tip message for the enroll-by date column', | ||
}, | ||
}); | ||
|
||
const AssignmentEnrollByDateHeader = () => { | ||
const intl = useIntl(); | ||
return ( | ||
<Stack gap={1} direction="horizontal"> | ||
<span data-testid="assignments-table-enroll-by-column-header"> | ||
{intl.formatMessage(messages.header)} | ||
</span> | ||
<IconButtonWithTooltip | ||
tooltipContent={intl.formatMessage(messages.headerTooltipContent)} | ||
tooltipPlacement="right" | ||
src={InfoOutline} | ||
iconAs={Icon} | ||
size="inline" | ||
data-testid="enroll-by-date-tooltip" | ||
/> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default AssignmentEnrollByDateHeader; |
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
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
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
Oops, something went wrong.