Skip to content

Commit 525fabd

Browse files
committed
refactor(course-outline): render outline nodes recursively
Replace three card components (SectionCard/SubsectionCard/UnitCard) with a single recursive OutlineNode component driven by depth prop. Card files become thin wrappers preserving test imports. OutlineTree uses a recursive renderNode function with RenderContext for move-computation parameter passing. Consolidate reorder helpers: - applySubsectionReorderMove + applyUnitReorderMove → applyReorderMove - moveSubsectionOver + moveUnitOver → moveItemOver - moveSubsection + moveUnit → moveItem 174/174 tests pass. No new lint/format/type issues.
1 parent 528fcd1 commit 525fabd

12 files changed

Lines changed: 856 additions & 1374 deletions

File tree

src/course-outline/CourseOutline.test.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ import statusBarMessages from './status-bar/messages';
5353
import subsectionMessages from './subsection-card/messages';
5454
import pageAlertMessages from './page-alerts/messages';
5555
import {
56-
moveSubsectionOver,
57-
moveUnitOver,
58-
moveSubsection,
59-
moveUnit,
56+
moveItemOver,
57+
moveItem,
6058
} from './drag-helper/utils';
6159

6260
let axiosMock: import('axios-mock-adapter/types');
@@ -2432,7 +2430,7 @@ describe('<CourseOutline />', () => {
24322430
axiosMock
24332431
.onPut(getCourseItemApiUrl(courseOutlineIndexMock.courseStructure.childInfo.children[0].id))
24342432
.reply(200, { dummy: 'value' });
2435-
const expectedSection = moveSubsection(
2433+
const expectedSection = moveItem(
24362434
[
24372435
...courseOutlineIndexMock.courseStructure.childInfo.children,
24382436
] as unknown as XBlock[],
@@ -2482,7 +2480,7 @@ describe('<CourseOutline />', () => {
24822480
axiosMock
24832481
.onPut(getCourseItemApiUrl(firstSection.id))
24842482
.reply(200, { dummy: 'value' });
2485-
const expectedSections = moveSubsectionOver(
2483+
const expectedSections = moveItemOver(
24862484
[
24872485
...courseOutlineIndexMock.courseStructure.childInfo.children,
24882486
] as unknown as XBlock[],
@@ -2528,7 +2526,7 @@ describe('<CourseOutline />', () => {
25282526
axiosMock
25292527
.onPut(getCourseItemApiUrl(secondSection.id))
25302528
.reply(200, { dummy: 'value' });
2531-
const expectedSections = moveSubsectionOver(
2529+
const expectedSections = moveItemOver(
25322530
[
25332531
...courseOutlineIndexMock.courseStructure.childInfo.children,
25342532
] as unknown as XBlock[],
@@ -2627,7 +2625,7 @@ describe('<CourseOutline />', () => {
26272625
axiosMock
26282626
.onPut(getCourseItemApiUrl(courseOutlineIndexMock.courseStructure.childInfo.children[1].childInfo.children[1].id))
26292627
.reply(200, { dummy: 'value' });
2630-
const expectedSection = moveUnit(
2628+
const expectedSection = moveItem(
26312629
[
26322630
...courseOutlineIndexMock.courseStructure.childInfo.children,
26332631
] as unknown as XBlock[],
@@ -2681,7 +2679,7 @@ describe('<CourseOutline />', () => {
26812679
axiosMock
26822680
.onPut(getCourseItemApiUrl(firstSubsection.id))
26832681
.reply(200, { dummy: 'value' });
2684-
const expectedSections = moveUnitOver(
2682+
const expectedSections = moveItemOver(
26852683
[
26862684
...courseOutlineIndexMock.courseStructure.childInfo.children,
26872685
] as unknown as XBlock[],
@@ -2730,7 +2728,7 @@ describe('<CourseOutline />', () => {
27302728
axiosMock
27312729
.onPut(getCourseItemApiUrl(firstSectionLastSubsection.id))
27322730
.reply(200, { dummy: 'value' });
2733-
const expectedSections = moveUnitOver(
2731+
const expectedSections = moveItemOver(
27342732
[...courseOutlineIndexMock.courseStructure.childInfo.children] as unknown as XBlock[],
27352733
1,
27362734
0,
@@ -2780,7 +2778,7 @@ describe('<CourseOutline />', () => {
27802778
axiosMock
27812779
.onPut(getCourseItemApiUrl(subsection.id))
27822780
.reply(200, { dummy: 'value' });
2783-
const expectedSections = moveUnitOver(
2781+
const expectedSections = moveItemOver(
27842782
[
27852783
...courseOutlineIndexMock.courseStructure.childInfo.children,
27862784
] as unknown as XBlock[],
@@ -2831,7 +2829,7 @@ describe('<CourseOutline />', () => {
28312829
axiosMock
28322830
.onPut(getCourseItemApiUrl(thirdSectionFirstSubsection.id))
28332831
.reply(200, { dummy: 'value' });
2834-
const expectedSections = moveUnitOver(
2832+
const expectedSections = moveItemOver(
28352833
[...courseOutlineIndexMock.courseStructure.childInfo.children] as unknown as XBlock[],
28362834
1,
28372835
lastSubIndex,
@@ -2925,7 +2923,7 @@ describe('<CourseOutline />', () => {
29252923
axiosMock
29262924
.onPut(getCourseItemApiUrl(section.id))
29272925
.reply(200, { dummy: 'value' });
2928-
const expectedSection = moveSubsection(
2926+
const expectedSection = moveItem(
29292927
[
29302928
...courseOutlineIndexMock.courseStructure.childInfo.children,
29312929
] as unknown as XBlock[],
@@ -3018,7 +3016,7 @@ describe('<CourseOutline />', () => {
30183016
axiosMock
30193017
.onPut(getCourseItemApiUrl(subsection.id))
30203018
.reply(200, { dummy: 'value' });
3021-
const expectedSection = moveUnit([...sections] as unknown as XBlock[], 2, 0, 1, 0)[0][2];
3019+
const expectedSection = moveItem([...sections] as unknown as XBlock[], 2, 0, 1, 0)[0][2];
30223020
axiosMock
30233021
.onGet(getXBlockApiUrl(section.id))
30243022
.reply(200, expectedSection);
@@ -3060,7 +3058,7 @@ describe('<CourseOutline />', () => {
30603058
axiosMock
30613059
.onPut(getCourseItemApiUrl(subsection.id))
30623060
.reply(500);
3063-
const expectedSection = moveUnit([...sections] as unknown as XBlock[], 2, 0, 1, 0)[0][2];
3061+
const expectedSection = moveItem([...sections] as unknown as XBlock[], 2, 0, 1, 0)[0][2];
30643062
axiosMock
30653063
.onGet(getXBlockApiUrl(section.id))
30663064
.reply(200, expectedSection);

0 commit comments

Comments
 (0)