Skip to content

Commit d860835

Browse files
committed
Revert "feat: decouple notifications panel using widget registry mechanism (#1885)"
This reverts commit 0664dc3.
1 parent bb96beb commit d860835

115 files changed

Lines changed: 1987 additions & 4345 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/decisions/0010-upgrade-widget-extraction.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

example.env.config.jsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import UnitTranslationPlugin from '@edx/unit-translation-selector-plugin';
2-
import { upgradeWidgetConfig } from './src/widgets/upgrade/src/index';
32
import { PLUGIN_OPERATIONS, DIRECT_PLUGIN } from '@openedx/frontend-plugin-framework';
43

54
// Load environment variables from .env file
65
const config = {
76
...process.env,
8-
SIDEBAR_WIDGETS: [upgradeWidgetConfig],
9-
107
pluginSlots: {
118
unit_title_plugin: {
129
plugins: [

jest.config.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,20 @@ const config = createConfig('jest', {
2424

2525
// delete config.testURL;
2626

27-
// NOTE: jest-console-group-reporter@1.1.1 uses @jest/reporters@^30 internally
28-
// (via its peer dep resolution) but this project runs Jest 29, whose globalConfig
29-
// uses testPathPattern (string) not testPathPatterns (object). When any worker
30-
// exits uncleanly the reporter's SummaryReporter.onRunComplete crashes with
31-
// "Cannot read properties of undefined (reading 'isSet')", causing a non-zero
32-
// exit code even when all tests pass. Disabled until the package is updated for
33-
// Jest 29/30 compatibility.
34-
// config.reporters = [...(config.reporters || []), ["jest-console-group-reporter", {
35-
// afterEachTest: { enable: true, filePaths: false, reportType: "details" },
36-
// afterAllTests: { reportType: "summary", enable: true, filePaths: true },
37-
// }]];
27+
config.reporters = [...(config.reporters || []), ["jest-console-group-reporter", {
28+
// change this setting if need to see less details for each test
29+
// reportType: "summary" | "details",
30+
// enable: true | false,
31+
afterEachTest: {
32+
enable: true,
33+
filePaths: false,
34+
reportType: "details",
35+
},
36+
afterAllTests: {
37+
reportType: "summary",
38+
enable: true,
39+
filePaths: true,
40+
},
41+
}]];
3842

3943
module.exports = config;

package-lock.json

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@
8383
"eslint-import-resolver-webpack": "^0.13.9",
8484
"jest-console-group-reporter": "^1.1.1",
8585
"jest-when": "^3.6.0",
86-
"rosie": "2.1.1",
87-
"ts-jest": "29.1.4"
86+
"rosie": "2.1.1"
8887
},
8988
"bundlewatch": {
9089
"files": [

src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const ALLOW_UPSELL_MODES = [
6464

6565
export const WIDGETS = {
6666
DISCUSSIONS: 'DISCUSSIONS',
67-
COURSE_OUTLINE: 'COURSE_OUTLINE',
67+
NOTIFICATIONS: 'NOTIFICATIONS',
6868
} as const satisfies Readonly<{ [k: string]: string }>;
6969

7070
export const LOADING = 'loading';

src/courseware/course/Course.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import { AlertList } from '@src/generic/user-messages';
1010
import { useModel } from '@src/generic/model-store';
1111
import { LearnerToolsSlot } from '../../plugin-slots/LearnerToolsSlot';
1212
import SidebarProvider from './sidebar/SidebarContextProvider';
13-
import { RightSidebarTriggerSlot } from '../../plugin-slots/RightSidebarTriggerSlot';
13+
import NewSidebarProvider from './new-sidebar/SidebarContextProvider';
14+
import { NotificationsDiscussionsSidebarTriggerSlot } from '../../plugin-slots/NotificationsDiscussionsSidebarTriggerSlot';
1415
import { CelebrationModal, shouldCelebrateOnSectionLoad, WeeklyGoalCelebrationModal } from './celebration';
1516
import ContentTools from './content-tools';
1617
import Sequence from './sequence';
@@ -30,6 +31,7 @@ const Course = ({
3031
const {
3132
celebrations,
3233
isStaff,
34+
isNewDiscussionSidebarViewEnabled,
3335
originalUserIsStaff,
3436
} = useModel('courseHomeMeta', courseId);
3537
const sequence = useModel('sequences', sequenceId);
@@ -71,8 +73,10 @@ const Course = ({
7173
));
7274
}, [sequenceId]);
7375

76+
const SidebarProviderComponent = isNewDiscussionSidebarViewEnabled ? NewSidebarProvider : SidebarProvider;
77+
7478
return (
75-
<SidebarProvider courseId={courseId} unitId={unitId}>
79+
<SidebarProviderComponent courseId={courseId} unitId={unitId}>
7680
<Helmet>
7781
<title>{`${pageTitleBreadCrumbs.join(' | ')} | ${getConfig().SITE_NAME}`}</title>
7882
</Helmet>
@@ -94,7 +98,7 @@ const Course = ({
9498
)}
9599
<div className="w-100 d-flex align-items-center">
96100
<CourseOutlineMobileSidebarTriggerSlot />
97-
<RightSidebarTriggerSlot courseId={courseId} />
101+
<NotificationsDiscussionsSidebarTriggerSlot courseId={courseId} />
98102
</div>
99103
</div>
100104

@@ -119,7 +123,7 @@ const Course = ({
119123
onClose={() => setWeeklyGoalCelebrationOpen(false)}
120124
/>
121125
<ContentTools course={course} />
122-
</SidebarProvider>
126+
</SidebarProviderComponent>
123127
);
124128
};
125129

src/courseware/course/Course.test.jsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,18 @@ describe('Course', () => {
198198
rerender(null);
199199
});
200200

201-
it('doesn\'t renders course breadcrumbs by default', async () => {
202-
global.innerWidth = breakpoints.extraLarge.minWidth;
201+
it('handles click to open/close notification tray', async () => {
202+
await setupDiscussionSidebar();
203+
const notificationShowButton = await screen.findByRole('button', { name: /Show notification tray/i });
204+
expect(screen.queryByRole('region', { name: /notification tray/i })).not.toBeInTheDocument();
205+
fireEvent.click(notificationShowButton);
203206

207+
const notificationTray = await screen.findByRole('region', { name: /notification tray/i });
208+
expect(notificationTray).toBeInTheDocument();
209+
expect(notificationTray).not.toHaveClass('d-none');
210+
});
211+
212+
it('doesn\'t renders course breadcrumbs by default', async () => {
204213
const courseMetadata = Factory.build('courseMetadata');
205214
const unitBlocks = Array.from({ length: 3 }).map(() => Factory.build(
206215
'block',

src/courseware/course/messages.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,35 @@
11
import { defineMessages } from '@edx/frontend-platform/i18n';
22

33
const messages = defineMessages({
4-
closeSidebarTrigger: {
5-
id: 'sidebar.close.button',
6-
defaultMessage: 'Close sidebar',
7-
description: 'Button to close the active sidebar panel',
4+
notificationTray: {
5+
id: 'notification.tray.container',
6+
defaultMessage: 'Notification tray',
7+
description: 'Notification tray container',
88
},
9-
responsiveCloseSidebarPanel: {
10-
id: 'sidebar.responsive.close.button',
9+
openNotificationTrigger: {
10+
id: 'notification.open.button',
11+
defaultMessage: 'Show notification tray',
12+
description: 'Button to open the notification tray and show notifications',
13+
},
14+
closeNotificationTrigger: {
15+
id: 'notification.close.button',
16+
defaultMessage: 'Close notification tray',
17+
description: 'Button for the learner to close the sidebar',
18+
},
19+
responsiveCloseNotificationTray: {
20+
id: 'responsive.close.notification',
1121
defaultMessage: 'Back to course',
12-
description: 'Responsive back-button to close the sidebar and return to course content',
22+
description: 'Responsive button to go back to course and close the notification tray',
23+
},
24+
notificationTitle: {
25+
id: 'notification.tray.title',
26+
defaultMessage: 'Notifications',
27+
description: 'Title text displayed for the notification tray',
28+
},
29+
noNotificationsMessage: {
30+
id: 'notification.tray.no.message',
31+
defaultMessage: 'You have no new notifications at this time.',
32+
description: 'Text displayed when the learner has no notifications',
1333
},
1434
});
1535

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React, { useContext } from 'react';
2+
3+
import SidebarContext from './SidebarContext';
4+
import { SIDEBARS } from './sidebars';
5+
6+
const Sidebar = () => {
7+
const { currentSidebar, isDiscussionbarAvailable, isNotificationbarAvailable } = useContext(SidebarContext);
8+
9+
if (currentSidebar === null || (!isDiscussionbarAvailable && !isNotificationbarAvailable)
10+
|| !SIDEBARS[currentSidebar]) { return null; }
11+
const SidebarToRender = SIDEBARS[currentSidebar].Sidebar;
12+
13+
return (
14+
<SidebarToRender />
15+
);
16+
};
17+
18+
export default Sidebar;

0 commit comments

Comments
 (0)