All files / src/components SnackbarCopy.js

100% Statements 10/10
100% Branches 0/0
100% Functions 6/6
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68                                      11x   11x         1x               2x                     4x           4x 8x 1x       4x 9x                  
import React, { Component } from "react";
import { connect } from "react-redux";
import {
  Snackbar,
  SnackbarContent,
  IconButton,
  withStyles
} from "@material-ui/core";
import { Close as CloseIcon } from "@material-ui/icons";
import {
  classesPropType,
  snackbarOpenPropType,
  toggleSnackbarPropType
} from "../proptypes";
import { toggleSnackbar as toggleSnackbarAction } from "../redux/actions/datatableActions";
import { customVariant } from "./MuiTheme";
 
export class SnackbarCopy extends Component {
  render() {
    const { snackbarOpen, toggleSnackbar, classes } = this.props;
 
    return (
      <Snackbar
        anchorOrigin={{ vertical: "bottom", horizontal: "left" }}
        open={snackbarOpen}
        autoHideDuration={2500}
        onClose={() => toggleSnackbar(false)}
      >
        <SnackbarContent
          className={classes.infoSnackbar}
          message={<span>Cell's content has been copied to clipboard.</span>}
          action={
            <IconButton
              className="close-snackbar-icon"
              onClick={() => toggleSnackbar(false)}
            >
              <CloseIcon className={classes.whiteIcon} />
            </IconButton>
          }
        />
      </Snackbar>
    );
  }
}
 
SnackbarCopy.propTypes = {
  classes: classesPropType.isRequired,
  snackbarOpen: snackbarOpenPropType.isRequired,
  toggleSnackbar: toggleSnackbarPropType
};
 
const mapDispatchToProps = dispatch => {
  return {
    toggleSnackbar: bool => dispatch(toggleSnackbarAction(bool))
  };
};
 
const mapStateToProps = state => {
  return {
    snackbarOpen: state.datatableReducer.snackbarOpen
  };
};
 
export default connect(
  mapStateToProps,
  mapDispatchToProps
)(withStyles(customVariant)(SnackbarCopy));