<commit_before>var React = require('react');
var CreateForm = require('../components/CreateForm');
var utils = require('keystone-utils');

var Button = require('elemental').Button;
var Dropdown = require('elemental').Dropdown;

var View = React.createClass({
	
	displayName: 'ListView',
	
	getInitialState: function() {
		return {
			createIsVisible: Keystone.showCreateForm,
			animateCreateForm: false
		};
	},
	
	toggleCreate: function(visible) {
		this.setState({
			createIsVisible: visible,
			animateCreateForm: true
		});
	},
	
	renderCreateButton: function() {
		if (Keystone.list.autocreate) {
			return (
				<Button type="success" href={'?new' + Keystone.csrf.query}>
					<span className="octicon octicon-plus mr-5 mr-5" />
					Create {Keystone.list.singular}
				</Button>
			);
		}
		return (
			<Button type="success" onClick={this.toggleCreate.bind(this, true)}>
				<span className="octicon octicon-plus mr-5 mr-5" />
				Create {Keystone.list.singular}
			</Button>
		);
	},
	
	renderCreateForm: function() {
		if (!this.state.createIsVisible) return null;
		return <CreateForm list={Keystone.list} animate={this.state.animateCreateForm} onCancel={this.toggleCreate.bind(this, false)} values={Keystone.createFormData} err={Keystone.createFormErrors} />;
	},
	
	render: function() {
		if (Keystone.list.nocreate) return null;
		return (
			<div className="EditForm__header">
				<div className="container">
					{this.renderCreateButton()}
					{this.renderCreateForm()}
				</div>
			</div>
		);
	}
	
});




/*
	==============================
	SORT DROPDOWN
	==============================
*/

var ListSortDropdown = React.createClass({
	
	displayName: 'ListSortDropdown',
	
	getInitialState: function() {
		return {};
	},

	menuItems: function() {
		return Keystone.list.uiElements.map(function(item, i) {
			console.log(item);

			if (item.type === 'heading') {
				return { type: 'header', label: item.content };
			} else {
				return { type: 'item', label: utils.titlecase(item.field) };
			}
		});
	},
	<commit_msg>remove old log<commit_after>var React = require('react');
var CreateForm = require('../components/CreateForm');
var utils = require('keystone-utils');

var Button = require('elemental').Button;
var Dropdown = require('elemental').Dropdown;

var View = React.createClass({
	
	displayName: 'ListView',
	
	getInitialState: function() {
		return {
			createIsVisible: Keystone.showCreateForm,
			animateCreateForm: false
		};
	},
	
	toggleCreate: function(visible) {
		this.setState({
			createIsVisible: visible,
			animateCreateForm: true
		});
	},
	
	renderCreateButton: function() {
		if (Keystone.list.autocreate) {
			return (
				<Button type="success" href={'?new' + Keystone.csrf.query}>
					<span className="octicon octicon-plus mr-5 mr-5" />
					Create {Keystone.list.singular}
				</Button>
			);
		}
		return (
			<Button type="success" onClick={this.toggleCreate.bind(this, true)}>
				<span className="octicon octicon-plus mr-5 mr-5" />
				Create {Keystone.list.singular}
			</Button>
		);
	},
	
	renderCreateForm: function() {
		if (!this.state.createIsVisible) return null;
		return <CreateForm list={Keystone.list} animate={this.state.animateCreateForm} onCancel={this.toggleCreate.bind(this, false)} values={Keystone.createFormData} err={Keystone.createFormErrors} />;
	},
	
	render: function() {
		if (Keystone.list.nocreate) return null;
		return (
			<div className="EditForm__header">
				<div className="container">
					{this.renderCreateButton()}
					{this.renderCreateForm()}
				</div>
			</div>
		);
	}
	
});




/*
	==============================
	SORT DROPDOWN
	==============================
*/

var ListSortDropdown = React.createClass({
	
	displayName: 'ListSortDropdown',
	
	getInitialState: function() {
		return {};
	},

	menuItems: function() {
		return Keystone.list.uiElements.map(function(item, i) {
			if (item.type === 'heading') {
				return { type: 'header', label: item.content };
			} else {
				return { type: 'item', label: utils.titlecase(item.field) };
			}
		});
	},
	
{'fraction_non_alphanumeric': 0.18168389955686853, 'fraction_numerical': 0.0019694731659281144, 'mean_word_length': 4.022249690976515, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '4403893', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1295, 'n_words': 247}