Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
106557f3
Commit
106557f3
authored
Dec 08, 2017
by
Ari Rizzitano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert course/library listing to use reactrenderer
parent
292848cf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
77 deletions
+38
-77
cms/static/js/features_jsx/studio/CourseOrLibraryListing.jsx
+1
-55
cms/templates/index.html
+36
-21
webpack.common.config.js
+1
-1
No files found.
cms/static/js/features_jsx/studio/
index
.jsx
→
cms/static/js/features_jsx/studio/
CourseOrLibraryListing
.jsx
View file @
106557f3
...
...
@@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
import
React
from
'react'
;
import
ReactDOM
from
'react-dom'
;
function
CourseOrLibraryListing
(
props
)
{
export
function
CourseOrLibraryListing
(
props
)
{
const
allowReruns
=
props
.
allowReruns
;
const
linkClass
=
props
.
linkClass
;
const
idBase
=
props
.
idBase
;
...
...
@@ -75,57 +75,3 @@ CourseOrLibraryListing.propTypes = {
items
:
PropTypes
.
arrayOf
(
PropTypes
.
object
).
isRequired
,
linkClass
:
PropTypes
.
string
.
isRequired
,
};
export
class
StudioCourseIndex
{
constructor
(
selector
,
context
,
allowReruns
)
{
// The HTML element is only conditionally shown, based on number of courses.
const
element
=
document
.
querySelector
(
selector
);
if
(
element
)
{
ReactDOM
.
render
(
<
CourseOrLibraryListing
items=
{
context
}
linkClass=
"course-link"
idBase=
"course"
allowReruns=
{
allowReruns
}
/>,
element
,
);
}
}
}
export
class
StudioArchivedIndex
{
constructor
(
selector
,
context
,
allowReruns
)
{
// The HTML element is only conditionally shown, based on number of archived courses.
const
element
=
document
.
querySelector
(
selector
);
if
(
element
)
{
ReactDOM
.
render
(
<
CourseOrLibraryListing
items=
{
context
}
linkClass=
"course-link"
idBase=
"archived"
allowReruns=
{
allowReruns
}
/>,
element
,
);
}
}
}
export
class
StudioLibraryIndex
{
constructor
(
selector
,
context
)
{
// The HTML element is only conditionally shown, based on number of libraries.
const
element
=
document
.
querySelector
(
selector
);
if
(
element
)
{
ReactDOM
.
render
(
<
CourseOrLibraryListing
items=
{
context
}
linkClass=
"library-link"
idBase=
"library"
allowReruns=
{
false
}
/>,
document
.
querySelector
(
selector
),
);
}
}
}
cms/templates/index.html
View file @
106557f3
...
...
@@ -324,7 +324,18 @@ from openedx.core.djangolib.js_utils import (
% endif
%if len(courses) > 0 or optimization_enabled:
<div
class=
"courses courses-tab react-course-listing active"
></div>
<div
class=
"courses courses-tab react-course-listing active"
>
${static.renderReact(
component="CourseOrLibraryListing",
id="react-course-listing",
props={
'items': sorted(courses, key=lambda s: s['display_name'].lower() if s['display_name'] is not None else ''),
'linkClass': 'course-link',
'idBase': 'course',
'allowReruns': allow_course_reruns and rerun_creator_status and course_creator_status=='granted'
}
)}
</div>
%else:
<div
class=
"notice notice-incontext notice-instruction notice-instruction-nocourses list-notices courses-tab active"
>
...
...
@@ -442,11 +453,33 @@ from openedx.core.djangolib.js_utils import (
% endif
%if archived_courses:
<div
class=
"archived-courses react-archived-course-listing archived-courses-tab"
></div>
<div
class=
"archived-courses react-archived-course-listing archived-courses-tab"
>
${static.renderReact(
component="CourseOrLibraryListing",
id="react-archived-course-listing",
props={
'items': sorted(archived_courses, key=lambda s: s['display_name'].lower() if s['display_name'] is not None else ''),
'linkClass': 'course-link',
'idBase': 'archived',
'allowReruns': allow_course_reruns and rerun_creator_status and course_creator_status=='granted'
}
)}
</div>
%endif
%if len(libraries) > 0 or optimization_enabled:
<div
class=
"libraries react-library-listing libraries-tab"
></div>
<div
class=
"libraries react-library-listing libraries-tab"
>
${static.renderReact(
component="CourseOrLibraryListing",
id="react-library-listing",
props={
'items': sorted(libraries, key=lambda s: s['display_name'].lower() if s['display_name'] is not None else ''),
'linkClass': 'library-link',
'idBase': 'library',
'allowReruns': allow_course_reruns and rerun_creator_status and course_creator_status=='granted'
}
)}
</div>
%else:
<div
class=
"notice notice-incontext notice-instruction notice-instruction-nocourses list-notices libraries-tab"
>
...
...
@@ -552,22 +585,4 @@ from openedx.core.djangolib.js_utils import (
%endif
</div>
<
%
static:webpack
entry=
"StudioIndex"
>
var enableReruns = ${allow_course_reruns and rerun_creator_status and course_creator_status=='granted' | n, dump_js_escaped_json};
new StudioCourseIndex(
".react-course-listing",
${sorted(courses, key=lambda s: s['display_name'].lower() if s['display_name'] is not None else '') | n, dump_js_escaped_json},
enableReruns
);
new StudioArchivedIndex(
".react-archived-course-listing",
${sorted(archived_courses, key=lambda s: s['display_name'].lower() if s['display_name'] is not None else '') | n, dump_js_escaped_json},
enableReruns
);
new StudioLibraryIndex(
".react-library-listing",
${sorted(libraries, key=lambda s: s['display_name'].lower() if s['display_name'] is not None else '') | n, dump_js_escaped_json}
);
</
%
static:webpack>
</
%
block>
webpack.common.config.js
View file @
106557f3
...
...
@@ -19,7 +19,7 @@ module.exports = {
// Studio
AssetsPage
:
'./node_modules/@edx/studio-frontend/src/index.jsx'
,
Import
:
'./cms/static/js/features/import/factories/import.js'
,
StudioIndex
:
'./cms/static/js/features_jsx/studio/index
.jsx'
,
CourseOrLibraryListing
:
'./cms/static/js/features_jsx/studio/CourseOrLibraryListing
.jsx'
,
AccessibilityPage
:
'./node_modules/@edx/studio-frontend/src/accessibilityIndex.jsx'
,
// LMS
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment