Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add exports to infoPanel
  • Loading branch information
asmsuechan committed Jul 15, 2017
commit 6ea2b5e1d945ade0e1085e2e97254fbb59c34007
16 changes: 13 additions & 3 deletions browser/main/Detail/InfoPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CSSModules from 'browser/lib/CSSModules'
import styles from './InfoPanel.styl'

const InfoPanel = ({
storageName, folderName, noteLink, updatedAt, createdAt
storageName, folderName, noteKey, updatedAt, createdAt, exportAsMd, exportAsTxt
}) => (
<div className='infoPanel' styleName='control-infoButton-panel' style={{display: 'none'}}>
<div styleName='group-section'>
Expand Down Expand Up @@ -47,7 +47,15 @@ const InfoPanel = ({
</div>
</div>

<div styleName='group-export' />
<div styleName='group-export'>
<i className='fa fa-file-text fa-fw'
onClick={(e) => exportAsMd(e)}
/>

<i className='fa fa-file-text fa-fw'
onClick={(e) => exportAsTxt(e)}
/>
</div>
</div>
)

Expand All @@ -56,7 +64,9 @@ InfoPanel.propTypes = {
folderName: PropTypes.string.isRequired,
noteLink: PropTypes.string.isRequired,
updatedAt: PropTypes.string.isRequired,
createdAt: PropTypes.string.isRequired
createdAt: PropTypes.string.isRequired,
exportAsMd: PropTypes.func.isRequired,
exportAsTxt: PropTypes.func.isRequired
}

export default CSSModules(InfoPanel, styles)
3 changes: 3 additions & 0 deletions browser/main/Detail/InfoPanel.styl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
width 160px
height 25px

.group-export
height 25px

body[data-theme="dark"]
.control-infoButton-panel
background-color $ui-dark-noteList-backgroundColor
Expand Down
10 changes: 10 additions & 0 deletions browser/main/Detail/MarkdownNoteDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ class MarkdownNoteDetail extends React.Component {

}

exportAsMd () {
ee.emit('export:save-md')
}

exportAsTxt () {
ee.emit('export:save-text')
}

handleTrashButtonClick (e) {
let { note } = this.state
const { isTrashed } = note
Expand Down Expand Up @@ -352,6 +360,8 @@ class MarkdownNoteDetail extends React.Component {
noteLink={`[title](${location.query.key})`}
updatedAt={formatDate(note.updatedAt)}
createdAt={formatDate(note.createdAt)}
exportAsMd={this.exportAsMd}
exportAsTxt={this.exportAsTxt}
/>
</div>
</div>
Expand Down
11 changes: 11 additions & 0 deletions browser/main/Detail/SnippetNoteDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,15 @@ class SnippetNoteDetail extends React.Component {
if (infoPanel.style) infoPanel.style.display = infoPanel.style.display === 'none' ? 'inline' : 'none'
}

showWarning () {
dialog.showMessageBox(remote.getCurrentWindow(), {
type: 'warning',
message: 'Sorry!',
detail: 'md/text import is available only a markdown note.',
buttons: ['OK', 'Cancel']
})
}

render () {
let { data, config, location } = this.props
let { note } = this.state
Expand Down Expand Up @@ -591,6 +600,8 @@ class SnippetNoteDetail extends React.Component {
noteLink={`[title](${location.query.key})`}
updatedAt={formatDate(note.updatedAt)}
createdAt={formatDate(note.createdAt)}
exportAsMd={this.showWarning}
exportAsTxt={this.showWarning}
/>
</div>
</div>
Expand Down