1+ 'use strict' ;
2+
3+ Object . defineProperty ( exports , "__esModule" , {
4+ value : true
5+ } ) ;
6+
7+ var _extends2 = require ( 'babel-runtime/helpers/extends' ) ;
8+
9+ var _extends3 = _interopRequireDefault ( _extends2 ) ;
10+
11+ var _getPrototypeOf = require ( 'babel-runtime/core-js/object/get-prototype-of' ) ;
12+
13+ var _getPrototypeOf2 = _interopRequireDefault ( _getPrototypeOf ) ;
14+
15+ var _classCallCheck2 = require ( 'babel-runtime/helpers/classCallCheck' ) ;
16+
17+ var _classCallCheck3 = _interopRequireDefault ( _classCallCheck2 ) ;
18+
19+ var _createClass2 = require ( 'babel-runtime/helpers/createClass' ) ;
20+
21+ var _createClass3 = _interopRequireDefault ( _createClass2 ) ;
22+
23+ var _possibleConstructorReturn2 = require ( 'babel-runtime/helpers/possibleConstructorReturn' ) ;
24+
25+ var _possibleConstructorReturn3 = _interopRequireDefault ( _possibleConstructorReturn2 ) ;
26+
27+ var _inherits2 = require ( 'babel-runtime/helpers/inherits' ) ;
28+
29+ var _inherits3 = _interopRequireDefault ( _inherits2 ) ;
30+
31+ var _react = require ( 'react' ) ;
32+
33+ var _react2 = _interopRequireDefault ( _react ) ;
34+
35+ var _reactDom = require ( 'react-dom' ) ;
36+
37+ var _reactDom2 = _interopRequireDefault ( _reactDom ) ;
38+
39+ var _ActionListRow = require ( './ActionListRow' ) ;
40+
41+ var _ActionListRow2 = _interopRequireDefault ( _ActionListRow ) ;
42+
43+ var _ActionListHeader = require ( './ActionListHeader' ) ;
44+
45+ var _ActionListHeader2 = _interopRequireDefault ( _ActionListHeader ) ;
46+
47+ function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
48+
49+ function getTimestamps ( actions , actionIds , actionId ) {
50+ var idx = actionIds . indexOf ( actionId ) ;
51+ var prevActionId = actionIds [ idx - 1 ] ;
52+
53+ return {
54+ current : actions [ actionId ] . timestamp ,
55+ previous : idx ? actions [ prevActionId ] . timestamp : 0
56+ } ;
57+ }
58+
59+ var ActionList = function ( _PureComponent ) {
60+ ( 0 , _inherits3 . default ) ( ActionList , _PureComponent ) ;
61+
62+ function ActionList ( ) {
63+ ( 0 , _classCallCheck3 . default ) ( this , ActionList ) ;
64+ return ( 0 , _possibleConstructorReturn3 . default ) ( this , ( ActionList . __proto__ || ( 0 , _getPrototypeOf2 . default ) ( ActionList ) ) . apply ( this , arguments ) ) ;
65+ }
66+
67+ ( 0 , _createClass3 . default ) ( ActionList , [ {
68+ key : 'componentDidMount' ,
69+ value : function componentDidMount ( ) {
70+ this . scrollToBottom ( true ) ;
71+ }
72+ } , {
73+ key : 'componentDidUpdate' ,
74+ value : function componentDidUpdate ( prevProps ) {
75+ if ( this . props . lastActionId !== prevProps . lastActionId ) {
76+ this . scrollToBottom ( ) ;
77+ }
78+ }
79+ } , {
80+ key : 'scrollToBottom' ,
81+ value : function scrollToBottom ( force ) {
82+ var el = _reactDom2 . default . findDOMNode ( this . refs . rows ) ;
83+ var scrollHeight = el . scrollHeight ;
84+ if ( force || Math . abs ( scrollHeight - ( el . scrollTop + el . offsetHeight ) ) < 50 ) {
85+ el . scrollTop = scrollHeight ;
86+ }
87+ }
88+ } , {
89+ key : 'render' ,
90+ value : function render ( ) {
91+ var _props = this . props ,
92+ styling = _props . styling ,
93+ actions = _props . actions ,
94+ actionIds = _props . actionIds ,
95+ isWideLayout = _props . isWideLayout ,
96+ onToggleAction = _props . onToggleAction ,
97+ skippedActionIds = _props . skippedActionIds ,
98+ selectedActionId = _props . selectedActionId ,
99+ startActionId = _props . startActionId ,
100+ onSelect = _props . onSelect ,
101+ onSearch = _props . onSearch ,
102+ searchValue = _props . searchValue ,
103+ currentActionId = _props . currentActionId ,
104+ onCommit = _props . onCommit ,
105+ onSweep = _props . onSweep ,
106+ onJumpToState = _props . onJumpToState ;
107+
108+ var lowerSearchValue = searchValue && searchValue . toLowerCase ( ) ;
109+ var filteredActionIds = searchValue ? actionIds . filter ( function ( id ) {
110+ return actions [ id ] . action . type . toLowerCase ( ) . indexOf ( lowerSearchValue ) !== - 1 ;
111+ } ) : actionIds ;
112+
113+ return _react2 . default . createElement (
114+ 'div' ,
115+ ( 0 , _extends3 . default ) ( {
116+ key : 'actionList'
117+ } , styling ( [ 'actionList' , isWideLayout ? 'actionListWide' : null ] , isWideLayout ) ) ,
118+ _react2 . default . createElement ( _ActionListHeader2 . default , { styling : styling ,
119+ onSearch : onSearch ,
120+ onCommit : onCommit ,
121+ onSweep : onSweep ,
122+ hasSkippedActions : skippedActionIds . length > 0 ,
123+ hasStagedActions : actionIds . length > 1 } ) ,
124+ _react2 . default . createElement (
125+ 'div' ,
126+ ( 0 , _extends3 . default ) ( { } , styling ( 'actionListRows' ) , { ref : 'rows' } ) ,
127+ filteredActionIds . map ( function ( actionId ) {
128+ return _react2 . default . createElement ( _ActionListRow2 . default , { key : actionId ,
129+ styling : styling ,
130+ isInitAction : ! actionId ,
131+ isSelected : startActionId !== null && actionId >= startActionId && actionId <= selectedActionId || actionId === selectedActionId ,
132+ isInFuture : actionId > currentActionId ,
133+ onSelect : function ( _onSelect ) {
134+ function onSelect ( _x ) {
135+ return _onSelect . apply ( this , arguments ) ;
136+ }
137+
138+ onSelect . toString = function ( ) {
139+ return _onSelect . toString ( ) ;
140+ } ;
141+
142+ return onSelect ;
143+ } ( function ( e ) {
144+ return onSelect ( e , actionId ) ;
145+ } ) ,
146+ timestamps : getTimestamps ( actions , actionIds , actionId ) ,
147+ action : actions [ actionId ] . action ,
148+ onToggleClick : function onToggleClick ( ) {
149+ return onToggleAction ( actionId ) ;
150+ } ,
151+ onJumpClick : function onJumpClick ( ) {
152+ return onJumpToState ( actionId ) ;
153+ } ,
154+ onCommitClick : function onCommitClick ( ) {
155+ return onCommit ( actionId ) ;
156+ } ,
157+ isSkipped : skippedActionIds . indexOf ( actionId ) !== - 1 } ) ;
158+ } )
159+ )
160+ ) ;
161+ }
162+ } ] ) ;
163+ return ActionList ;
164+ } ( _react . PureComponent ) ;
165+
166+ exports . default = ActionList ;
0 commit comments