1
- import React , { useMemo , useState } from 'react' ;
1
+ import React , { useMemo } from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
- import { getConfig } from '@edx/frontend-platform' ;
4
3
import { FormattedMessage } from '@edx/frontend-platform/i18n' ;
5
4
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
6
5
import { faHome } from '@fortawesome/free-solid-svg-icons' ;
7
6
import { useSelector } from 'react-redux' ;
8
- import { useToggle , ModalPopup , Menu } from '@openedx/paragon' ;
9
7
import { Link } from 'react-router-dom' ;
10
- import { useModel , useModels } from '../../generic/model-store' ;
11
- import JumpNavMenuItem from './JumpNavMenuItem' ;
12
-
13
- const CourseBreadcrumb = ( {
14
- content,
15
- withSeparator,
16
- courseId,
17
- sequenceId,
18
- unitId,
19
- isStaff,
20
- } ) => {
21
- const defaultContent = content . filter (
22
- ( destination ) => destination . default ,
23
- ) [ 0 ] || { id : courseId , label : '' , sequences : [ ] } ;
24
-
25
- const showRegularLink = getConfig ( ) . ENABLE_JUMPNAV !== 'true' || content . length < 2 || ! isStaff ;
26
- const [ isOpen , open , close ] = useToggle ( false ) ;
27
- const [ target , setTarget ] = useState ( null ) ;
28
- return (
29
- < >
30
- { withSeparator && (
31
- < li className = "col-auto p-0 mx-2 text-primary-500 text-truncate text-nowrap" role = "presentation" aria-hidden > /</ li >
32
- ) }
33
-
34
- < li
35
- style = { {
36
- overflow : 'hidden' ,
37
- textOverflow : 'ellipsis' ,
38
- whiteSpace : 'nowrap' ,
39
- } }
40
- data-testid = "breadcrumb-item"
41
- >
42
- { showRegularLink ? (
43
- < Link
44
- className = "text-primary-500"
45
- to = {
46
- defaultContent . sequences . length
47
- ? `/course/${ courseId } /${ defaultContent . sequences [ 0 ] . id } `
48
- : `/course/${ courseId } /${ defaultContent . id } `
49
- }
50
- >
51
- { defaultContent . label }
52
- </ Link >
53
- ) : (
54
- < >
55
- {
56
- // eslint-disable-next-line
57
- < a className = "text-primary-500" onClick = { open } ref = { setTarget } >
58
- { defaultContent . label }
59
- </ a >
60
- }
61
- < ModalPopup positionRef = { target } isOpen = { isOpen } onClose = { close } >
62
- < Menu >
63
- { content . map ( ( item ) => (
64
- < JumpNavMenuItem
65
- key = { item . label }
66
- isDefault = { item . default }
67
- sequences = { item . sequences }
68
- courseId = { courseId }
69
- title = { item . label }
70
- currentSequence = { sequenceId }
71
- currentUnit = { unitId }
72
- onClick = { close }
73
- />
74
- ) ) }
75
- </ Menu >
76
- </ ModalPopup >
77
- </ >
78
- ) }
79
- </ li >
80
- </ >
81
- ) ;
82
- } ;
83
- CourseBreadcrumb . propTypes = {
84
- content : PropTypes . arrayOf (
85
- PropTypes . shape ( {
86
- default : PropTypes . bool ,
87
- id : PropTypes . string ,
88
- label : PropTypes . string ,
89
- } ) ,
90
- ) . isRequired ,
91
- sequenceId : PropTypes . string ,
92
- unitId : PropTypes . string ,
93
- withSeparator : PropTypes . bool ,
94
- courseId : PropTypes . string ,
95
- isStaff : PropTypes . bool ,
96
- } ;
97
-
98
- CourseBreadcrumb . defaultProps = {
99
- withSeparator : false ,
100
- sequenceId : null ,
101
- unitId : null ,
102
- courseId : null ,
103
- isStaff : null ,
104
- } ;
8
+ import { useModel , useModels } from '../../../generic/model-store' ;
9
+ import BreadcrumbItem from './BreadcrumbItem' ;
105
10
106
11
const CourseBreadcrumbs = ( {
107
12
courseId,
@@ -110,14 +15,16 @@ const CourseBreadcrumbs = ({
110
15
unitId,
111
16
isStaff,
112
17
} ) => {
113
- const course = useModel ( 'coursewareMeta' , courseId ) ;
18
+ const course = useModel ( 'coursewareMeta' , courseId ) ;
114
19
const courseStatus = useSelector ( ( state ) => state . courseware . courseStatus ) ;
115
20
const sequenceStatus = useSelector (
116
21
( state ) => state . courseware . sequenceStatus ,
117
22
) ;
23
+ console . log ( useModels ( 'sections' , course . sectionIds ) ) ;
24
+
118
25
119
26
const allSequencesInSections = Object . fromEntries (
120
- useModels ( 'sections' , course . sectionIds ) . map ( ( section ) => [
27
+ useModels ( 'sections' , course . sectionIds ) ? .map ( ( section ) => [
121
28
section . id ,
122
29
{
123
30
default : section . id === sectionId ,
@@ -152,6 +59,8 @@ const CourseBreadcrumbs = ({
152
59
}
153
60
return [ chapters , sequentials ] ;
154
61
} , [ courseStatus , sequenceStatus , allSequencesInSections ] ) ;
62
+ console . log ( links ) ;
63
+
155
64
156
65
return (
157
66
< nav aria-label = "breadcrumb" className = "d-inline-block col-sm-10 mb-3" >
@@ -171,14 +80,15 @@ const CourseBreadcrumbs = ({
171
80
</ Link >
172
81
</ li >
173
82
{ links . map ( ( content , i ) => (
174
- < CourseBreadcrumb
83
+ < BreadcrumbItem
175
84
// eslint-disable-next-line react/no-array-index-key
176
85
key = { i }
177
86
courseId = { courseId }
178
87
sequenceId = { sequenceId }
179
88
content = { content }
180
89
unitId = { unitId }
181
90
withSeparator
91
+ separator = "/"
182
92
isStaff = { isStaff }
183
93
/>
184
94
) ) }
0 commit comments