@@ -11,18 +11,16 @@ import 'axios-progress-bar/dist/nprogress.css';
1111import {
1212 CodeEditor ,
1313 Header ,
14- MarkdownViewer ,
1514 Navigator ,
1615 ResizableContainer ,
1716 TabContainer ,
1817 ToastContainer ,
1918 VisualizationViewer ,
2019} from '/components' ;
2120import { CategoryApi , GitHubApi } from '/apis' ;
22- import { tracerManager } from '/core' ;
2321import { actions } from '/reducers' ;
2422import { extension , refineGist } from '/common/util' ;
25- import { languages , exts , us } from '/common/config' ;
23+ import { exts , languages , us } from '/common/config' ;
2624import { README_MD , SCRATCH_PAPER_MD } from '/skeletons' ;
2725import styles from './stylesheet.scss' ;
2826
@@ -36,7 +34,6 @@ class App extends React.Component {
3634 this . state = {
3735 navigatorOpened : true ,
3836 workspaceWeights : [ 1 , 2 , 2 ] ,
39- viewerTabIndex : 0 ,
4037 editorTabIndex : - 1 ,
4138 } ;
4239 }
@@ -53,15 +50,11 @@ class App extends React.Component {
5350 CategoryApi . getCategories ( )
5451 . then ( ( { categories } ) => this . props . setCategories ( categories ) )
5552 . catch ( this . props . showErrorToast ) ;
56-
57- tracerManager . setOnError ( error => this . props . showErrorToast ( { name : error . name , message : error . message } ) ) ;
5853 }
5954
6055 componentWillUnmount ( ) {
6156 delete window . signIn ;
6257 delete window . signOut ;
63-
64- tracerManager . setOnError ( null ) ;
6558 }
6659
6760 componentWillReceiveProps ( nextProps ) {
@@ -172,10 +165,6 @@ class App extends React.Component {
172165 this . setState ( { workspaceWeights } ) ;
173166 }
174167
175- handleChangeViewerTabIndex ( viewerTabIndex ) {
176- this . setState ( { viewerTabIndex } ) ;
177- }
178-
179168 handleChangeEditorTabIndex ( editorTabIndex ) {
180169 const { files } = this . props . current ;
181170 if ( editorTabIndex === files . length ) this . handleAddFile ( ) ;
@@ -203,8 +192,11 @@ class App extends React.Component {
203192 handleDeleteFile ( file ) {
204193 const { files } = this . props . current ;
205194 const { editorTabIndex } = this . state ;
206- if ( files . indexOf ( file ) < editorTabIndex ) this . handleChangeEditorTabIndex ( editorTabIndex - 1 ) ;
207- else this . handleChangeEditorTabIndex ( Math . min ( editorTabIndex , files . length - 2 ) ) ;
195+ if ( files . indexOf ( file ) < editorTabIndex ) {
196+ this . handleChangeEditorTabIndex ( editorTabIndex - 1 ) ;
197+ } else {
198+ this . handleChangeEditorTabIndex ( Math . min ( editorTabIndex , files . length - 2 ) ) ;
199+ }
208200 this . props . deleteFile ( file ) ;
209201 }
210202
@@ -220,19 +212,21 @@ class App extends React.Component {
220212 serializeFiles ( files ) === serializeFiles ( lastFiles ) ;
221213 }
222214
215+ getDescription ( ) {
216+ const { files } = this . props . current ;
217+ const readmeFile = files . find ( file => file . name === 'README.md' ) ;
218+ if ( ! readmeFile ) return '' ;
219+ const groups = / ^ \s * # .* \n + ( [ ^ \n ] + ) / . exec ( readmeFile . content ) ;
220+ return groups && groups [ 1 ] || '' ;
221+ }
222+
223223 render ( ) {
224- const { navigatorOpened, workspaceWeights, viewerTabIndex , editorTabIndex } = this . state ;
224+ const { navigatorOpened, workspaceWeights, editorTabIndex } = this . state ;
225225 const { titles, files } = this . props . current ;
226226
227227 const gistSaved = this . isGistSaved ( ) ;
228228
229- const readmeFile = files . find ( file => file . name === 'README.md' ) || {
230- name : 'README.md' ,
231- content : `# ${ titles [ 1 ] } \nREADME.md not found` ,
232- contributors : [ us ] ,
233- } ;
234- const groups = / ^ \s * # .* \n + ( [ ^ \n ] + ) / . exec ( readmeFile . content ) ;
235- const description = groups && groups [ 1 ] || '' ;
229+ const description = this . getDescription ( ) ;
236230
237231 const editorTitles = files . map ( file => file . name ) ;
238232 if ( files [ editorTabIndex ] ) {
@@ -253,17 +247,13 @@ class App extends React.Component {
253247 </ Helmet >
254248 < Header className = { styles . header } onClickTitleBar = { ( ) => this . toggleNavigatorOpened ( ) }
255249 navigatorOpened = { navigatorOpened } loadScratchPapers = { ( ) => this . loadScratchPapers ( ) }
256- loadAlgorithm = { params => this . loadAlgorithm ( params ) }
257- onAction = { ( ) => this . handleChangeViewerTabIndex ( 1 ) } gistSaved = { gistSaved } />
250+ loadAlgorithm = { params => this . loadAlgorithm ( params ) } gistSaved = { gistSaved }
251+ file = { files [ editorTabIndex ] } />
258252 < ResizableContainer className = { styles . workspace } horizontal weights = { workspaceWeights }
259253 visibles = { [ navigatorOpened , true , true ] }
260254 onChangeWeights = { weights => this . handleChangeWorkspaceWeights ( weights ) } >
261255 < Navigator loadAlgorithm = { params => this . loadAlgorithm ( params ) } />
262- < TabContainer titles = { [ 'Description' , 'Visualization' ] } tabIndex = { viewerTabIndex }
263- onChangeTabIndex = { tabIndex => this . handleChangeViewerTabIndex ( tabIndex ) } >
264- < MarkdownViewer source = { readmeFile . content } />
265- < VisualizationViewer />
266- </ TabContainer >
256+ < VisualizationViewer className = { styles . visualization_viewer } />
267257 < TabContainer className = { styles . editor_tab_container } titles = { editorTitles } tabIndex = { editorTabIndex }
268258 onChangeTabIndex = { tabIndex => this . handleChangeEditorTabIndex ( tabIndex ) } >
269259 {
0 commit comments