1
/* eslint-disable react/prop-types */
2

3 1
import React from 'react';
4 1
import { connect } from 'react-redux';
5

6 1
import * as actions from './actions';
7
import { State as NodeState } from './reducers/nodes';
8
import { State } from './reducers';
9

10 1
import ExplorerPanel from './ExplorerPanel';
11

12
interface ExplorerProps {
13
  isVisible: boolean;
14
  depth: number,
15
  currentPageId: number | null,
16
  nodes: NodeState,
17
  onClose(): void;
18
  popPage(): void;
19
  gotoPage(id: number, transition: number): void;
20
}
21

22 1
const Explorer: React.FunctionComponent<ExplorerProps> = ({
23 1
  isVisible,
24 1
  depth,
25 1
  currentPageId,
26 1
  nodes,
27 1
  gotoPage,
28 1
  onClose,
29 1
}) => ((isVisible && currentPageId) ? (
30 1
  <ExplorerPanel
31
    depth={depth}
32
    page={nodes[currentPageId]}
33
    nodes={nodes}
34
    gotoPage={gotoPage}
35
    onClose={onClose}
36
  />
37 1
) : null);
38

39 1
const mapStateToProps = (state: State) => ({
40
  isVisible: state.explorer.isVisible,
41
  depth: state.explorer.depth,
42
  currentPageId: state.explorer.currentPageId,
43
  nodes: state.nodes,
44
});
45

46 1
const mapDispatchToProps = (dispatch) => ({
47 1
  gotoPage: (id: number, transition: number) => dispatch(actions.gotoPage(id, transition)),
48 1
  onClose: () => dispatch(actions.closeExplorer()),
49
});
50

51 1
export default connect(mapStateToProps, mapDispatchToProps)(Explorer);

Read our documentation on viewing source code .

Loading