1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Remove the context menu for deletion

This commit is contained in:
asmsuechan
2017-07-07 19:45:02 +09:00
parent 5623c68170
commit 44fc356775
4 changed files with 2 additions and 54 deletions

View File

@@ -39,18 +39,16 @@ const TagElementList = (tags) => {
* @param {boolean} isActive * @param {boolean} isActive
* @param {Object} note * @param {Object} note
* @param {Function} handleNoteClick * @param {Function} handleNoteClick
* @param {Function} handleNoteContextMenu
* @param {Function} handleDragStart * @param {Function} handleDragStart
* @param {string} dateDisplay * @param {string} dateDisplay
*/ */
const NoteItem = ({ isActive, note, dateDisplay, handleNoteClick, handleNoteContextMenu, handleDragStart }) => ( const NoteItem = ({ isActive, note, dateDisplay, handleNoteClick, handleDragStart }) => (
<div styleName={isActive <div styleName={isActive
? 'item--active' ? 'item--active'
: 'item' : 'item'
} }
key={`${note.storage}-${note.key}`} key={`${note.storage}-${note.key}`}
onClick={e => handleNoteClick(e, `${note.storage}-${note.key}`)} onClick={e => handleNoteClick(e, `${note.storage}-${note.key}`)}
onContextMenu={e => handleNoteContextMenu(e, `${note.storage}-${note.key}`)}
onDragStart={e => handleDragStart(e, note)} onDragStart={e => handleDragStart(e, note)}
draggable='true' draggable='true'
> >
@@ -94,7 +92,6 @@ NoteItem.propTypes = {
isStarred: PropTypes.bool.isRequired isStarred: PropTypes.bool.isRequired
}), }),
handleNoteClick: PropTypes.func.isRequired, handleNoteClick: PropTypes.func.isRequired,
handleNoteContextMenu: PropTypes.func.isRequired,
handleDragStart: PropTypes.func.isRequired, handleDragStart: PropTypes.func.isRequired,
handleDragEnd: PropTypes.func.isRequired handleDragEnd: PropTypes.func.isRequired
} }

View File

@@ -10,17 +10,15 @@ import styles from './NoteItemSimple.styl'
* @param {boolean} isActive * @param {boolean} isActive
* @param {Object} note * @param {Object} note
* @param {Function} handleNoteClick * @param {Function} handleNoteClick
* @param {Function} handleNoteContextMenu
* @param {Function} handleDragStart * @param {Function} handleDragStart
*/ */
const NoteItemSimple = ({ isActive, note, handleNoteClick, handleNoteContextMenum, handleDragStart }) => ( const NoteItemSimple = ({ isActive, note, handleNoteClick, handleDragStart }) => (
<div styleName={isActive <div styleName={isActive
? 'item-simple--active' ? 'item-simple--active'
: 'item-simple' : 'item-simple'
} }
key={`${note.storage}-${note.key}`} key={`${note.storage}-${note.key}`}
onClick={e => handleNoteClick(e, `${note.storage}-${note.key}`)} onClick={e => handleNoteClick(e, `${note.storage}-${note.key}`)}
onContextMenu={e => handleNoteContextMenu(e, `${note.storage}-${note.key}`)}
onDragStart={e => handleDragStart(e, note)} onDragStart={e => handleDragStart(e, note)}
draggable='true' draggable='true'
> >
@@ -46,7 +44,6 @@ NoteItemSimple.propTypes = {
title: PropTypes.string.isrequired title: PropTypes.string.isrequired
}), }),
handleNoteClick: PropTypes.func.isRequired, handleNoteClick: PropTypes.func.isRequired,
handleNoteContextMenu: PropTypes.func.isRequired,
handleDragStart: PropTypes.func.isRequired handleDragStart: PropTypes.func.isRequired
} }

View File

@@ -70,7 +70,6 @@ class NoteList extends React.Component {
dateDisplay={dateDisplay} dateDisplay={dateDisplay}
key={key} key={key}
handleNoteClick={(e) => this.props.handleNoteClick(e, _index)} handleNoteClick={(e) => this.props.handleNoteClick(e, _index)}
handleNoteContextMenu={() => ''}
/> />
) )
}) })

View File

@@ -264,49 +264,6 @@ class NoteList extends React.Component {
}) })
} }
handleNoteContextMenu (e, uniqueKey) {
let menu = new Menu()
menu.append(new MenuItem({
label: 'Delete Note',
click: (e) => this.handleDeleteNote(e, uniqueKey)
}))
menu.popup()
}
handleDeleteNote (e, uniqueKey) {
let index = dialog.showMessageBox(remote.getCurrentWindow(), {
type: 'warning',
message: 'Delete a note',
detail: 'This work cannot be undone.',
buttons: ['Confirm', 'Cancel']
})
if (index === 0) {
let { dispatch, location } = this.props
let splitted = uniqueKey.split('-')
let storageKey = splitted.shift()
let noteKey = splitted.shift()
dataApi
.deleteNote(storageKey, noteKey)
.then((data) => {
let dispatchHandler = () => {
dispatch({
type: 'DELETE_NOTE',
storageKey: data.storageKey,
noteKey: data.noteKey
})
}
if (location.query.key === uniqueKey) {
ee.once('list:moved', dispatchHandler)
ee.emit('list:next')
} else {
dispatchHandler()
}
})
}
}
handleSortByChange (e) { handleSortByChange (e) {
let { dispatch } = this.props let { dispatch } = this.props
@@ -449,7 +406,6 @@ class NoteList extends React.Component {
dateDisplay={dateDisplay} dateDisplay={dateDisplay}
key={key} key={key}
handleNoteClick={this.handleNoteClick.bind(this)} handleNoteClick={this.handleNoteClick.bind(this)}
handleNoteContextMenu={this.handleNoteContextMenu.bind(this)}
handleDragStart={this.handleDragStart.bind(this)} handleDragStart={this.handleDragStart.bind(this)}
/> />
) )
@@ -461,7 +417,6 @@ class NoteList extends React.Component {
note={note} note={note}
key={key} key={key}
handleNoteClick={this.handleNoteClick.bind(this)} handleNoteClick={this.handleNoteClick.bind(this)}
handleNoteContextMenu={this.handleNoteContextMenu.bind(this)}
handleDragStart={this.handleDragStart.bind(this)} handleDragStart={this.handleDragStart.bind(this)}
/> />
) )