<commit_before>import _ from 'lodash'
import Immutable from 'immutable'
import React from 'react/addons'
import {State, Navigation} from 'react-router'

import studentActions from '../flux/studentActions'
import RequirementSet from './requirementSet'

let cx = React.addons.classSet

let AreaOfStudy = React.createClass({
	mixins: [State, Navigation],

	propTypes: {
		area: React.PropTypes.shape({
			id: React.PropTypes.string.isRequired,
			title: React.PropTypes.string.isRequired,
			result: React.PropTypes.bool.isRequired,
			progress: React.PropTypes.shape({
				at: React.PropTypes.number.isRequired,
				of: React.PropTypes.number.isRequired,
				word: React.PropTypes.string,
			}).isRequired,
			type: React.PropTypes.string,
			details: React.PropTypes.arrayOf(React.PropTypes.object),
		})
	},

	toggle() {
		this.setState({expanded: !this.state.expanded})

		let sections = Immutable.Set(this.props.student.settings.get('expanded-sections') || [])
		if (this.state.expanded) {
			sections = sections.delete(this.props.area.id)
		}
		else {
			sections = sections.add(this.props.area.id)
		}

		studentActions.changeSetting(this.props.student.id, 'expanded-sections', sections.toArray())
	},

	checkForExpansion(props) {
		let sections = props.student.settings.get('expanded-sections')
		if (sections)
			return sections.indexOf(this.props.area.id) >= 0
		return false
	},

	componentWillReceiveProps(nextProps) {
		this.setState({ expanded: this.checkForExpansion(this.props) })
	},

	componentWillMount() {
		this.setState({ expanded: this.checkForExpansion(this.props) })
	},

	getInitialState() {
		return { expanded: this.checkForExpansion(this.props) }
	},

	render() {
		// console.log(`render areaOfStudy for ${this.props.area.id}`)

		let requirementSets = null
		if (this.state.expanded)
			requirementSets = _.map(this.props.area.details, (reqset) =>
				React.createElement(RequirementSet, _.extend({key: reqset.title}, reqset)))

		let header = React.createElement('header',
			{className: 'summary', onClick: this.toggle},
			React.createElement('h1', null, this.props.area.title),
			React.createElement('progress', {
				value: this.props.area.progress.at,
				max: this.props.area.progress.of,
				className: this.props.area.progress.word,
			}))

		let classes = cx({
			'area-of-study': true,
			open: this.state.expanded,
		})

		return React.createElement('div',
			{key: this.props.area.id, className: classes},
			header,
			requirementSets)
	},
})

export default AreaOfStudy<commit_msg>Remove support for automatically expanding areas of study<commit_after>import _ from 'lodash'
import Immutable from 'immutable'
import React from 'react/addons'
import {State, Navigation} from 'react-router'

import studentActions from '../flux/studentActions'
import RequirementSet from './requirementSet'

let cx = React.addons.classSet

let AreaOfStudy = React.createClass({
	mixins: [State, Navigation],

	propTypes: {
		area: React.PropTypes.shape({
			id: React.PropTypes.string.isRequired,
			title: React.PropTypes.string.isRequired,
			result: React.PropTypes.bool.isRequired,
			progress: React.PropTypes.shape({
				at: React.PropTypes.number.isRequired,
				of: React.PropTypes.number.isRequired,
				word: React.PropTypes.string,
			}).isRequired,
			type: React.PropTypes.string,
			details: React.PropTypes.arrayOf(React.PropTypes.object),
		})
	},

	toggle() {
		this.setState({expanded: !this.state.expanded})
	},

	componentWillReceiveProps(nextProps) {
		this.setState({
			reqSets: this.makeReqSets(),
		})
	},

	componentWillMount() {
		this.setState({
			reqSets: this.makeReqSets(),
		})
	},

	getInitialState() {
		return {
			expanded: false,
			reqSets: this.makeReqSets(),
		}
	},

	makeReqSets() {
		let reqSets = _.map(this.props.area.details, (reqset) =>
				React.createElement(RequirementSet, Object.assign({key: reqset.title}, reqset)))
		return reqSets
	},

	render() {
		// console.log(`render areaOfStudy for ${this.props.area.id}`)

		let header = React.createElement('header',
			{className: 'summary', onClick: this.toggle},
			React.createElement('h1', null, this.props.area.title),
			React.createElement('progress', {
				value: this.props.area.progress.at,
				max: this.props.area.progress.of,
				className: this.props.area.progress.word,
			}))

		let classes = cx({
			'area-of-study': true,
			open: this.state.expanded,
		})

		return React.createElement('div',
			{key: this.props.area.id, className: classes},
			header,
			this.state.expanded ? this.state.reqSets : null)
	},
})

export default AreaOfStudy
{'fraction_non_alphanumeric': 0.14422867117608554, 'fraction_numerical': 0.0006545930613135501, 'mean_word_length': 4.215017064846417, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1046459', 'n_tokens_mistral': 1674, 'n_tokens_neox': 1483, 'n_words': 277}