|
6 | 6 | * `notification_tray_slot` |
7 | 7 |
|
8 | 8 | ### Props: |
9 | | -* `courseId` |
10 | | -* `notificationCurrentState` |
11 | | -* `setNotificationCurrentState` |
| 9 | +* `courseId` - String identifier for the current course |
| 10 | +* `model` - String indicating the context model (set to 'coursewareMeta') |
| 11 | +* `notificationCurrentState` - Current state of upgrade notifications (UpgradeNotificationState) |
| 12 | +* `setNotificationCurrentState` - Function to update the notification state |
| 13 | + |
| 14 | +## Description |
| 15 | + |
| 16 | +This slot is used to customize the notification tray that appears in the courseware sidebar. The notification tray displays upgrade-related notifications and alerts for learners in verified mode courses. It provides a way to show contextual notifications about course access, deadlines, and upgrade opportunities. |
| 17 | + |
| 18 | +The slot is conditionally rendered only for learners in verified mode courses. For non-verified courses, a simple "no notifications" message is displayed instead. |
| 19 | + |
| 20 | +The `notificationCurrentState` can be one of: `'accessLastHour'`, `'accessHoursLeft'`, `'accessDaysLeft'`, `'FPDdaysLeft'`, `'FPDLastHour'`, `'accessDateView'`, or `'PastExpirationDate'`. |
| 21 | + |
| 22 | +## Example |
| 23 | + |
| 24 | +The following `env.config.jsx` will customize the notification tray with additional notification types and styling. |
| 25 | + |
| 26 | + |
| 27 | +```js |
| 28 | +import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework'; |
| 29 | + |
| 30 | +const config = { |
| 31 | + pluginSlots: { |
| 32 | + 'org.openedx.frontend.learning.notification_tray.v1': { |
| 33 | + plugins: [ |
| 34 | + { |
| 35 | + // Insert custom notification content |
| 36 | + op: PLUGIN_OPERATIONS.Replace, |
| 37 | + widget: { |
| 38 | + id: 'custom_notifications', |
| 39 | + type: DIRECT_PLUGIN, |
| 40 | + RenderWidget: ({ |
| 41 | + courseId, |
| 42 | + model, |
| 43 | + notificationCurrentState, |
| 44 | + setNotificationCurrentState |
| 45 | + }) => ( |
| 46 | + <div className="p-3"> |
| 47 | + <h5 className="mb-3">📬 Course Notifications</h5> |
| 48 | + |
| 49 | + {notificationCurrentState === 'accessLastHour' && ( |
| 50 | + <div className="alert alert-warning mb-3"> |
| 51 | + <strong>⏰ Last Chance!</strong> |
| 52 | + <p className="mb-0">Your access expires in less than an hour.</p> |
| 53 | + </div> |
| 54 | + )} |
| 55 | + |
| 56 | + {notificationCurrentState === 'accessDaysLeft' && ( |
| 57 | + <div className="alert alert-info mb-3"> |
| 58 | + <strong>📅 Access Reminder</strong> |
| 59 | + <p className="mb-0">Your course access expires in a few days.</p> |
| 60 | + </div> |
| 61 | + )} |
| 62 | + |
| 63 | + <div className="notification-item p-2 mb-2 border rounded"> |
| 64 | + <div className="d-flex justify-content-between align-items-center"> |
| 65 | + <span>📚 New course material available</span> |
| 66 | + <button |
| 67 | + className="btn btn-sm btn-outline-primary" |
| 68 | + onClick={() => setNotificationCurrentState('accessDateView')} |
| 69 | + > |
| 70 | + View |
| 71 | + </button> |
| 72 | + </div> |
| 73 | + </div> |
| 74 | + |
| 75 | + <div className="notification-item p-2 mb-2 border rounded"> |
| 76 | + <div className="d-flex justify-content-between align-items-center"> |
| 77 | + <span>🎯 Assignment due tomorrow</span> |
| 78 | + <span className="badge bg-warning">Due Soon</span> |
| 79 | + </div> |
| 80 | + </div> |
| 81 | + |
| 82 | + <div className="text-center mt-3"> |
| 83 | + <small className="text-muted"> |
| 84 | + Course: {courseId} | Model: {model} |
| 85 | + </small> |
| 86 | + </div> |
| 87 | + </div> |
| 88 | + ), |
| 89 | + }, |
| 90 | + }, |
| 91 | + ] |
| 92 | + } |
| 93 | + }, |
| 94 | +} |
| 95 | + |
| 96 | +export default config; |
| 97 | +``` |
0 commit comments