Skip to content

Commit f39a50e

Browse files
authored
feat: add section outline plugin (#1632)
This PR adds a plugin slot for the section list in the outline tab. This plugin can be used to add custom content before the list or add extra content to the titles for sections and subsections. To accomplish this, some of the smaller components inside Section and SequenceLink have been extrapolated into their own components so that they can be easily imported for use in plugins.
1 parent 72724bc commit f39a50e

15 files changed

+464
-300
lines changed

src/course-home/outline-tab/OutlineTab.jsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import WeeklyLearningGoalCard from './widgets/WeeklyLearningGoalCard';
1515
import CourseTools from './widgets/CourseTools';
1616
import { fetchOutlineTab } from '../data';
1717
import messages from './messages';
18-
import Section from './Section';
1918
import ShiftDatesAlert from '../suggested-schedule-messaging/ShiftDatesAlert';
2019
import UpgradeNotification from '../../generic/upgrade-notification/UpgradeNotification';
2120
import UpgradeToShiftDatesAlert from '../suggested-schedule-messaging/UpgradeToShiftDatesAlert';
@@ -28,6 +27,7 @@ import { useModel } from '../../generic/model-store';
2827
import WelcomeMessage from './widgets/WelcomeMessage';
2928
import ProctoringInfoPanel from './widgets/ProctoringInfoPanel';
3029
import AccountActivationAlert from '../../alerts/logistration-alert/AccountActivationAlert';
30+
import CourseHomeSectionOutlineSlot from '../../plugin-slots/CourseHomeSectionOutlineSlot';
3131

3232
const OutlineTab = () => {
3333
const intl = useIntl();
@@ -165,24 +165,18 @@ const OutlineTab = () => {
165165
<WelcomeMessage courseId={courseId} nextElementRef={expandButtonRef} />
166166
{rootCourseId && (
167167
<>
168-
<div className="row w-100 m-0 mb-3 justify-content-end">
168+
<div id="expand-button-row" className="row w-100 m-0 mb-3 justify-content-end">
169169
<div className="col-12 col-md-auto p-0">
170170
<Button ref={expandButtonRef} variant="outline-primary" block onClick={() => { setExpandAll(!expandAll); }}>
171171
{expandAll ? intl.formatMessage(messages.collapseAll) : intl.formatMessage(messages.expandAll)}
172172
</Button>
173173
</div>
174174
</div>
175-
<ol id="courseHome-outline" className="list-unstyled">
176-
{courses[rootCourseId].sectionIds.map((sectionId) => (
177-
<Section
178-
key={sectionId}
179-
courseId={courseId}
180-
defaultOpen={sections[sectionId].resumeBlock}
181-
expand={expandAll}
182-
section={sections[sectionId]}
183-
/>
184-
))}
185-
</ol>
175+
<CourseHomeSectionOutlineSlot
176+
expandAll={expandAll}
177+
sectionIds={courses[rootCourseId].sectionIds}
178+
sections={sections}
179+
/>
186180
</>
187181
)}
188182
</div>

src/course-home/outline-tab/OutlineTab.test.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ describe('Outline Tab', () => {
168168
course_blocks: { blocks: courseBlocks.blocks },
169169
});
170170
await fetchAndRender();
171-
expect(screen.getByTitle('Completed section')).toBeInTheDocument();
171+
expect(screen.getByLabelText('Completed section')).toBeInTheDocument();
172172
});
173173

174174
it('displays correct icon for incomplete assignment', async () => {
@@ -177,7 +177,7 @@ describe('Outline Tab', () => {
177177
course_blocks: { blocks: courseBlocks.blocks },
178178
});
179179
await fetchAndRender();
180-
expect(screen.getByTitle('Incomplete section')).toBeInTheDocument();
180+
expect(screen.getByLabelText('Incomplete section')).toBeInTheDocument();
181181
});
182182

183183
it('SequenceLink displays link', async () => {
@@ -293,7 +293,7 @@ describe('Outline Tab', () => {
293293
expect(showMoreButton).toBeInTheDocument();
294294
});
295295

296-
fit('dismisses message', async () => {
296+
it('dismisses message', async () => {
297297
expect(screen.getByTestId('alert-container-welcome')).toBeInTheDocument();
298298
const dismissButton = screen.queryByRole('button', { name: 'Dismiss' });
299299
const expandButton = screen.queryByRole('button', { name: 'Expand all' });

src/course-home/outline-tab/Section.jsx

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

src/course-home/outline-tab/SequenceLink.jsx

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

src/course-home/outline-tab/messages.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,16 @@ const messages = defineMessages({
341341
defaultMessage: 'Onboarding Past Due',
342342
description: 'Text that show when the deadline of proctortrack onboarding exam has passed, it appears on button that start the onboarding exam however for this case the button is disabled for obvious reason',
343343
},
344+
sequenceDueDate: {
345+
id: 'learning.outline.sequence-due-date-set',
346+
defaultMessage: '{description} due {assignmentDue}',
347+
description: 'Used below an assignment title',
348+
},
349+
sequenceNoDueDate: {
350+
id: 'learning.outline.sequence-due-date-not-set',
351+
defaultMessage: '{description}',
352+
description: 'Used below an assignment title',
353+
},
344354
});
345355

346356
export default messages;

0 commit comments

Comments
 (0)