Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exports to infoPanel #709

Merged
merged 3 commits into from
Jul 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
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, noteLink, 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']
})
}

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