diff --git a/ElectronClient/app/gui/SideBar.jsx b/ElectronClient/app/gui/SideBar.jsx index f37a080aac..0af9b8dc2a 100644 --- a/ElectronClient/app/gui/SideBar.jsx +++ b/ElectronClient/app/gui/SideBar.jsx @@ -3,6 +3,7 @@ const { connect } = require("react-redux"); const shared = require("lib/components/shared/side-menu-shared.js"); const { Synchronizer } = require("lib/synchronizer.js"); const BaseModel = require("lib/BaseModel.js"); +const Setting = require('lib/models/Setting.js'); const Folder = require("lib/models/Folder.js"); const Note = require("lib/models/Note.js"); const Tag = require("lib/models/Tag.js"); @@ -23,7 +24,7 @@ class SideBarComponent extends React.Component { this.onFolderDragStart_ = (event) => { const folderId = event.currentTarget.getAttribute('folderid'); if (!folderId) return; - + event.dataTransfer.setDragImage(new Image(), 1, 1); event.dataTransfer.clearData(); event.dataTransfer.setData('text/x-jop-folder-ids', JSON.stringify([folderId])); @@ -79,6 +80,11 @@ class SideBarComponent extends React.Component { id: folderId, }); }; + + this.state = { + tagHeaderIsExpanded: Setting.value('tagHeaderIsExpanded'), + folderHeaderIsExpanded: Setting.value('folderHeaderIsExpanded') + }; } style() { @@ -190,7 +196,7 @@ class SideBarComponent extends React.Component { if (shim.isLinux()) { // For some reason, the UI seems to sleep in some Linux distro during // sync. Cannot find the reason for it and cannot replicate, so here - // as a test force the update at regular intervals. + // as a test force the update at regular intervals. // https://github.com/laurent22/joplin/issues/312#issuecomment-429472193 if (!prevProps.syncStarted && this.props.syncStarted) { this.clearForceUpdateDuringSync(); @@ -201,7 +207,7 @@ class SideBarComponent extends React.Component { } if (prevProps.syncStarted && !this.props.syncStarted) this.clearForceUpdateDuringSync(); - } + } } componentWillUnmount() { @@ -303,7 +309,7 @@ class SideBarComponent extends React.Component { ); } - if (itemType === BaseModel.TYPE_TAG) { + if (itemType === BaseModel.TYPE_TAG) { menu.append( new MenuItem({ label: _('Rename'), @@ -440,14 +446,50 @@ class SideBarComponent extends React.Component { makeHeader(key, label, iconName, extraProps = {}) { const style = this.style().header; const icon = ; + + if (extraProps.toggleblock || extraProps.onClick) { + style.cursor = "pointer"; + } + + let headerClick = extraProps.onClick || null; + delete extraProps.onClick; + + // check if toggling option is set. + let toggleIcon = null; + const toggleKey = `${key}IsExpanded`; + if (extraProps.toggleblock) { + let isExpanded = this.state[toggleKey]; + toggleIcon = ; + } return ( -