Merge pull request woocommerce/woocommerce-admin#2462 from woocommerce/fix/2403

open external note action links in a new tab
This commit is contained in:
Ron Rennick 2019-06-27 15:40:52 -03:00 committed by GitHub
commit 41e6f63fa9
1 changed files with 14 additions and 2 deletions

View File

@ -33,6 +33,18 @@ class InboxPanel extends Component {
this.props.updateCurrentUserData( userDataFields );
}
handleActionClick( event, note_id, action_id ) {
const { triggerNoteAction } = this.props;
const href = event.target.href || '';
if ( href.length && ! href.startsWith( wcSettings.adminUrl ) ) {
event.preventDefault();
window.open( href, '_blank' );
}
triggerNoteAction( note_id, action_id );
}
renderEmptyCard() {
return (
<ActivityCard
@ -50,7 +62,7 @@ class InboxPanel extends Component {
}
renderNotes() {
const { lastRead, notes, triggerNoteAction } = this.props;
const { lastRead, notes } = this.props;
if ( 0 === Object.keys( notes ).length ) {
return this.renderEmptyCard();
@ -65,7 +77,7 @@ class InboxPanel extends Component {
isDefault
isPrimary={ action.primary }
href={ action.url || undefined }
onClick={ () => triggerNoteAction( note.id, action.id ) }
onClick={ e => this.handleActionClick( e, note.id, action.id ) }
>
{ action.label }
</Button>