<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import reactMixin from 'react-mixin';
import autoBind from 'react-autobind';
import Reflux from 'reflux';
import { Link } from 'react-router';
import Dropzone from 'react-dropzone';
import Select from 'react-select';

import {dataInterface} from '../dataInterface';
import actions from '../actions';
import stores from '../stores';
import bem from '../bem';
import searches from '../searches';
import ui from '../ui';
import mixins from '../mixins';

import LibrarySidebar from '../components/librarySidebar';

import {
  t,
  assign,
  anonUsername,
  supportUrl,
  validFileTypes
} from '../utils';

import SidebarFormsList from '../lists/sidebarForms';

var leaveBetaUrl = stores.pageState.leaveBetaUrl;

class FormSidebar extends Reflux.Component {
  constructor(props){
    super(props);
    this.state = assign({
      currentAssetId: false,
      files: []
    }, stores.pageState.state);
    this.stores = [
      stores.session,
      stores.pageState
    ];
    autoBind(this);
  }
  componentDidMount () {
    this.searchDefault();
  }
  componentWillMount() {
    this.setStates();
  }
  setStates() {
    this.setState({
      headerFilters: 'forms',
      searchContext: searches.getSearchContext('forms', {
        filterParams: {
          assetType: 'asset_type:survey',
        },
        filterTags: 'asset_type:survey',
      })
    });
  }
  newFormModal (evt) {
    evt.preventDefault();
    stores.pageState.showModal({
      type: 'new-form'
    });
  }
  render () {
    return (
      <bem.FormSidebar__wrapper>
        {this.state.currentAssetId}
        <ui.PopoverMenu type='new-menu' 
            triggerLabel={t('new')}>
            <bem.PopoverMenu__link onClick={this.newFormModal}>
              <i className="k-icon-projects" />
              {t('Project')}
            </bem.PopoverMenu__link>
            <Dropzone onDrop={this.dropFiles} 
                      multiple={false} 
                      className='dropzone'
                      accept={validFileTypes()}>
              <bem.PopoverMenu__link>
                <i className="k-icon-upload" />
                {t('upload')}
              </bem.PopoverMenu__link>
            </Dropzone>
        </ui.PopoverMenu>
        <SidebarFormsList/>
      </bem.FormSidebar__wrapper>
    );
  }
  componentWillReceiveProps() {
    this.setStates();
  }

};

reactMixin(FormSidebar.prototype, searches.common);
reactMixin(FormSidebar.prototype, mixins.droppable);

class DrawerLink extends React.Component {
  constructor(props) {
    super(props);
    autoBind(this);
  }
  onClick (evt) {
    if (!this.props.href) {
      evt.preventDefault();
    }
    if (this.props.onClick) {
      this.props.onClick(evt);
    }
  }
  render () {
    var icon_class = (this.props['ki-icon'] == undefined ? `fa fa-globe` : `k-icon-${this.props['ki-icon']}`);
    var icon = (<i className={icon_class}></i>);
    var classNames = [this.props.class, 'k-drawer__link'];

    var link;
    if (this.props.linkto) {
      link = (<commit_msg>fix issue with XLS not uploading due to missing context<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import reactMixin from 'react-mixin';
import autoBind from 'react-autobind';
import Reflux from 'reflux';
import { Link } from 'react-router';
import Dropzone from 'react-dropzone';
import Select from 'react-select';

import {dataInterface} from '../dataInterface';
import actions from '../actions';
import stores from '../stores';
import bem from '../bem';
import searches from '../searches';
import ui from '../ui';
import mixins from '../mixins';

import LibrarySidebar from '../components/librarySidebar';

import {
  t,
  assign,
  anonUsername,
  supportUrl,
  validFileTypes
} from '../utils';

import SidebarFormsList from '../lists/sidebarForms';

var leaveBetaUrl = stores.pageState.leaveBetaUrl;

class FormSidebar extends Reflux.Component {
  constructor(props){
    super(props);
    this.state = assign({
      currentAssetId: false,
      files: []
    }, stores.pageState.state);
    this.stores = [
      stores.session,
      stores.pageState
    ];
    autoBind(this);
  }
  componentDidMount () {
    this.searchDefault();
  }
  componentWillMount() {
    this.setStates();
  }
  setStates() {
    this.setState({
      headerFilters: 'forms',
      searchContext: searches.getSearchContext('forms', {
        filterParams: {
          assetType: 'asset_type:survey',
        },
        filterTags: 'asset_type:survey',
      })
    });
  }
  newFormModal (evt) {
    evt.preventDefault();
    stores.pageState.showModal({
      type: 'new-form'
    });
  }
  render () {
    return (
      <bem.FormSidebar__wrapper>
        {this.state.currentAssetId}
        <ui.PopoverMenu type='new-menu' 
            triggerLabel={t('new')}>
            <bem.PopoverMenu__link onClick={this.newFormModal}>
              <i className="k-icon-projects" />
              {t('Project')}
            </bem.PopoverMenu__link>
            <Dropzone onDrop={this.dropFiles} 
                      multiple={false} 
                      className='dropzone'
                      accept={validFileTypes()}>
              <bem.PopoverMenu__link>
                <i className="k-icon-upload" />
                {t('upload')}
              </bem.PopoverMenu__link>
            </Dropzone>
        </ui.PopoverMenu>
        <SidebarFormsList/>
      </bem.FormSidebar__wrapper>
    );
  }
  componentWillReceiveProps() {
    this.setStates();
  }

};

FormSidebar.contextTypes = {
  router: PropTypes.object
};

reactMixin(FormSidebar.prototype, searches.common);
reactMixin(FormSidebar.prototype, mixins.droppable);

class DrawerLink extends React.Component {
  constructor(props) {
    super(props);
    autoBind(this);
  }
  onClick (evt) {
    if (!this.props.href) {
      evt.preventDefault();
    }
    if (this.props.onClick) {
      this.props.onClick(evt);
    }
  }
  render () {
    var icon_class = (this.props['ki-icon'] == undefined ? `fa fa-globe` : `k-icon-${this.props['ki-icon']}`);
    var icon = (<i className={icon_class}></i>);
    var classNames = [this.props.class, 'k-drawer__link'];

    var link;
    if (this.props.linkto) {
      link = (
{'fraction_non_alphanumeric': 0.14219891960597394, 'fraction_numerical': 0.0, 'mean_word_length': 2.554488989271598, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, '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': '4529011', 'n_tokens_mistral': 1963, 'n_tokens_neox': 1957, 'n_words': 382}