<commit_before>import React from "react";
import { connect } from "react-redux";
import Drawer from "material-ui/Drawer";
import AppBar from "material-ui/AppBar";
import MenuItem from "material-ui/MenuItem";
import Download from "material-ui/svg-icons/file/file-download";
import ExitToApp from "material-ui/svg-icons/action/exit-to-app";
import Save from "material-ui/svg-icons/content/save";
import Lock from "material-ui/svg-icons/action/lock";
import LockOpen from "material-ui/svg-icons/action/lock-open";
import Divider from "material-ui/Divider";
import {
  exportMarkdown,
  setDrawerVisibility,
  logout,
  toggleEncryption,
  showChangePassword,
  showSetPassword,
  showRemovePassword,
  readAbout,
  toggleDrawer,
  uploadToDropbox
} from "../actionCreators";
import {
  isLoggedIn,
  isEncrypted,
  shouldShowDrawer,
  isUploading,
  isDirty
} from "../accessors";

// TODO: Support loading indicator to the right of "Save to Dropbox"
const JournalDrawer = props => (
  <Drawer
    open={props.showDrawer}
    docked={false}
    onRequestChange={props.setDrawerVisibility}
  >
    <AppBar
      title="Options"
      iconElementLeft={<span />}
      onTouchTap={props.toggleDrawer}
    />
    {/* TODO Make icon grey if saving/not dirty */}
    <MenuItem
      key="save"
      leftIcon={
        (
          <Save
            color={
              !props.isDirty || props.isUploading
                ? "rgba(0, 0, 0, 0.298039)"
                : null
            }
          />
        )
      }
      onClick={props.uploadToDropbox}
      disabled={props.isUploading || !props.isDirty}
    >
      {/* TODO Nested ternary statements?? Are you crazy?? */}
      {props.isUploading
        ? "Saving..."
        : !props.isDirty ? "All changes saved" : "Save"}
    </MenuItem>
    <Divider />
    {props.isEncrypted &&
      <MenuItem
        key="update"
        leftIcon={<Lock />}
        onClick={props.showChangePassword}
      >
        Update Password
      </MenuItem>}
    {props.isEncrypted
      ? <MenuItem
          key="remove"
          leftIcon={<LockOpen />}
          onClick={props.showRemovePassword}
        >
          Remove Encryption
        </MenuItem>
      : <MenuItem leftIcon={<Lock />} onClick={props.showSetPassword}>
          Encrypt
        </MenuItem>}
    <MenuItem leftIcon={<Download />} onClick={props.exportMarkdown}>
      Export (.md)
    </MenuItem>
    <Divider />
    <MenuItem leftIcon={<ExitToApp />} onClick={props.logout}>
      Logout
    </MenuItem>
    <Divider />
    <MenuItem onTouchTap={props.readAbout}><commit_msg>Prefer onTouchTap to onClick<commit_after>import React from "react";
import { connect } from "react-redux";
import Drawer from "material-ui/Drawer";
import AppBar from "material-ui/AppBar";
import MenuItem from "material-ui/MenuItem";
import Download from "material-ui/svg-icons/file/file-download";
import ExitToApp from "material-ui/svg-icons/action/exit-to-app";
import Save from "material-ui/svg-icons/content/save";
import Lock from "material-ui/svg-icons/action/lock";
import LockOpen from "material-ui/svg-icons/action/lock-open";
import Divider from "material-ui/Divider";
import {
  exportMarkdown,
  setDrawerVisibility,
  logout,
  toggleEncryption,
  showChangePassword,
  showSetPassword,
  showRemovePassword,
  readAbout,
  toggleDrawer,
  uploadToDropbox
} from "../actionCreators";
import {
  isLoggedIn,
  isEncrypted,
  shouldShowDrawer,
  isUploading,
  isDirty
} from "../accessors";

// TODO: Support loading indicator to the right of "Save to Dropbox"
const JournalDrawer = props => (
  <Drawer
    open={props.showDrawer}
    docked={false}
    onRequestChange={props.setDrawerVisibility}
  >
    <AppBar
      title="Options"
      iconElementLeft={<span />}
      onTouchTap={props.toggleDrawer}
    />
    {/* TODO Make icon grey if saving/not dirty */}
    <MenuItem
      key="save"
      leftIcon={
        (
          <Save
            color={
              !props.isDirty || props.isUploading
                ? "rgba(0, 0, 0, 0.298039)"
                : null
            }
          />
        )
      }
      onClick={props.uploadToDropbox}
      disabled={props.isUploading || !props.isDirty}
    >
      {/* TODO Nested ternary statements?? Are you crazy?? */}
      {props.isUploading
        ? "Saving..."
        : !props.isDirty ? "All changes saved" : "Save"}
    </MenuItem>
    <Divider />
    {props.isEncrypted &&
      <MenuItem
        key="update"
        leftIcon={<Lock />}
        onClick={props.showChangePassword}
      >
        Update Password
      </MenuItem>}
    {props.isEncrypted
      ? <MenuItem
          key="remove"
          leftIcon={<LockOpen />}
          onTouchTap={props.showRemovePassword}
        >
          Remove Encryption
        </MenuItem>
      : <MenuItem leftIcon={<Lock />} onTouchTap={props.showSetPassword}>
          Encrypt
        </MenuItem>}
    <MenuItem leftIcon={<Download />} onTouchTap={props.exportMarkdown}>
      Export (.md)
    </MenuItem>
    <Divider />
    <MenuItem leftIcon={<ExitToApp />} onTouchTap={props.logout}>
      Logout
    </MenuItem>
    <Divider />
    <MenuItem onTouchTap={props.readAbout}>
{'fraction_non_alphanumeric': 0.12810155799192152, 'fraction_numerical': 0.0038468936333910368, 'mean_word_length': 2.5230352303523036, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5978884', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1598, 'n_words': 324}