2017-11-06 20:35:04 +02:00
const React = require ( 'react' ) ;
const { connect } = require ( 'react-redux' ) ;
2020-07-03 23:32:39 +02:00
const { Header } = require ( '../Header/Header.min.js' ) ;
const { SideBar } = require ( '../SideBar/SideBar.min.js' ) ;
const { NoteList } = require ( '../NoteList/NoteList.min.js' ) ;
const NoteEditor = require ( '../NoteEditor/NoteEditor.js' ) . default ;
2020-04-09 19:57:20 +02:00
const { stateUtils } = require ( 'lib/reducer.js' ) ;
2020-07-03 23:32:39 +02:00
const { PromptDialog } = require ( '../PromptDialog.min.js' ) ;
const NoteContentPropertiesDialog = require ( '../NoteContentPropertiesDialog.js' ) . default ;
const NotePropertiesDialog = require ( '../NotePropertiesDialog.min.js' ) ;
const ShareNoteDialog = require ( '../ShareNoteDialog.js' ) . default ;
const InteropServiceHelper = require ( '../../InteropServiceHelper.js' ) ;
2017-12-14 20:12:14 +02:00
const Setting = require ( 'lib/models/Setting.js' ) ;
2020-05-02 17:41:07 +02:00
const { shim } = require ( 'lib/shim' ) ;
2020-06-10 23:08:59 +02:00
const { themeStyle } = require ( 'lib/theme.js' ) ;
2017-11-08 19:51:55 +02:00
const { _ } = require ( 'lib/locale.js' ) ;
const { bridge } = require ( 'electron' ) . remote . require ( './bridge' ) ;
2020-07-03 23:32:39 +02:00
const VerticalResizer = require ( '../VerticalResizer.min' ) ;
2019-04-01 21:43:13 +02:00
const PluginManager = require ( 'lib/services/PluginManager' ) ;
2020-03-13 19:42:50 +02:00
const EncryptionService = require ( 'lib/services/EncryptionService' ) ;
2020-07-03 23:32:39 +02:00
const CommandService = require ( 'lib/services/CommandService' ) . default ;
2020-04-09 19:57:20 +02:00
const ipcRenderer = require ( 'electron' ) . ipcRenderer ;
2020-05-02 17:41:07 +02:00
const { time } = require ( 'lib/time-utils.js' ) ;
2017-11-06 20:35:04 +02:00
2020-07-03 23:32:39 +02:00
const commands = [
require ( './commands/editAlarm' ) ,
require ( './commands/exportPdf' ) ,
require ( './commands/hideModalMessage' ) ,
require ( './commands/moveToFolder' ) ,
require ( './commands/newNote' ) ,
require ( './commands/newNotebook' ) ,
require ( './commands/newTodo' ) ,
require ( './commands/print' ) ,
require ( './commands/renameFolder' ) ,
require ( './commands/renameTag' ) ,
require ( './commands/search' ) ,
require ( './commands/selectTemplate' ) ,
require ( './commands/setTags' ) ,
require ( './commands/showModalMessage' ) ,
require ( './commands/showNoteContentProperties' ) ,
require ( './commands/showNoteProperties' ) ,
require ( './commands/showShareNoteDialog' ) ,
require ( './commands/toggleNoteList' ) ,
require ( './commands/toggleSidebar' ) ,
require ( './commands/toggleVisiblePanes' ) ,
] ;
2017-11-06 20:35:04 +02:00
class MainScreenComponent extends React . Component {
2018-09-16 20:37:31 +02:00
constructor ( ) {
super ( ) ;
2020-04-09 19:57:20 +02:00
this . state = {
promptOptions : null ,
modalLayer : {
visible : false ,
message : '' ,
} ,
notePropertiesDialogOptions : { } ,
noteContentPropertiesDialogOptions : { } ,
shareNoteDialogOptions : { } ,
} ;
2020-07-03 23:32:39 +02:00
this . registerCommands ( ) ;
2020-04-09 19:57:20 +02:00
this . setupAppCloseHandling ( ) ;
2020-07-03 23:32:39 +02:00
this . commandService _commandsEnabledStateChange = this . commandService _commandsEnabledStateChange . bind ( this ) ;
2018-09-16 20:37:31 +02:00
this . notePropertiesDialog _close = this . notePropertiesDialog _close . bind ( this ) ;
2020-02-25 11:43:31 +02:00
this . noteContentPropertiesDialog _close = this . noteContentPropertiesDialog _close . bind ( this ) ;
2019-12-13 03:16:34 +02:00
this . shareNoteDialog _close = this . shareNoteDialog _close . bind ( this ) ;
2019-02-16 03:12:43 +02:00
this . sidebar _onDrag = this . sidebar _onDrag . bind ( this ) ;
this . noteList _onDrag = this . noteList _onDrag . bind ( this ) ;
}
2020-04-09 19:57:20 +02:00
setupAppCloseHandling ( ) {
this . waitForNotesSavedIID _ = null ;
// This event is dispached from the main process when the app is about
// to close. The renderer process must respond with the "appCloseReply"
// and tell the main process whether the app can really be closed or not.
// For example, it cannot be closed right away if a note is being saved.
// If a note is being saved, we wait till it is saved and then call
// "appCloseReply" again.
ipcRenderer . on ( 'appClose' , ( ) => {
if ( this . waitForNotesSavedIID _ ) clearInterval ( this . waitForNotesSavedIID _ ) ;
this . waitForNotesSavedIID _ = null ;
ipcRenderer . send ( 'asynchronous-message' , 'appCloseReply' , {
canClose : ! this . props . hasNotesBeingSaved ,
} ) ;
if ( this . props . hasNotesBeingSaved ) {
this . waitForNotesSavedIID _ = setInterval ( ( ) => {
if ( ! this . props . hasNotesBeingSaved ) {
clearInterval ( this . waitForNotesSavedIID _ ) ;
this . waitForNotesSavedIID _ = null ;
ipcRenderer . send ( 'asynchronous-message' , 'appCloseReply' , {
canClose : true ,
} ) ;
}
} , 50 ) ;
}
} ) ;
}
2019-02-16 03:12:43 +02:00
sidebar _onDrag ( event ) {
Setting . setValue ( 'style.sidebar.width' , this . props . sidebarWidth + event . deltaX ) ;
}
noteList _onDrag ( event ) {
Setting . setValue ( 'style.noteList.width' , Setting . value ( 'style.noteList.width' ) + event . deltaX ) ;
2018-09-16 20:37:31 +02:00
}
notePropertiesDialog _close ( ) {
this . setState ( { notePropertiesDialogOptions : { } } ) ;
}
2020-02-25 11:43:31 +02:00
noteContentPropertiesDialog _close ( ) {
this . setState ( { noteContentPropertiesDialogOptions : { } } ) ;
}
2019-12-13 03:16:34 +02:00
shareNoteDialog _close ( ) {
this . setState ( { shareNoteDialogOptions : { } } ) ;
}
2020-07-03 23:32:39 +02:00
commandService _commandsEnabledStateChange ( event ) {
const buttonCommandNames = [
'toggleSidebar' ,
'toggleNoteList' ,
'newNote' ,
'newTodo' ,
'newNotebook' ,
'toggleVisiblePanes' ,
] ;
for ( const n of buttonCommandNames ) {
if ( event . commands [ n ] ) {
this . forceUpdate ( ) ;
return ;
}
2017-11-11 19:36:47 +02:00
}
}
2020-07-03 23:32:39 +02:00
componentDidMount ( ) {
CommandService . instance ( ) . on ( 'commandsEnabledStateChange' , this . commandService _commandsEnabledStateChange ) ;
}
componentWillUnmount ( ) {
CommandService . instance ( ) . off ( 'commandsEnabledStateChange' , this . commandService _commandsEnabledStateChange ) ;
this . unregisterCommands ( ) ;
2017-11-08 19:51:55 +02:00
}
2018-04-15 17:50:39 +02:00
toggleSidebar ( ) {
this . props . dispatch ( {
type : 'SIDEBAR_VISIBILITY_TOGGLE' ,
} ) ;
}
2019-10-30 11:40:34 +02:00
toggleNoteList ( ) {
this . props . dispatch ( {
type : 'NOTELIST_VISIBILITY_TOGGLE' ,
} ) ;
}
2020-05-02 17:41:07 +02:00
async waitForNoteToSaved ( noteId ) {
while ( noteId && this . props . editorNoteStatuses [ noteId ] === 'saving' ) {
console . info ( 'Waiting for note to be saved...' , this . props . editorNoteStatuses ) ;
await time . msleep ( 100 ) ;
}
}
async printTo _ ( target , options ) {
// Concurrent print calls are disallowed to avoid incorrect settings being restored upon completion
if ( this . isPrinting _ ) {
console . info ( ` Printing ${ options . path } to ${ target } disallowed, already printing. ` ) ;
return ;
}
this . isPrinting _ = true ;
// Need to wait for save because the interop service reloads the note from the database
await this . waitForNoteToSaved ( options . noteId ) ;
if ( target === 'pdf' ) {
try {
const pdfData = await InteropServiceHelper . exportNoteToPdf ( options . noteId , {
printBackground : true ,
pageSize : Setting . value ( 'export.pdfPageSize' ) ,
landscape : Setting . value ( 'export.pdfPageOrientation' ) === 'landscape' ,
customCss : this . props . customCss ,
} ) ;
await shim . fsDriver ( ) . writeFile ( options . path , pdfData , 'buffer' ) ;
} catch ( error ) {
console . error ( error ) ;
bridge ( ) . showErrorMessageBox ( error . message ) ;
}
} else if ( target === 'printer' ) {
try {
await InteropServiceHelper . printNote ( options . noteId , {
printBackground : true ,
customCss : this . props . customCss ,
} ) ;
} catch ( error ) {
console . error ( error ) ;
bridge ( ) . showErrorMessageBox ( error . message ) ;
}
}
this . isPrinting _ = false ;
}
2019-10-30 11:40:34 +02:00
styles ( themeId , width , height , messageBoxVisible , isSidebarVisible , isNoteListVisible , sidebarWidth , noteListWidth ) {
const styleKey = [ themeId , width , height , messageBoxVisible , + isSidebarVisible , + isNoteListVisible , sidebarWidth , noteListWidth ] . join ( '_' ) ;
2017-11-30 01:03:10 +02:00
if ( styleKey === this . styleKey _ ) return this . styles _ ;
2017-11-06 22:54:58 +02:00
2017-11-30 01:03:10 +02:00
const theme = themeStyle ( themeId ) ;
2017-11-06 22:54:58 +02:00
2017-11-30 01:03:10 +02:00
this . styleKey _ = styleKey ;
2017-11-06 20:35:04 +02:00
2017-11-30 01:03:10 +02:00
this . styles _ = { } ;
this . styles _ . header = {
width : width ,
} ;
2017-12-05 01:57:13 +02:00
this . styles _ . messageBox = {
width : width ,
2020-08-02 13:28:50 +02:00
height : 50 ,
2017-12-05 01:57:13 +02:00
display : 'flex' ,
alignItems : 'center' ,
paddingLeft : 10 ,
backgroundColor : theme . warningBackgroundColor ,
2019-07-29 14:13:23 +02:00
} ;
2017-12-05 01:57:13 +02:00
2019-12-30 14:00:53 +02:00
const rowHeight = height - theme . headerHeight - ( messageBoxVisible ? this . styles _ . messageBox . height : 0 ) ;
2020-05-15 13:20:56 +02:00
this . styles _ . verticalResizerSidebar = {
2019-02-16 03:12:43 +02:00
width : 5 ,
2019-12-30 16:10:43 +02:00
// HACK: For unknown reasons, the resizers are just a little bit taller than the other elements,
// making the whole window scroll vertically. So we remove 10 extra pixels here.
height : rowHeight - 10 ,
2019-02-16 03:12:43 +02:00
display : 'inline-block' ,
} ;
2020-05-15 13:20:56 +02:00
this . styles _ . verticalResizerNotelist = Object . assign ( { } , this . styles _ . verticalResizerSidebar ) ;
2017-11-30 01:03:10 +02:00
this . styles _ . sideBar = {
2020-05-15 13:20:56 +02:00
width : sidebarWidth - this . styles _ . verticalResizerSidebar . width ,
2017-11-06 22:54:58 +02:00
height : rowHeight ,
2017-11-06 20:35:04 +02:00
display : 'inline-block' ,
verticalAlign : 'top' ,
2019-07-29 12:55:50 +02:00
} ;
2018-04-15 17:50:39 +02:00
if ( isSidebarVisible === false ) {
this . styles _ . sideBar . width = 0 ;
this . styles _ . sideBar . display = 'none' ;
2020-05-15 13:20:56 +02:00
this . styles _ . verticalResizerSidebar . display = 'none' ;
2018-04-15 17:50:39 +02:00
}
2017-11-06 20:35:04 +02:00
2017-11-30 01:03:10 +02:00
this . styles _ . noteList = {
2020-05-15 13:20:56 +02:00
width : noteListWidth - this . styles _ . verticalResizerNotelist . width ,
2017-11-06 22:54:58 +02:00
height : rowHeight ,
2017-11-06 20:35:04 +02:00
display : 'inline-block' ,
verticalAlign : 'top' ,
} ;
2019-10-30 11:40:34 +02:00
if ( isNoteListVisible === false ) {
2019-10-30 22:59:32 +02:00
this . styles _ . noteList . width = 0 ;
2019-10-30 11:40:34 +02:00
this . styles _ . noteList . display = 'none' ;
2020-05-15 13:20:56 +02:00
this . styles _ . verticalResizerNotelist . display = 'none' ;
2019-10-30 11:40:34 +02:00
}
2017-11-30 01:03:10 +02:00
this . styles _ . noteText = {
2019-02-16 03:12:43 +02:00
width : Math . floor ( width - this . styles _ . sideBar . width - this . styles _ . noteList . width - 10 ) ,
2017-11-06 22:54:58 +02:00
height : rowHeight ,
2017-11-06 20:35:04 +02:00
display : 'inline-block' ,
verticalAlign : 'top' ,
} ;
2017-11-30 01:03:10 +02:00
this . styles _ . prompt = {
width : width ,
height : height ,
2017-11-08 19:51:55 +02:00
} ;
2018-02-27 22:04:38 +02:00
this . styles _ . modalLayer = Object . assign ( { } , theme . textStyle , {
zIndex : 10000 ,
position : 'absolute' ,
top : 0 ,
left : 0 ,
2018-03-23 19:59:18 +02:00
backgroundColor : theme . backgroundColor ,
2018-02-27 22:04:38 +02:00
width : width - 20 ,
height : height - 20 ,
padding : 10 ,
} ) ;
2017-11-30 01:03:10 +02:00
return this . styles _ ;
}
2020-03-13 19:42:50 +02:00
renderNotification ( theme , styles ) {
if ( ! this . messageBoxVisible ( ) ) return null ;
const onViewStatusScreen = ( ) => {
this . props . dispatch ( {
type : 'NAV_GO' ,
routeName : 'Status' ,
} ) ;
} ;
const onViewEncryptionConfigScreen = ( ) => {
this . props . dispatch ( {
type : 'NAV_GO' ,
routeName : 'Config' ,
props : {
defaultSection : 'encryption' ,
} ,
} ) ;
} ;
2020-08-02 13:28:50 +02:00
const onRestartAndUpgrade = async ( ) => {
Setting . setValue ( 'sync.upgradeState' , Setting . SYNC _UPGRADE _STATE _MUST _DO ) ;
await Setting . saveAll ( ) ;
bridge ( ) . restart ( ) ;
} ;
2020-03-13 19:42:50 +02:00
let msg = null ;
2020-08-02 13:28:50 +02:00
if ( this . props . shouldUpgradeSyncTarget ) {
msg = (
< span >
{ _ ( 'The sync target needs to be upgraded before Joplin can sync. The operation may take a few minutes to complete and the app needs to be restarted. To proceed please click on the link.' ) } { ' ' }
< a href = "#" onClick = { ( ) => onRestartAndUpgrade ( ) } >
{ _ ( 'Restart and upgrade' ) }
< / a >
< / span >
) ;
} else if ( this . props . hasDisabledSyncItems ) {
2020-03-13 19:42:50 +02:00
msg = (
< span >
{ _ ( 'Some items cannot be synchronised.' ) } { ' ' }
< a href = "#" onClick = { ( ) => onViewStatusScreen ( ) } >
{ _ ( 'View them now' ) }
< / a >
< / span >
) ;
} else if ( this . props . hasDisabledEncryptionItems ) {
msg = (
< span >
{ _ ( 'Some items cannot be decrypted.' ) } { ' ' }
< a href = "#" onClick = { ( ) => onViewStatusScreen ( ) } >
{ _ ( 'View them now' ) }
< / a >
< / span >
) ;
} else if ( this . props . showMissingMasterKeyMessage ) {
msg = (
< span >
{ _ ( 'One or more master keys need a password.' ) } { ' ' }
< a href = "#" onClick = { ( ) => onViewEncryptionConfigScreen ( ) } >
{ _ ( 'Set the password' ) }
< / a >
< / span >
) ;
} else if ( this . props . showNeedUpgradingMasterKeyMessage ) {
msg = (
< span >
{ _ ( 'One of your master keys use an obsolete encryption method.' ) } { ' ' }
< a href = "#" onClick = { ( ) => onViewEncryptionConfigScreen ( ) } >
{ _ ( 'View them now' ) }
< / a >
< / span >
) ;
} else if ( this . props . showShouldReencryptMessage ) {
msg = (
< span >
2020-03-14 02:52:28 +02:00
{ _ ( 'The default encryption method has been changed, you should re-encrypt your data.' ) } { ' ' }
2020-03-13 19:42:50 +02:00
< a href = "#" onClick = { ( ) => onViewEncryptionConfigScreen ( ) } >
{ _ ( 'More info' ) }
< / a >
< / span >
) ;
}
return (
< div style = { styles . messageBox } >
< span style = { theme . textStyle } > { msg } < / span >
< / div >
) ;
}
messageBoxVisible ( ) {
2020-08-02 13:28:50 +02:00
return this . props . hasDisabledSyncItems || this . props . showMissingMasterKeyMessage || this . props . showNeedUpgradingMasterKeyMessage || this . props . showShouldReencryptMessage || this . props . hasDisabledEncryptionItems || this . props . shouldUpgradeSyncTarget ;
2020-03-13 19:42:50 +02:00
}
2020-07-03 23:32:39 +02:00
registerCommands ( ) {
for ( const command of commands ) {
CommandService . instance ( ) . registerRuntime ( command . declaration . name , command . runtime ( this ) ) ;
}
}
unregisterCommands ( ) {
for ( const command of commands ) {
CommandService . instance ( ) . unregisterRuntime ( command . declaration . name ) ;
}
}
2017-11-30 01:03:10 +02:00
render ( ) {
2018-11-08 00:37:13 +02:00
const theme = themeStyle ( this . props . theme ) ;
2019-07-29 14:13:23 +02:00
const style = Object . assign (
{
color : theme . color ,
backgroundColor : theme . backgroundColor ,
} ,
2020-08-05 00:00:11 +02:00
this . props . style
2019-07-29 14:13:23 +02:00
) ;
2017-11-30 01:03:10 +02:00
const promptOptions = this . state . promptOptions ;
const notes = this . props . notes ;
2018-04-15 17:50:39 +02:00
const sidebarVisibility = this . props . sidebarVisibility ;
2019-10-30 11:40:34 +02:00
const noteListVisibility = this . props . noteListVisibility ;
2020-03-13 19:42:50 +02:00
const styles = this . styles ( this . props . theme , style . width , style . height , this . messageBoxVisible ( ) , sidebarVisibility , noteListVisibility , this . props . sidebarWidth , this . props . noteListWidth ) ;
2017-11-30 01:03:10 +02:00
2018-03-20 01:04:48 +02:00
const headerItems = [ ] ;
2017-11-10 22:34:36 +02:00
2020-07-03 23:32:39 +02:00
headerItems . push ( CommandService . instance ( ) . commandToToolbarButton ( 'toggleSidebar' , { iconRotation : sidebarVisibility ? 0 : 90 } ) ) ;
headerItems . push ( CommandService . instance ( ) . commandToToolbarButton ( 'toggleNoteList' , { iconRotation : noteListVisibility ? 0 : 90 } ) ) ;
headerItems . push ( CommandService . instance ( ) . commandToToolbarButton ( 'newNote' ) ) ;
headerItems . push ( CommandService . instance ( ) . commandToToolbarButton ( 'newTodo' ) ) ;
headerItems . push ( CommandService . instance ( ) . commandToToolbarButton ( 'newNotebook' ) ) ;
2017-11-08 23:22:24 +02:00
2018-03-20 01:04:48 +02:00
headerItems . push ( {
2020-05-02 17:41:07 +02:00
title : _ ( 'Code View' ) ,
2020-05-17 16:34:42 +02:00
iconName : 'fa-file-code ' ,
2017-11-13 02:23:12 +02:00
enabled : ! ! notes . length ,
2020-05-02 17:41:07 +02:00
type : 'checkbox' ,
checked : this . props . settingEditorCodeView ,
2019-07-29 14:13:23 +02:00
onClick : ( ) => {
2020-05-02 17:41:07 +02:00
// A bit of a hack, but for now don't allow changing code view
// while a note is being saved as it will cause a problem with
// TinyMCE because it won't have time to send its content before
// being switch to Ace Editor.
if ( this . props . hasNotesBeingSaved ) return ;
Setting . toggle ( 'editor.codeView' ) ;
2019-07-29 14:13:23 +02:00
} ,
2017-11-10 22:34:36 +02:00
} ) ;
2017-11-08 19:51:55 +02:00
2020-07-03 23:32:39 +02:00
headerItems . push ( CommandService . instance ( ) . commandToToolbarButton ( 'toggleVisiblePanes' ) ) ;
2020-05-02 17:41:07 +02:00
2018-03-20 01:04:48 +02:00
headerItems . push ( {
title : _ ( 'Search...' ) ,
iconName : 'fa-search' ,
2020-09-06 14:07:00 +02:00
onQuery : ( query , fuzzy = false ) => {
CommandService . instance ( ) . execute ( 'search' , { query , fuzzy } ) ;
2019-07-29 14:13:23 +02:00
} ,
2018-03-20 01:04:48 +02:00
type : 'search' ,
} ) ;
2017-11-30 01:03:10 +02:00
if ( ! this . promptOnClose _ ) {
this . promptOnClose _ = ( answer , buttonType ) => {
return this . state . promptOptions . onClose ( answer , buttonType ) ;
2019-07-29 14:13:23 +02:00
} ;
2017-11-30 01:03:10 +02:00
}
2020-03-13 19:42:50 +02:00
const messageComp = this . renderNotification ( theme , styles ) ;
2017-12-05 01:57:13 +02:00
2019-04-01 21:43:13 +02:00
const dialogInfo = PluginManager . instance ( ) . pluginDialogToShow ( this . props . plugins ) ;
2019-07-29 14:13:23 +02:00
const pluginDialog = ! dialogInfo ? null : < dialogInfo.Dialog { ...dialogInfo.props } / > ;
2019-04-01 21:43:13 +02:00
2018-02-27 22:04:38 +02:00
const modalLayerStyle = Object . assign ( { } , styles . modalLayer , { display : this . state . modalLayer . visible ? 'block' : 'none' } ) ;
2018-09-16 20:37:31 +02:00
const notePropertiesDialogOptions = this . state . notePropertiesDialogOptions ;
2020-02-25 11:43:31 +02:00
const noteContentPropertiesDialogOptions = this . state . noteContentPropertiesDialogOptions ;
2019-12-13 03:16:34 +02:00
const shareNoteDialogOptions = this . state . shareNoteDialogOptions ;
2018-09-16 20:37:31 +02:00
2020-06-06 17:00:20 +02:00
const codeEditor = Setting . value ( 'editor.betaCodeMirror' ) ? 'CodeMirror' : 'AceEditor' ;
const bodyEditor = this . props . settingEditorCodeView ? codeEditor : 'TinyMCE' ;
2020-03-10 01:24:57 +02:00
2017-11-06 20:35:04 +02:00
return (
< div style = { style } >
2018-02-27 22:04:38 +02:00
< div style = { modalLayerStyle } > { this . state . modalLayer . message } < / div >
2020-07-15 00:27:12 +02:00
{ noteContentPropertiesDialogOptions . visible && < NoteContentPropertiesDialog theme = { this . props . theme } onClose = { this . noteContentPropertiesDialog _close } text = { noteContentPropertiesDialogOptions . text } / > }
2019-07-29 14:13:23 +02:00
{ notePropertiesDialogOptions . visible && < NotePropertiesDialog theme = { this . props . theme } noteId = { notePropertiesDialogOptions . noteId } onClose = { this . notePropertiesDialog _close } onRevisionLinkClick = { notePropertiesDialogOptions . onRevisionLinkClick } / > }
2019-12-13 03:16:34 +02:00
{ shareNoteDialogOptions . visible && < ShareNoteDialog theme = { this . props . theme } noteIds = { shareNoteDialogOptions . noteIds } onClose = { this . shareNoteDialog _close } / > }
2019-07-29 14:13:23 +02:00
< PromptDialog autocomplete = { promptOptions && 'autocomplete' in promptOptions ? promptOptions . autocomplete : null } defaultValue = { promptOptions && promptOptions . value ? promptOptions . value : '' } theme = { this . props . theme } style = { styles . prompt } onClose = { this . promptOnClose _ } label = { promptOptions ? promptOptions . label : '' } description = { promptOptions ? promptOptions . description : null } visible = { ! ! this . state . promptOptions } buttons = { promptOptions && 'buttons' in promptOptions ? promptOptions . buttons : null } inputType = { promptOptions && 'inputType' in promptOptions ? promptOptions . inputType : null } / >
2018-09-16 20:37:31 +02:00
2018-03-20 01:04:48 +02:00
< Header style = { styles . header } showBackButton = { false } items = { headerItems } / >
2017-12-05 01:57:13 +02:00
{ messageComp }
2017-11-30 01:03:10 +02:00
< SideBar style = { styles . sideBar } / >
2020-05-15 13:20:56 +02:00
< VerticalResizer style = { styles . verticalResizerSidebar } onDrag = { this . sidebar _onDrag } / >
2017-11-30 01:03:10 +02:00
< NoteList style = { styles . noteList } / >
2020-05-15 13:20:56 +02:00
< VerticalResizer style = { styles . verticalResizerNotelist } onDrag = { this . noteList _onDrag } / >
2020-05-03 19:44:49 +02:00
< NoteEditor bodyEditor = { bodyEditor } style = { styles . noteText } / >
2019-07-29 14:13:23 +02:00
{ pluginDialog }
2017-11-06 20:35:04 +02:00
< / div >
) ;
}
}
2020-05-21 10:14:33 +02:00
const mapStateToProps = state => {
2017-11-06 22:54:58 +02:00
return {
2017-11-10 22:34:36 +02:00
theme : state . settings . theme ,
2020-05-02 17:41:07 +02:00
settingEditorCodeView : state . settings [ 'editor.codeView' ] ,
2018-04-15 17:50:39 +02:00
sidebarVisibility : state . sidebarVisibility ,
2019-10-30 11:40:34 +02:00
noteListVisibility : state . noteListVisibility ,
2017-11-13 02:23:12 +02:00
folders : state . folders ,
notes : state . notes ,
2017-12-05 20:56:39 +02:00
hasDisabledSyncItems : state . hasDisabledSyncItems ,
2020-03-13 19:42:50 +02:00
hasDisabledEncryptionItems : state . hasDisabledEncryptionItems ,
2017-12-22 20:50:27 +02:00
showMissingMasterKeyMessage : state . notLoadedMasterKeys . length && state . masterKeys . length ,
2020-03-13 19:42:50 +02:00
showNeedUpgradingMasterKeyMessage : ! ! EncryptionService . instance ( ) . masterKeysThatNeedUpgrading ( state . masterKeys ) . length ,
showShouldReencryptMessage : state . settings [ 'encryption.shouldReencrypt' ] >= Setting . SHOULD _REENCRYPT _YES ,
2020-08-02 13:28:50 +02:00
shouldUpgradeSyncTarget : state . settings [ 'sync.upgradeState' ] === Setting . SYNC _UPGRADE _STATE _SHOULD _DO ,
2018-01-31 22:19:11 +02:00
selectedFolderId : state . selectedFolderId ,
2019-02-16 03:12:43 +02:00
sidebarWidth : state . settings [ 'style.sidebar.width' ] ,
noteListWidth : state . settings [ 'style.noteList.width' ] ,
2019-03-15 23:57:58 +02:00
selectedNoteId : state . selectedNoteIds . length === 1 ? state . selectedNoteIds [ 0 ] : null ,
2019-04-01 21:43:13 +02:00
plugins : state . plugins ,
2019-07-20 23:13:10 +02:00
templates : state . templates ,
2020-05-02 17:41:07 +02:00
customCss : state . customCss ,
editorNoteStatuses : state . editorNoteStatuses ,
2020-04-09 19:57:20 +02:00
hasNotesBeingSaved : stateUtils . hasNotesBeingSaved ( state ) ,
2017-11-06 22:54:58 +02:00
} ;
2017-11-06 20:35:04 +02:00
} ;
const MainScreen = connect ( mapStateToProps ) ( MainScreenComponent ) ;
2018-04-15 17:50:39 +02:00
module . exports = { MainScreen } ;