All files / src/components/pages/filesytem SelectedFsEntities.tsx

75% Statements 6/8
25% Branches 1/4
66.67% Functions 2/3
71.43% Lines 5/7

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 69 70 71 72 73 74 75              2x       2x       2x             1x                                                                                               1x        
import { SystemState } from "../../../background/redux/actions/sytemState";
import { connect, ConnectedProps } from "react-redux";
import React, { ReactElement } from "react";
import { OverlayTrigger, Tooltip } from "react-bootstrap";
import { FsEntity } from "../../../background/api/filesystemTypes";
import { clearSelected } from "../../../background/redux/actions/filesystem";
 
const mapState = (state: SystemState) => ({
  selectedFsEnties: state.filesystem.selectedFsEnties
});
 
const mapDispatch = {
  clearSelected
};
 
const connector = connect(mapState, mapDispatch);
 
type PropsFromRedux = ConnectedProps<typeof connector>;
 
type Props = PropsFromRedux & {};
 
function SelectedFsEntities(props: Props): ReactElement {
  Iif (props.selectedFsEnties?.length > 0)
    return (
      <div className={"pt-3"}>
        <OverlayTrigger
          placement={"bottom"}
          overlay={
            <Tooltip id={`tooltip-bottom`} className={""}>
              <ul className={"list-group"}>
                {props.selectedFsEnties.map((e: FsEntity) => {
                  return (
                    <li
                      className={"list-group-item list-group-item-dark"}
                      key={e.fileSystemId}
                    >
                      {e.path}
                    </li>
                  );
                })}
              </ul>
            </Tooltip>
          }
        >
          <span className={"pr-2"}>
            Selected {props.selectedFsEnties.length} file
            {props.selectedFsEnties.length > 1 ? "s" : ""}
          </span>
        </OverlayTrigger>
        <OverlayTrigger
          placement={"bottom"}
          overlay={
            <Tooltip id={`tooltip-bottom`} className={"bg-light text-dark m-1"}>
              Clear the selection
            </Tooltip>
          }
        >
          <button
            type="button"
            aria-label="Close"
            className={"close mr-2 text-primary"}
            onClick={props.clearSelected}
          >
            <span className={"text-shadow-none"} aria-hidden="true">
              &times;
            </span>
          </button>
        </OverlayTrigger>
      </div>
    );
  else return <span></span>;
}
 
export default connector(SelectedFsEntities);