<commit_before>import React from 'react';
import { connect } from 'react-redux';
import { IconMenu, IconButton, MenuItem } from 'material-ui';
import muiThemeable from 'material-ui/styles/muiThemeable';
import { Print as PrintIcon, Export as ExportIcon, ViewVisible as ViewVisibleIcon, ViewHidden as ViewHiddenIcon, MoreHorizontal as MoreHorizontalIcon } from 'emerald-js-ui/lib/icons3';
import { api } from 'lib/rpc/api';
import saveAs from 'lib/saveAs';
import screen from '../../../store/wallet/screen';
import history from '../../../store/wallet/history';
import accounts from '../../../store/vault/accounts';

const hasBalance = (account) => (account.get('balance', null) === null) ||
  (account.get('balance') && account.get('balance').value().gt(0));

const renderHide = (chain, account, onHide, { disabledColor }) => {
  const disabled = hasBalance(account);
  const iconStyle = disabled ? {
    color: disabledColor,
  } : null;
  return (
    <MenuItem
      disabled={ disabled }
      leftIcon={<ViewHiddenIcon style={iconStyle} />}
      primaryText='HIDE'
      onClick={ onHide(chain) }/>
  );
};

const renderUnhide = (chain, account, onUnhide) => {
  return (
    <MenuItem
      leftIcon={<ViewVisibleIcon />}
      primaryText='UNHIDE'
      onClick={ onUnhide(chain) }/>
  );
};

export const SecondaryMenu = ({ account, onPrint, onExport, onHide, onUnhide, chain, muiTheme }) => {
  const colors = {
    textColor: muiTheme.palette.textColor,
    disabledColor: muiTheme.palette.disabledColor,
  };
  const isHardware = account.get('hardware', false);
  return (
    <IconMenu iconButtonElement={<IconButton><MoreHorizontalIcon /></IconButton>}>
      {!isHardware &&
            <MenuItem
              leftIcon={<ExportIcon />}
              primaryText='EXPORT'
              onTouchTap={ onExport(chain) }/> }
      {!isHardware &&
            <MenuItem
              leftIcon={<PrintIcon />}
              primaryText='PRINT'
              onTouchTap={ onPrint(chain) }/> }

      { !account.get('hidden') && renderHide(chain, account, onHide, colors) }
      { account.get('hidden') && renderUnhide(chain, account, onUnhide) }

    </IconMenu>
  );
};

export default connect(
  (state, ownProps) => ({
    chain: state.launcher.getIn(['chain', 'name']),
  }),
  (dispatch, ownProps) => ({
    onPrint: (chain) => () => {
      const address = ownProps.account.get('id');
      dispatch(screen.actions.gotoScreen('export-paper-wallet', address));
    },
    onHide: (chain) => () => {
      const address = ownProps.account.get('id');
      dispatch(screen.actions.showDialog('hide-account', address));
    },
    onUnhide: (chain) => () => {
      const address = ownProps.account.get('id');
      dispatch(accounts.actions.unhideAccount(address));
      // refresh account data
      dispatch(history.actions.refreshTrackedTransactions());
      dispatch(accounts.actions.loadAccountsList());
      dispatch(accounts.actions.loadPendingTransactions());<commit_msg>Problem: Overlapping Menu #611<commit_after>import React from 'react';
import { connect } from 'react-redux';
import { IconMenu, IconButton, MenuItem } from 'material-ui';
import muiThemeable from 'material-ui/styles/muiThemeable';
import { Print as PrintIcon, Export as ExportIcon, ViewVisible as ViewVisibleIcon, ViewHidden as ViewHiddenIcon, MoreHorizontal as MoreHorizontalIcon } from 'emerald-js-ui/lib/icons3';
import { api } from 'lib/rpc/api';
import saveAs from 'lib/saveAs';
import screen from '../../../store/wallet/screen';
import history from '../../../store/wallet/history';
import accounts from '../../../store/vault/accounts';

const hasBalance = (account) => (account.get('balance', null) === null) ||
  (account.get('balance') && account.get('balance').value().gt(0));

const renderHide = (chain, account, onHide, { disabledColor }) => {
  const disabled = hasBalance(account);
  const iconStyle = disabled ? {
    color: disabledColor,
  } : null;
  return (
    <MenuItem
      disabled={ disabled }
      leftIcon={<ViewHiddenIcon style={iconStyle} />}
      primaryText='HIDE'
      onClick={ onHide(chain) }/>
  );
};

const renderUnhide = (chain, account, onUnhide) => {
  return (
    <MenuItem
      leftIcon={<ViewVisibleIcon />}
      primaryText='UNHIDE'
      onClick={ onUnhide(chain) }/>
  );
};

export const SecondaryMenu = ({ account, onPrint, onExport, onHide, onUnhide, chain, muiTheme }) => {
  const colors = {
    textColor: muiTheme.palette.textColor,
    disabledColor: muiTheme.palette.disabledColor,
  };
  const isHardware = account.get('hardware', false);
  return (
    <IconMenu useLayerForClickAway={true} iconButtonElement={<IconButton><MoreHorizontalIcon /></IconButton>}>
      {!isHardware &&
       <MenuItem
         leftIcon={<ExportIcon />}
         primaryText='EXPORT'
         onTouchTap={ onExport(chain) }/> }
      {!isHardware &&
       <MenuItem
         leftIcon={<PrintIcon />}
         primaryText='PRINT'
         onTouchTap={ onPrint(chain) }/> }

      { !account.get('hidden') && renderHide(chain, account, onHide, colors) }
      { account.get('hidden') && renderUnhide(chain, account, onUnhide) }

    </IconMenu>
  );
};

export default connect(
  (state, ownProps) => ({
    chain: state.launcher.getIn(['chain', 'name']),
  }),
  (dispatch, ownProps) => ({
    onPrint: (chain) => () => {
      const address = ownProps.account.get('id');
      dispatch(screen.actions.gotoScreen('export-paper-wallet', address));
    },
    onHide: (chain) => () => {
      const address = ownProps.account.get('id');
      dispatch(screen.actions.showDialog('hide-account', address));
    },
    onUnhide: (chain) => () => {
      const address = ownProps.account.get('id');
      dispatch(accounts.actions.unhideAccount(address));
      // refresh account data
      dispatch(history.actions.refreshTrackedTransactions());
      dispatch(accounts.actions.loadAccountsList());
      dispatch(accounts.actions.loadPendingTransactions());
{'fraction_non_alphanumeric': 0.1614087798364213, 'fraction_numerical': 0.0011684192956100817, 'mean_word_length': 3.4883895131086144, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 53, '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': '4888448', 'n_tokens_mistral': 1788, 'n_tokens_neox': 1788, 'n_words': 365}