1
1
import React , { Component } from 'react' ;
2
2
import { Helmet } from 'react-helmet' ;
3
- import { Grid , Row , Col } from 'react-bootstrap' ;
3
+ import { Grid , Row , Col , Modal } from 'react-bootstrap' ;
4
4
import SplitPane from 'react-split-pane' ;
5
5
import Sidebar from './components/Sidebar' ;
6
6
import QueryBox from './components/QueryBox' ;
@@ -20,14 +20,23 @@ class App extends Component {
20
20
) as t
21
21
GROUP BY committer_email, month, repo_id` ,
22
22
results : new Map ( ) ,
23
- schema : undefined
23
+ schema : undefined ,
24
+
25
+ // modal
26
+ showModal : false ,
27
+ modalTitle : null ,
28
+ modalContent : null
24
29
} ;
25
30
26
31
this . handleTextChange = this . handleTextChange . bind ( this ) ;
27
32
this . handleSubmit = this . handleSubmit . bind ( this ) ;
28
33
this . handleRemoveResult = this . handleRemoveResult . bind ( this ) ;
29
34
this . handleTableClick = this . handleTableClick . bind ( this ) ;
30
35
this . handleExampleClick = this . handleExampleClick . bind ( this ) ;
36
+ this . handleModalClose = this . handleModalClose . bind ( this ) ;
37
+
38
+ this . showCode = this . showCode . bind ( this ) ;
39
+ this . showUAST = this . showUAST . bind ( this ) ;
31
40
32
41
this . uniqueKey = 0 ;
33
42
}
@@ -97,6 +106,26 @@ GROUP BY committer_email, month, repo_id`,
97
106
} ) ;
98
107
}
99
108
109
+ handleModalClose ( ) {
110
+ this . setState ( { showModal : false , modalTitle : null , modalContent : null } ) ;
111
+ }
112
+
113
+ showCode ( code ) {
114
+ this . setState ( {
115
+ showModal : true ,
116
+ modalTitle : 'Source code' ,
117
+ modalContent : < pre > { code } </ pre >
118
+ } ) ;
119
+ }
120
+
121
+ showUAST ( uast ) {
122
+ this . setState ( {
123
+ showModal : true ,
124
+ modalTitle : 'UAST' ,
125
+ modalContent : < pre > { JSON . stringify ( uast , null , 2 ) } </ pre >
126
+ } ) ;
127
+ }
128
+
100
129
componentDidMount ( ) {
101
130
this . loadSchema ( ) ;
102
131
}
@@ -119,6 +148,8 @@ GROUP BY committer_email, month, repo_id`,
119
148
results = { results }
120
149
handleRemoveResult = { this . handleRemoveResult }
121
150
handleEditQuery = { this . handleTextChange }
151
+ showCode = { this . showCode }
152
+ showUAST = { this . showUAST }
122
153
/>
123
154
</ Col >
124
155
) ;
@@ -159,6 +190,16 @@ GROUP BY committer_email, month, repo_id`,
159
190
</ Col >
160
191
</ Row >
161
192
</ Grid >
193
+ < Modal
194
+ show = { this . state . showModal }
195
+ onHide = { this . handleModalClose }
196
+ bsSize = "large"
197
+ >
198
+ < Modal . Header closeButton >
199
+ < Modal . Title > { this . state . modalTitle } </ Modal . Title >
200
+ </ Modal . Header >
201
+ < Modal . Body > { this . state . modalContent } </ Modal . Body >
202
+ </ Modal >
162
203
</ div >
163
204
) ;
164
205
}
0 commit comments