@@ -5,6 +5,8 @@ import activityRecord from 'browser/lib/activityRecord'
55import _ from 'lodash'
66import Commander from 'browser/main/lib/Commander'
77import dataApi from 'browser/main/lib/dataApi'
8+ import modal from 'browser/main/lib/modal'
9+ import NewNoteModal from 'browser/main/modals/NewNoteModal'
810
911const OSX = window . process . platform === 'darwin'
1012
@@ -33,77 +35,62 @@ class TopBar extends React.Component {
3335 }
3436
3537 handleNewPostButtonClick ( e ) {
36- let { storages, params, dispatch } = this . props
38+ let { storages, params, dispatch, location } = this . props
3739 let storage = _ . find ( storages , { key : params . storageKey } )
3840 if ( storage == null ) storage = storages [ 0 ]
3941 if ( storage == null ) throw new Error ( 'No storage to create a note' )
4042 let folder = _ . find ( storage . folders , { key : params . folderKey } )
4143 if ( folder == null ) folder = storage . folders [ 0 ]
4244 if ( folder == null ) throw new Error ( 'No folder to craete a note' )
43- // activityRecord.emit('ARTICLE_CREATE')
44- console . log ( storage , folder )
45- dataApi
46- . createNote ( storage . key , folder . key , {
47- title : '' ,
48- content : ''
49- } )
50- . then ( ( note ) => {
51- dispatch ( {
52- type : 'CREATE_NOTE' ,
53- note : note
54- } )
55- } )
45+
46+ modal . open ( NewNoteModal , {
47+ storage : storage . key ,
48+ folder : folder . key ,
49+ dispatch,
50+ location
51+ } )
5652 }
5753
5854 handleTutorialButtonClick ( e ) {
5955 }
6056
6157 render ( ) {
62- let { config } = this . props
58+ let { config, style } = this . props
6359 return (
6460 < div className = 'TopBar'
6561 styleName = { config . isSideNavFolded ? 'root--expanded' : 'root' }
62+ style = { style }
6663 >
67- < div styleName = 'left' >
68- < div styleName = 'left-search' >
69- < i styleName = 'left-search-icon' className = 'fa fa-search fa-fw' />
70- < input styleName = 'left-search-input'
71- ref = 'searchInput'
72- onFocus = { ( e ) => this . handleSearchChange ( e ) }
73- onBlur = { ( e ) => this . handleSearchChange ( e ) }
74- value = { this . state . search }
75- onChange = { ( e ) => this . handleSearchChange ( e ) }
76- placeholder = 'Search'
77- type = 'text'
78- />
64+ < div styleName = 'control' >
65+ < div styleName = 'control-search' >
66+ < i styleName = 'control-search-icon' className = 'fa fa-search fa-fw' />
67+ < div styleName = 'control-search-input' >
68+ < input
69+ ref = 'searchInput'
70+ onFocus = { ( e ) => this . handleSearchChange ( e ) }
71+ onBlur = { ( e ) => this . handleSearchChange ( e ) }
72+ value = { this . state . search }
73+ onChange = { ( e ) => this . handleSearchChange ( e ) }
74+ placeholder = 'Search'
75+ type = 'text'
76+ />
77+ </ div >
7978 { this . state . search > 0 &&
8079 < button styleName = 'left-search-clearButton'
8180 onClick = { ( e ) => this . handleSearchClearButton ( e ) }
8281 >
8382 < i className = 'fa fa-times' />
8483 </ button >
8584 }
86- </ div >
8785
88- < div styleName = 'left-control' >
89- < button styleName = 'left-control-newPostButton'
90- onClick = { ( e ) => this . handleNewPostButtonClick ( e ) } >
91- < i className = 'fa fa-plus' />
92- < span styleName = 'left-control-newPostButton-tooltip' >
93- New Note { OSX ? '⌘' : '^' } + n
94- </ span >
95- </ button >
9686 </ div >
97- </ div >
98-
99- < div styleName = 'right' >
100- < button styleName = 'right-helpButton'
101- onClick = { ( e ) => this . handleTutorialButtonClick ( e ) }
102- disabled
103- >
104- ?< span styleName = 'left-control-newPostButton-tooltip' > How to use</ span >
87+ < button styleName = 'control-newPostButton'
88+ onClick = { ( e ) => this . handleNewPostButtonClick ( e ) } >
89+ < i className = 'fa fa-plus' />
90+ < span styleName = 'control-newPostButton-tooltip' >
91+ New Note { OSX ? '⌘' : '^' } + n
92+ </ span >
10593 </ button >
106-
10794 </ div >
10895 </ div >
10996 )
0 commit comments