Skip to content

Commit 8ef2db2

Browse files
committed
show uast using uast-viewer
Signed-off-by: Maxim Sukharev <[email protected]>
1 parent b93100b commit 8ef2db2

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

frontend/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"react-helmet": "^5.2.0",
1414
"react-scripts": "1.1.4",
1515
"react-split-pane": "^0.1.77",
16-
"react-table": "^6.8.2"
16+
"react-table": "^6.8.2",
17+
"uast-viewer": "^0.0.2"
1718
},
1819
"scripts": {
1920
"start": "react-app-rewired start",
@@ -33,8 +34,8 @@
3334
"prettier": "^1.12.1",
3435
"react-app-rewire-less": "^2.1.1",
3536
"react-app-rewired": "^1.5.2",
36-
"whatwg-url": "^6.4.1",
37-
"react-test-renderer": "^16.4.0"
37+
"react-test-renderer": "^16.4.0",
38+
"whatwg-url": "^6.4.1"
3839
},
3940
"proxy": {
4041
"/query": {

frontend/src/App.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React, { Component } from 'react';
22
import { Helmet } from 'react-helmet';
33
import { Grid, Row, Col, Modal } from 'react-bootstrap';
44
import SplitPane from 'react-split-pane';
5+
import UASTViewer, { transformer } from 'uast-viewer';
6+
import 'uast-viewer/dist/default-theme.css';
57
import Sidebar from './components/Sidebar';
68
import QueryBox from './components/QueryBox';
79
import TabbedResults from './components/TabbedResults';
@@ -125,7 +127,14 @@ FROM ( SELECT MONTH(committer_when) as month,
125127
this.setState({
126128
showModal: true,
127129
modalTitle: 'UAST',
128-
modalContent: <pre>{JSON.stringify(uast, null, 2)}</pre>
130+
modalContent:
131+
// currently github returns only 1 item, UAST of the file
132+
// but just in case if there is more or less we show it without viewer
133+
uast.length === 1 ? (
134+
<UASTViewer uast={transformer(uast[0])} />
135+
) : (
136+
<pre>{uast}</pre>
137+
)
129138
});
130139
}
131140

frontend/yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7021,6 +7021,10 @@ ua-parser-js@^0.7.9:
70217021
version "0.7.18"
70227022
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.18.tgz#a7bfd92f56edfb117083b69e31d2aa8882d4b1ed"
70237023

7024+
uast-viewer@^0.0.2:
7025+
version "0.0.2"
7026+
resolved "https://registry.yarnpkg.com/uast-viewer/-/uast-viewer-0.0.2.tgz#25dbd2649f51cff9380869d57c8edd813bb1e0b2"
7027+
70247028
[email protected], uglify-js@^3.0.13:
70257029
version "3.3.23"
70267030
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.3.23.tgz#48ea43e638364d18be292a6fdc2b5b7c35f239ab"

0 commit comments

Comments
 (0)