<NME> assignment_list.jsx
<BEF> import React from 'react';
import createReactClass from 'create-react-class';
import PropTypes from 'prop-types';
import { sortBy, groupBy, compact } from 'lodash-es';

import List from '../common/list.jsx';
import Assignment from './assignment.jsx';
import { getFiltered } from '../../utils/model_utils.js';
import ArticleUtils from '../../utils/article_utils.js';

const AssignmentList = createReactClass({
  displayName: 'AssignmentList',

  propTypes: {
    articles: PropTypes.array,
    assignments: PropTypes.array,
    course: PropTypes.object,
    current_user: PropTypes.object,
    wikidataLabels: PropTypes.object
    articles: PropTypes.array,
    assignments: PropTypes.array,
    course: PropTypes.object,
    current_user: PropTypes.object
  },

  hasAssignedUser(group) {
  hasAssignedUser(group) {
    return group.some((assignment) => {
      return assignment.user_id;
    });
  },

  render() {
    const allAssignments = this.props.assignments;
    const sortedAssignments = sortBy(allAssignments, assignment => assignment.article_title);
    const grouped = groupBy(sortedAssignments, assignment => assignment.article_title);
    let elements = Object.keys(grouped).map((title) => {
      const group = grouped[title];
      if (!this.hasAssignedUser(group)) { return null; }
      const article = getFiltered(this.props.articles, { title })[0];
        <Assignment
          assignmentGroup={group}
          article={article || null}
          course={this.props.course}
          key={group[0].id}
          current_user={this.props.current_user}
          wikidataLabel={this.props.wikidataLabels[title]}
        />
      );
    });
    elements = compact(elements);

    const keys = {
      rating_num: {
        label: I18n.t('articles.rating'),
        desktop_only: true
      },
      title: {
        label: I18n.t('articles.title'),
        desktop_only: false
      },
      assignee: {
        label: I18n.t('assignments.assignees'),
        desktop_only: true
      },
      reviewer: {
        label: I18n.t('assignments.reviewers'),
        desktop_only: true
      }
    };

    const project = this.props.course.home_wiki.project;

    return (
      <div id="assignments" className="mt4">
        <div className="section-header">
          <h3>{ArticleUtils.I18n('assigned', project)}</h3>
        </div>
        <List
          elements={elements}
          keys={keys}
          table_key={'assignments'}
          none_message={ArticleUtils.I18n('assignments_none', project)}
          sortable={false}
        />
      </div>
    );
  }
}
);

export default AssignmentList;

<MSG> Apply Wikidata labels to assigned articles

<DFF> @@ -20,7 +20,8 @@ const AssignmentList = createReactClass({
     articles: PropTypes.array,
     assignments: PropTypes.array,
     course: PropTypes.object,
-    current_user: PropTypes.object
+    current_user: PropTypes.object,
+    wikidataLabels: PropTypes.object
   },
 
   hasAssignedUser(group) {
@@ -41,6 +42,7 @@ const AssignmentList = createReactClass({
         <Assignment
           assignmentGroup={group}
           article={article || null}
+          wikidataLabel={this.props.wikidataLabels[title]}
           course={this.props.course}
           key={group[0].id}
           current_user={this.props.current_user}

{'commit': "diff --git a/app/assets/javascripts/components/assignments/assignment.jsx b/app/assets/javascripts/components/assignments/assignment.jsx\nindex 3b94a5f60..1375dec3a 100644\n--- a/app/assets/javascripts/components/assignments/assignment.jsx\n+++ b/app/assets/javascripts/components/assignments/assignment.jsx\n@@ -20,13 +20,14 @@ const Assignment = createReactClass({\n     article: PropTypes.object,\n     assignmentGroup: PropTypes.array,\n     course: PropTypes.object,\n-    current_user: PropTypes.object\n+    current_user: PropTypes.object,\n+    wikidataLabel: PropTypes.string\n   },\n   render() {\n     if (!this.props.course.home_wiki) { return <div />; }\n     const article = this.props.article || CourseUtils.articleFromAssignment(this.props.assignmentGroup[0], this.props.course.home_wiki);\n     if (!article.formatted_title) {\n-      article.formatted_title = CourseUtils.formattedArticleTitle(article, this.props.course.home_wiki);\n+      article.formatted_title = CourseUtils.formattedArticleTitle(article, this.props.course.home_wiki, this.props.wikidataLabel);\n     }\n     const className = 'assignment';\n     const ratingClass = `rating ${article.rating}`;\ndiff --git a/app/assets/javascripts/components/assignments/assignment_list.jsx b/app/assets/javascripts/components/assignments/assignment_list.jsx\nindex 7470058a6..e8b4a2208 100644\n--- a/app/assets/javascripts/components/assignments/assignment_list.jsx\n+++ b/app/assets/javascripts/components/assignments/assignment_list.jsx\n@@ -20,7 +20,8 @@ const AssignmentList = createReactClass({\n     articles: PropTypes.array,\n     assignments: PropTypes.array,\n     course: PropTypes.object,\n-    current_user: PropTypes.object\n+    current_user: PropTypes.object,\n+    wikidataLabels: PropTypes.object\n   },\n \n   hasAssignedUser(group) {\n@@ -41,6 +42,7 @@ const AssignmentList = createReactClass({\n         <Assignment\n           assignmentGroup={group}\n           article={article || null}\n+          wikidataLabel={this.props.wikidataLabels[title]}\n           course={this.props.course}\n           key={group[0].id}\n           current_user={this.props.current_user}\n", 'commit_subject': 'Apply Wikidata labels to assigned articles', 'repo_name': 'WikiEducationFoundation/WikiEduDashboard', 'committer': {'name': 'Sage Ross', 'email': '0bc9f67b2b08dbd979104ac630343507d3de0edf@gmail.com', 'time_sec': '1522276949', 'tz_offset': '-420', 'date': {'seconds': '1522276949'}}, 'commit_tree': '75c32c7cab02bb62c6bbc5a4b54987f4ff880eac', 'commit_message': 'Apply Wikidata labels to assigned articles\n', 'language_name': 'HTML', 'license': 'mit', 'hunks': '@@ -20,7 +20,8 @@ const AssignmentList = createReactClass({\n     articles: PropTypes.array,\n     assignments: PropTypes.array,\n     course: PropTypes.object,\n-    current_user: PropTypes.object\n+    current_user: PropTypes.object,\n+    wikidataLabels: PropTypes.object\n   },\n \n   hasAssignedUser(group) {\n@@ -41,6 +42,7 @@ const AssignmentList = createReactClass({\n         <Assignment\n           assignmentGroup={group}\n           article={article || null}\n+          wikidataLabel={this.props.wikidataLabels[title]}\n           course={this.props.course}\n           key={group[0].id}\n           current_user={this.props.current_user}\n', 'addition_count': 3, 'deletion_count': 1, 'src_file': 'a/app/assets/javascripts/components/assignments/assignment_list.jsx', 'tgt_file': 'b/app/assets/javascripts/components/assignments/assignment_list.jsx', 'file_extension': '.jsx', 'before_file': 'import React from \'react\';\nimport createReactClass from \'create-react-class\';\nimport PropTypes from \'prop-types\';\nimport { sortBy, groupBy, compact } from \'lodash-es\';\n\nimport List from \'../common/list.jsx\';\nimport Assignment from \'./assignment.jsx\';\nimport { getFiltered } from \'../../utils/model_utils.js\';\nimport ArticleUtils from \'../../utils/article_utils.js\';\n\nconst AssignmentList = createReactClass({\n  displayName: \'AssignmentList\',\n\n  propTypes: {\n    articles: PropTypes.array,\n    assignments: PropTypes.array,\n    course: PropTypes.object,\n    current_user: PropTypes.object,\n    wikidataLabels: PropTypes.object\n    articles: PropTypes.array,\n    assignments: PropTypes.array,\n    course: PropTypes.object,\n    current_user: PropTypes.object\n  },\n\n  hasAssignedUser(group) {\n  hasAssignedUser(group) {\n    return group.some((assignment) => {\n      return assignment.user_id;\n    });\n  },\n\n  render() {\n    const allAssignments = this.props.assignments;\n    const sortedAssignments = sortBy(allAssignments, assignment => assignment.article_title);\n    const grouped = groupBy(sortedAssignments, assignment => assignment.article_title);\n    let elements = Object.keys(grouped).map((title) => {\n      const group = grouped[title];\n      if (!this.hasAssignedUser(group)) { return null; }\n      const article = getFiltered(this.props.articles, { title })[0];\n        <Assignment\n          assignmentGroup={group}\n          article={article || null}\n          course={this.props.course}\n          key={group[0].id}\n          current_user={this.props.current_user}\n          wikidataLabel={this.props.wikidataLabels[title]}\n        />\n      );\n    });\n    elements = compact(elements);\n\n    const keys = {\n      rating_num: {\n        label: I18n.t(\'articles.rating\'),\n        desktop_only: true\n      },\n      title: {\n        label: I18n.t(\'articles.title\'),\n        desktop_only: false\n      },\n      assignee: {\n        label: I18n.t(\'assignments.assignees\'),\n        desktop_only: true\n      },\n      reviewer: {\n        label: I18n.t(\'assignments.reviewers\'),\n        desktop_only: true\n      }\n    };\n\n    const project = this.props.course.home_wiki.project;\n\n    return (\n      <div id="assignments" className="mt4">\n        <div className="section-header">\n          <h3>{ArticleUtils.I18n(\'assigned\', project)}</h3>\n        </div>\n        <List\n          elements={elements}\n          keys={keys}\n          table_key={\'assignments\'}\n          none_message={ArticleUtils.I18n(\'assignments_none\', project)}\n          sortable={false}\n        />\n      </div>\n    );\n  }\n}\n);\n\nexport default AssignmentList;\n', 'message': 'Apply Wikidata labels to assigned articles\n', 'author_name': 'Sage Ross', 'lang': 'jsx'}