This repository has been archived by the owner on Dec 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply refactored shortcuts component on codebase
Issue #1283
- Loading branch information
1 parent
7a9485d
commit 1bf091a
Showing
24 changed files
with
405 additions
and
453 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 69 additions & 45 deletions
114
src/components/shortcuts/DocumentListContextShortcuts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,84 @@ | ||
import React, { Component } from 'react'; | ||
import { Shortcuts } from 'react-shortcuts'; | ||
import { Shortcut } from '../Shortcuts'; | ||
|
||
class DocumentListContextShortcuts extends Component { | ||
constructor(props){ | ||
super(props); | ||
} | ||
handleShortcuts = (action, event) => { | ||
const { | ||
handleAdvancedEdit, handleOpenNewTab, handleDelete, getAllLeafs, | ||
handleIndent | ||
} = this.props; | ||
|
||
switch (action) { | ||
case 'OPEN_SELECTED': | ||
export default class DocumentListContextShortcuts extends Component { | ||
handlers = { | ||
OPEN_SELECTED: event => { | ||
event.preventDefault(); | ||
|
||
if (this.props.handleOpenNewTab) { | ||
this.props.handleOpenNewTab(); | ||
} | ||
}, | ||
REMOVE_SELECTED: event => { | ||
event.preventDefault(); | ||
|
||
if (this.props.handleDelete) { | ||
this.props.handleDelete(); | ||
} | ||
}, | ||
ADVANCED_EDIT: event => { | ||
event.preventDefault(); | ||
if(handleOpenNewTab) { | ||
handleOpenNewTab(); | ||
|
||
if (this.props.handleAdvancedEdit) { | ||
this.props.handleAdvancedEdit(); | ||
} | ||
break; | ||
case 'REMOVE_SELECTED': | ||
}, | ||
SELECT_ALL_LEAFS: event => { | ||
event.preventDefault(); | ||
if(handleDelete){ | ||
handleDelete(); | ||
|
||
if (this.props.getAllLeafs) { | ||
this.props.getAllLeafs(); | ||
} | ||
break; | ||
case 'ADVANCED_EDIT': | ||
}, | ||
EXPAND_INDENT: event => { | ||
event.preventDefault(); | ||
if(handleAdvancedEdit){ | ||
handleAdvancedEdit(); | ||
|
||
if (this.props.handleIndent) { | ||
this.props.handleIndent(true); | ||
} | ||
break; | ||
case 'SELECT_ALL_LEAFS': | ||
}, | ||
COLLAPSE_INDENT: event => { | ||
event.preventDefault(); | ||
getAllLeafs(); | ||
break; | ||
case 'EXPAND_INDENT': | ||
handleIndent(true); | ||
break; | ||
case 'COLLAPSE_INDENT': | ||
handleIndent(false); | ||
break; | ||
|
||
if (this.props.handleIndent) { | ||
this.props.handleIndent(false); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
render() { | ||
return ( | ||
<Shortcuts | ||
handler={this.handleShortcuts} | ||
isolate | ||
name="DOCUMENT_LIST_CONTEXT" | ||
preventDefault | ||
stopPropagation | ||
targetNodeSelector="body" | ||
return [ | ||
<Shortcut | ||
key="OPEN_SELECTED" | ||
name="OPEN_SELECTED" | ||
handler={this.handlers.OPEN_SELECTED} | ||
/>, | ||
<Shortcut | ||
key="REMOVE_SELECTED" | ||
name="REMOVE_SELECTED" | ||
handler={this.handlers.REMOVE_SELECTED} | ||
/>, | ||
<Shortcut | ||
key="ADVANCED_EDIT" | ||
name="ADVANCED_EDIT" | ||
handler={this.handlers.ADVANCED_EDIT} | ||
/>, | ||
<Shortcut | ||
key="SELECT_ALL_LEAFS" | ||
name="SELECT_ALL_LEAFS" | ||
handler={this.handlers.SELECT_ALL_LEAFS} | ||
/>, | ||
<Shortcut | ||
key="EXPAND_INDENT" | ||
name="EXPAND_INDENT" | ||
handler={this.handlers.EXPAND_INDENT} | ||
/>, | ||
<Shortcut | ||
key="COLLAPSE_INDENT" | ||
name="COLLAPSE_INDENT" | ||
handler={this.handlers.COLLAPSE_INDENT} | ||
/> | ||
); | ||
]; | ||
} | ||
} | ||
|
||
export default DocumentListContextShortcuts; |
Oops, something went wrong.