All files / publisher/release/actions history.js

100% Statements 13/13
92.85% Branches 13/14
100% Functions 4/4
100% Lines 13/13

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 556x 6x         6x             11x           4x 4x   4x                   2x 1x             2x   2x 2x             2x        
export const OPEN_HISTORY = "OPEN_HISTORY";
export const CLOSE_HISTORY = "CLOSE_HISTORY";
 
import { triggerGAEvent } from "../actions/gaEventTracking";
 
export function openHistory(filters) {
  return {
    type: OPEN_HISTORY,
    payload: { filters },
  };
}
 
export function closeHistory() {
  return {
    type: CLOSE_HISTORY,
  };
}
 
export function toggleHistory(filters) {
  return (dispatch, getState) => {
    const { history } = getState();
 
    if (
      history.isOpen &&
      (history.filters == filters ||
        (history.filters &&
          filters &&
          filters.track === history.filters.track &&
          filters.arch === history.filters.arch &&
          filters.risk === history.filters.risk &&
          filters.branch === history.filters.branch))
    ) {
      if (filters) {
        dispatch(
          triggerGAEvent(
            `click-close-history`,
            `${filters.track}/${filters.risk}/${filters.branch}/${filters.arch}`,
          ),
        );
      }
      dispatch(closeHistory());
    } else {
      Eif (filters) {
        dispatch(
          triggerGAEvent(
            `click-open-history`,
            `${filters.track}/${filters.risk}/${filters.branch}/${filters.arch}`,
          ),
        );
      }
      dispatch(openHistory(filters));
    }
  };
}