11import React , { Component } from 'react' ;
2+
23import Header from '../Header' ;
34import Tab from '../Tab' ;
45import About from '../About' ;
6+ import JsonView from '../JsonView' ;
57
68import { editorTab , consoleTab , outputTab } from './tabs' ;
9+ import ContextMenu from '../ContextMenu' ;
710
811const MIN_WIDTH = 100 ;
912const MAX_WIDTH = 1400 ;
@@ -17,8 +20,10 @@ class App extends Component {
1720 this . state = {
1821 width : initialWidth ,
1922 rightWidth,
23+ position : null ,
2024 } ;
2125 this . resizer = React . createRef ( ) ;
26+ this . handleContextMenu = this . handleContextMenu . bind ( this ) ;
2227 }
2328
2429 componentDidMount ( ) {
@@ -50,8 +55,15 @@ class App extends Component {
5055 window . removeEventListener ( 'mouseup' , this . stopResize , false ) ;
5156 } ;
5257
58+ handleContextMenu = event => {
59+ event . preventDefault ( ) ;
60+ const { pageX, pageY } = event ;
61+ const position = { top : pageY , left : pageX } ;
62+ this . setState ( { position } ) ;
63+ } ;
64+
5365 render ( ) {
54- const { width, rightWidth } = this . state ;
66+ const { width, rightWidth, position } = this . state ;
5567
5668 return (
5769 < div className = "mainContainer" >
@@ -75,13 +87,15 @@ class App extends Component {
7587 < div style = { { minHeight : '50%' , height : '50%' } } >
7688 < Tab tabs = { outputTab } />
7789 </ div >
78- < div style = { { minHeight : '50%' , height : '50%' } } >
90+ < div onContextMenu = { this . handleContextMenu } style = { { minHeight : '50%' , height : '50%' } } >
7991 < Tab tabs = { consoleTab } />
8092 </ div >
8193 </ div >
8294 </ div >
8395
8496 < About />
97+ < JsonView />
98+ < ContextMenu position = { position } onClose = { ( ) => this . setState ( { position : null } ) } />
8599 </ div >
86100 ) ;
87101 }
0 commit comments