-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chrome: Adding the trash post link to the sidebar
- Loading branch information
1 parent
3b2d42f
commit 0a13bea
Showing
4 changed files
with
75 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { connect } from 'react-redux'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from 'i18n'; | ||
import Button from 'components/button'; | ||
import Dashicon from 'components/dashicon'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './style.scss'; | ||
import { getCurrentPost } from '../../selectors'; | ||
import { trashPost } from '../../actions'; | ||
|
||
function PostTrash( { postId, ...props } ) { | ||
if ( ! postId ) { | ||
return null; | ||
} | ||
|
||
const onClick = () => props.trashPost( postId ); | ||
|
||
return ( | ||
<Button className="editor-post-trash" onClick={ onClick }> | ||
{ __( 'Move to trash' ) } | ||
<Dashicon icon="trash" /> | ||
</Button> | ||
); | ||
} | ||
|
||
export default connect( | ||
( state ) => { | ||
return { | ||
postId: getCurrentPost( state ).id, | ||
}; | ||
}, | ||
( dispatch ) => { | ||
return { | ||
trashPost( postId ) { | ||
return trashPost( dispatch, postId ); | ||
}, | ||
}; | ||
} | ||
)( PostTrash ); |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.editor-post-trash { | ||
cursor: pointer; | ||
color: inherit; | ||
flex-grow: 1; | ||
text-align: right; | ||
|
||
.dashicon { | ||
vertical-align: middle; | ||
margin-right: -10px; | ||
margin-left: 10px; | ||
} | ||
|
||
&:hover { | ||
color: $blue-medium; | ||
} | ||
} |