Skip to content

Commit 0c157be

Browse files
cwdickFacebook Github Bot 4
authored andcommitted
Move aggrow table header into its own component
Reviewed By: bnham Differential Revision: D3759285 fbshipit-source-id: befee1f060992ac8049042e4389d944d13bc3ae7
1 parent 8af84c6 commit 0c157be

File tree

2 files changed

+199
-171
lines changed

2 files changed

+199
-171
lines changed

local-cli/server/middleware/heapCapture/out/table.js

Lines changed: 106 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,104 @@ dropFilter:React.PropTypes.func.isRequired,
7575
dropAction:React.PropTypes.func.isRequired};var
7676

7777

78-
Table=function(_React$Component3){_inherits(Table,_React$Component3);// eslint-disable-line no-unused-vars
79-
function Table(props){_classCallCheck(this,Table);var _this3=_possibleConstructorReturn(this,Object.getPrototypeOf(Table).call(this,
78+
TableHeader=function(_React$Component3){_inherits(TableHeader,_React$Component3);
79+
function TableHeader(props){_classCallCheck(this,TableHeader);return _possibleConstructorReturn(this,Object.getPrototypeOf(TableHeader).call(this,
8080
props));
81-
_this3.state={
81+
}_createClass(TableHeader,[{key:'render',value:function render()
82+
{
83+
var aggrow=this.props.aggrow;
84+
var aggregators=aggrow.getActiveAggregators();
85+
var expanders=aggrow.getActiveExpanders();
86+
var headers=[];
87+
for(var i=0;i<aggregators.length;i++){
88+
var name=aggrow.getAggregatorName(aggregators[i]);
89+
headers.push(
90+
React.createElement(DropTarget,{
91+
id:'aggregate:insert:'+i.toString(),
92+
dropFilter:function dropFilter(s){return s.startsWith('aggregate');},
93+
dropAction:this.props.dropAction},
94+
95+
React.createElement('div',{style:{
96+
width:'16px',
97+
height:'inherit',
98+
backgroundColor:'darkGray',
99+
flexShrink:'0'}})));
100+
101+
102+
headers.push(React.createElement(Draggable,{id:'aggregate:active:'+i.toString()},
103+
React.createElement('div',{style:{width:'128px',textAlign:'center',flexShrink:'0'}},name)));
104+
105+
}
106+
headers.push(
107+
React.createElement(DropTarget,{
108+
id:'divider:insert',
109+
dropFilter:function dropFilter(s){return s.startsWith('aggregate')||s.startsWith('expander');},
110+
dropAction:this.props.dropAction},
111+
112+
React.createElement('div',{style:{
113+
width:'16px',
114+
height:'inherit',
115+
backgroundColor:'gold',
116+
flexShrink:'0'}})));
117+
118+
119+
for(var _i=0;_i<expanders.length;_i++){
120+
var _name=aggrow.getExpanderName(expanders[_i]);
121+
var bg=_i%2===0?'white':'lightGray';
122+
headers.push(React.createElement(Draggable,{id:'expander:active:'+_i.toString()},
123+
React.createElement('div',{style:{
124+
width:'128px',
125+
textAlign:'center',
126+
backgroundColor:bg,
127+
flexShrink:'0'}},
128+
129+
_name)));
130+
131+
132+
var sep=_i+1<expanders.length?'->':'...';
133+
headers.push(
134+
React.createElement(DropTarget,{
135+
id:'expander:insert:'+(_i+1).toString(),
136+
dropFilter:function dropFilter(){return true;},
137+
dropAction:this.props.dropAction},
138+
139+
React.createElement('div',{style:{
140+
height:'inherit',
141+
backgroundColor:'darkGray',
142+
flexShrink:'0'}},
143+
144+
sep)));
145+
146+
147+
148+
}
149+
return(
150+
React.createElement('div',{style:{
151+
width:'100%',
152+
height:'26px',
153+
display:'flex',
154+
flexDirection:'row',
155+
alignItems:'center',
156+
borderBottom:'2px solid black'}},
157+
158+
headers));
159+
160+
161+
}}]);return TableHeader;}(React.Component);
162+
163+
164+
TableHeader.propTypes={
165+
aggrow:React.PropTypes.object.isRequired,
166+
dropAction:React.PropTypes.func.isRequired};var
167+
168+
169+
Table=function(_React$Component4){_inherits(Table,_React$Component4);// eslint-disable-line no-unused-vars
170+
function Table(props){_classCallCheck(this,Table);var _this4=_possibleConstructorReturn(this,Object.getPrototypeOf(Table).call(this,
171+
props));
172+
_this4.state={
82173
aggrow:props.aggrow,
83174
viewport:{top:0,height:100},
84-
cursor:0};return _this3;
175+
cursor:0};return _this4;
85176

86177
}_createClass(Table,[{key:'scroll',value:function scroll(
87178

@@ -173,7 +264,7 @@ this._keepCursorInViewport();
173264
e.preventDefault();
174265
break;}
175266

176-
}},{key:'dropAggregator',value:function dropAggregator(
267+
}},{key:'dropAction',value:function dropAction(
177268

178269
s,d){
179270
var aggrow=this.state.aggrow;
@@ -219,95 +310,18 @@ this.setState({cursor:0});
219310
}
220311
}},{key:'render',value:function render()
221312

222-
{var _this4=this;
223-
var headers=[];
224-
var aggrow=this.state.aggrow;
225-
var aggregators=aggrow.getActiveAggregators();
226-
var expanders=aggrow.getActiveExpanders();
227-
// aggregators
228-
for(var i=0;i<aggregators.length;i++){
229-
var name=aggrow.getAggregatorName(aggregators[i]);
230-
headers.push(
231-
React.createElement(DropTarget,{
232-
id:'aggregate:insert:'+i.toString(),
233-
dropFilter:function dropFilter(){return true;},
234-
dropAction:function dropAction(s,d){_this4.dropAggregator(s,d);}},
235-
236-
React.createElement('div',{style:{
237-
width:'16px',
238-
height:'inherit',
239-
backgroundColor:'darkGray',
240-
flexShrink:'0'}})));
241-
242-
243-
headers.push(React.createElement(Draggable,{id:'aggregate:active:'+i.toString()},
244-
React.createElement('div',{style:{width:'128px',textAlign:'center',flexShrink:'0'}},name)));
245-
246-
}
247-
headers.push(
248-
React.createElement(DropTarget,{
249-
id:'divider:insert',
250-
dropFilter:function dropFilter(){return true;},
251-
dropAction:function dropAction(s,d){_this4.dropAggregator(s,d);}},
252-
253-
React.createElement('div',{style:{
254-
width:'16px',
255-
height:'inherit',
256-
backgroundColor:'gold',
257-
flexShrink:'0'}})));
258-
259-
260-
for(var _i=0;_i<expanders.length;_i++){
261-
var _name=aggrow.getExpanderName(expanders[_i]);
262-
var bg=_i%2===0?'white':'lightGray';
263-
headers.push(React.createElement(Draggable,{id:'expander:active:'+_i.toString()},
264-
React.createElement('div',{style:{
265-
width:'128px',
266-
textAlign:'center',
267-
backgroundColor:bg,
268-
flexShrink:'0'}},
269-
270-
_name)));
271-
272-
273-
var sep=_i+1<expanders.length?'->':'...';
274-
headers.push(
275-
React.createElement(DropTarget,{
276-
id:'expander:insert:'+(_i+1).toString(),
277-
dropFilter:function dropFilter(){return true;},
278-
dropAction:function dropAction(s,d){_this4.dropAggregator(s,d);}},
279-
280-
React.createElement('div',{style:{
281-
height:'inherit',
282-
backgroundColor:'darkGray',
283-
flexShrink:'0'}},
284-
285-
sep)));
286-
287-
288-
289-
}
290-
313+
{var _this5=this;
291314
return(
292315
React.createElement('div',{style:{width:'100%',height:'100%',display:'flex',flexDirection:'column'}},
293-
React.createElement('div',{style:{
294-
width:'100%',
295-
height:'26px',
296-
display:'flex',
297-
flexDirection:'row',
298-
alignItems:'center',
299-
borderBottom:'2px solid black'}},
300-
301-
headers),
302-
316+
React.createElement(TableHeader,{aggrow:this.state.aggrow,dropAction:function dropAction(s,d){return _this5.dropAction(s,d);}}),
303317
React.createElement('div',{
304318
style:{
305319
width:'100%',
306320
flexGrow:'1',
307321
overflow:'scroll'},
308322

309-
onScroll:function onScroll(e){return _this4.scroll(e);},
310-
ref:function ref(div){_this4._scrollDiv=div;}},
323+
onScroll:function onScroll(e){return _this5.scroll(e);},
324+
ref:function ref(div){_this5._scrollDiv=div;}},
311325
React.createElement('div',{style:{position:'relative'}},
312326
this.renderVirtualizedRows()))));
313327

@@ -316,7 +330,7 @@ this.renderVirtualizedRows()))));
316330

317331
}},{key:'renderVirtualizedRows',value:function renderVirtualizedRows()
318332

319-
{var _this5=this;
333+
{var _this6=this;
320334
var aggrow=this.state.aggrow;
321335
var viewport=this.state.viewport;
322336
var rows=aggrow.getRows(viewport.top,viewport.height);
@@ -326,12 +340,12 @@ position:'absolute',
326340
width:'100%',
327341
height:(rowHeight*(aggrow.getHeight()+20)).toString()+'px'}},
328342

329-
rows.map(function(child){return _this5.renderRow(child);})));
343+
rows.map(function(child){return _this6.renderRow(child);})));
330344

331345

332346
}},{key:'renderRow',value:function renderRow(
333347

334-
row){var _this6=this;
348+
row){var _this7=this;
335349
if(row===null){
336350
return null;
337351
}
@@ -385,7 +399,7 @@ width:'12px',
385399
textAlign:'center',
386400
border:'1px solid gray'},
387401

388-
onClick:function onClick(){return _this6._expandRow(row);}},'+'));
402+
onClick:function onClick(){return _this7._expandRow(row);}},'+'));
389403

390404

391405
}else if(aggrow.canContract(row)){
@@ -398,7 +412,7 @@ width:'12px',
398412
textAlign:'center',
399413
border:'1px solid gray'},
400414

401-
onClick:function onClick(){return _this6._contractRow(row);}},'-'));
415+
onClick:function onClick(){return _this7._contractRow(row);}},'-'));
402416

403417

404418
}else{
@@ -434,7 +448,7 @@ backgroundColor:bg,
434448
borderBottom:'1px solid gray'},
435449

436450
onClick:function onClick(){
437-
_this6.setState({cursor:row.top});
451+
_this7.setState({cursor:row.top});
438452
}},
439453
columns));
440454

0 commit comments

Comments
 (0)