<commit_before>import React, {Component} from 'react';
import PropTypes from 'prop-types';
import Drawer from 'material-ui/Drawer';
import {List, ListItem, makeSelectable} from 'material-ui/List';
import {spacing, typography, zIndex} from 'material-ui/styles';

const SelectableList = makeSelectable(List);

const styles = {
  logo: {
    cursor: 'pointer',
    fontSize: 24,
    color: typography.textFullWhite,
    lineHeight: `${spacing.desktopKeylineIncrement}px`,
    fontWeight: typography.fontWeightLight,
    backgroundColor: '#a5cf47',
    paddingLeft: spacing.desktopGutter,
    marginBottom: 8,
  },
};

class AppNavDrawer extends Component {
  static propTypes = {
    docked: PropTypes.bool.isRequired,
    location: PropTypes.object.isRequired,
    onChangeList: PropTypes.func.isRequired,
    onRequestChangeNavDrawer: PropTypes.func.isRequired,
    open: PropTypes.bool.isRequired,
    style: PropTypes.object,
  };

  static contextTypes = {
    muiTheme: PropTypes.object.isRequired,
    router: PropTypes.object.isRequired,
  };

  // state = {
  //   muiVersions: [],
  // };

  // componentDidMount() {
  //   const self = this;
  //   const url = '/versions.json';
  //   const request = new XMLHttpRequest();
  //
  //   request.onreadystatechange = function() {
  //     if (request.readyState === 4 && request.status === 200) {
  //       self.setState({
  //         muiVersions: JSON.parse(request.responseText),
  //         version: JSON.parse(request.responseText)[0],
  //       });
  //     }
  //   };
  //
  //   request.open('GET', url, true);
  //   request.send();
  // }
  //
  // firstNonPreReleaseVersion() {
  //   let version;
  //   for (let i = 0; i < this.state.muiVersions.length; i++) {
  //     version = this.state.muiVersions[i];
  //     // If the version doesn't contain '-' and isn't 'HEAD'
  //     if (!/-/.test(version) && version !== 'HEAD') {
  //       break;
  //     }
  //   }
  //   return version;
  // }

  // handleVersionChange = (event, index, value) => {
  //   if (value === this.firstNonPreReleaseVersion()) {
  //     window.location = 'http://www.material-ui.com/';
  //   } else {
  //     window.location = `http://www.material-ui.com/${value}`;
  //   }
  // };
  //
  // currentVersion() {
  //   if (window.location.hostname === 'localhost') return this.state.muiVersions[0];
  //   if (window.location.pathname === '/') {
  //     return this.firstNonPreReleaseVersion();
  //   } else {
  //     return window.location.pathname.replace(/\//g, '');
  //   }
  // }
  handleRequestChangeLink = (event, value) => {
    window.location = value;
  };

  handleTouchTapHeader = () => {
    this.context.router.push('/');
    this.props.onRequestChangeNavDrawer(false);
  };

  render() {
    const {
      location,
      docked,
      onRequestChangeNavDrawer,
      onChangeList,
      open,
      style,
    } = this.props;

    return (
      <Drawer
        style={style}
        docked={docked}
        open={open}
        onRequestChange={onRequestChangeNavDrawer}
        containerStyle={{zIndex: zIndex.drawer - 100}}
      >
        <div style={styles.logo} onTouchTap={this.handleTouchTapHeader}>
          Internet of Things
        </div>

        <SelectableList
          value={location.pathname}
          onChange={onChangeList}
        >
          <ListItem
            primaryText="Home"
            value="/"
            href="#"
          />
          <ListItem
            primaryText="Getting Started"
            value="/getstarted/intro"
            href="#/getstarted/intro"
          />
          <ListItem
            primaryText="For Teachers"
            primaryTogglesNestedList={true}
            value="/teachers/intro"
            href="#/teachers/intro"
            nestedItems={[
              <ListItem
                primaryText="Tutorials"
                value="/teachers/tutorials"
                href="#/teachers/tutorials"
              />,
              <ListItem<commit_msg>Add close icon to drawer header to make it more intutite<commit_after>import React, {Component} from 'react';
import PropTypes from 'prop-types';
import Drawer from 'material-ui/Drawer';
import FontIcon from 'material-ui/FontIcon';
import NavigationClose from 'material-ui/svg-icons/navigation/close';
import {darkWhite} from 'material-ui/styles/colors';
import {List, ListItem, makeSelectable} from 'material-ui/List';
import {spacing, typography, zIndex} from 'material-ui/styles';

const SelectableList = makeSelectable(List);

const styles = {
  logo: {
    cursor: 'pointer',
    fontSize: 24,
    color: typography.textFullWhite,
    lineHeight: `${spacing.desktopKeylineIncrement}px`,
    fontWeight: typography.fontWeightLight,
    backgroundColor: '#a5cf47',
    paddingLeft: spacing.desktopGutter,
    marginBottom: 8,
  },
};

class AppNavDrawer extends Component {
  static propTypes = {
    docked: PropTypes.bool.isRequired,
    location: PropTypes.object.isRequired,
    onChangeList: PropTypes.func.isRequired,
    onRequestChangeNavDrawer: PropTypes.func.isRequired,
    open: PropTypes.bool.isRequired,
    style: PropTypes.object,
  };

  static contextTypes = {
    muiTheme: PropTypes.object.isRequired,
    router: PropTypes.object.isRequired,
  };

  // state = {
  //   muiVersions: [],
  // };

  // componentDidMount() {
  //   const self = this;
  //   const url = '/versions.json';
  //   const request = new XMLHttpRequest();
  //
  //   request.onreadystatechange = function() {
  //     if (request.readyState === 4 && request.status === 200) {
  //       self.setState({
  //         muiVersions: JSON.parse(request.responseText),
  //         version: JSON.parse(request.responseText)[0],
  //       });
  //     }
  //   };
  //
  //   request.open('GET', url, true);
  //   request.send();
  // }
  //
  // firstNonPreReleaseVersion() {
  //   let version;
  //   for (let i = 0; i < this.state.muiVersions.length; i++) {
  //     version = this.state.muiVersions[i];
  //     // If the version doesn't contain '-' and isn't 'HEAD'
  //     if (!/-/.test(version) && version !== 'HEAD') {
  //       break;
  //     }
  //   }
  //   return version;
  // }

  // handleVersionChange = (event, index, value) => {
  //   if (value === this.firstNonPreReleaseVersion()) {
  //     window.location = 'http://www.material-ui.com/';
  //   } else {
  //     window.location = `http://www.material-ui.com/${value}`;
  //   }
  // };
  //
  // currentVersion() {
  //   if (window.location.hostname === 'localhost') return this.state.muiVersions[0];
  //   if (window.location.pathname === '/') {
  //     return this.firstNonPreReleaseVersion();
  //   } else {
  //     return window.location.pathname.replace(/\//g, '');
  //   }
  // }
  handleRequestChangeLink = (event, value) => {
    window.location = value;
  };

  handleTouchTapHeader = () => {
    this.context.router.push('/');
    this.props.onRequestChangeNavDrawer(false);
  };

  render() {
    const {
      location,
      docked,
      onRequestChangeNavDrawer,
      onChangeList,
      open,
      style,
    } = this.props;

    return (
      <Drawer
        style={style}
        docked={docked}
        open={open}
        onRequestChange={onRequestChangeNavDrawer}
        containerStyle={{zIndex: zIndex.drawer - 100}}
      >
        <div style={styles.logo} onTouchTap={this.handleTouchTapHeader}>
          <FontIcon className="material-icons"><NavigationClose color={darkWhite} /></FontIcon>
          &nbsp;&nbsp;Internet of Things
        </div>

        <SelectableList
          value={location.pathname}
          onChange={onChangeList}
        >
          <ListItem
            primaryText="Home"
            value="/"
            href="#"
          />
          <ListItem
            primaryText="Getting Started"
            value="/getstarted/intro"
            href="#/getstarted/intro"
          />
          <ListItem
            primaryText="For Teachers"
            primaryTogglesNestedList={true}
            value="/teachers/intro"
            href="#/teachers/intro"
            nestedItems={[
              <ListItem
                primaryText="Tutorials"
                value="/teachers/tutorials"
                href="#/teachers/tutorials"
              />,
              <ListItem
{'fraction_non_alphanumeric': 0.15064372518349176, 'fraction_numerical': 0.003850318854530141, 'mean_word_length': 2.1389728096676737, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '897521', 'n_tokens_mistral': 2598, 'n_tokens_neox': 2544, 'n_words': 443}