From 46ef804ae40798011f4247b79afbf4b125f7e5dd Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Wed, 19 Jun 2019 16:23:32 -0300 Subject: [PATCH 1/4] open external note action links in a new tab --- .../client/header/activity-panel/panels/inbox.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js b/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js index 51765784538..20612dcb971 100644 --- a/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js +++ b/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js @@ -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 ( 'http' === href.substr( 0, 4 ).toLowerCase() ) { + event.preventDefault(); + window.open( href, '_blank' ); + } + + triggerNoteAction( note_id, action_id ); + } + renderEmptyCard() { return ( triggerNoteAction( note.id, action.id ) } + onClick={ e => this.handleActionClick( e, note.id, action.id ) } > { action.label } From a05daef8d74f50c2f75ba9be995de1d55814f33b Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Thu, 20 Jun 2019 10:49:25 -0300 Subject: [PATCH 2/4] update URL test to wc-admin#/ --- .../client/header/activity-panel/panels/inbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js b/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js index 20612dcb971..035ad517555 100644 --- a/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js +++ b/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js @@ -37,7 +37,7 @@ class InboxPanel extends Component { const { triggerNoteAction } = this.props; const href = event.target.href || ''; - if ( 'http' === href.substr( 0, 4 ).toLowerCase() ) { + if ( href.length && href.indexOf( 'wc-admin#/' ) <= 0 ) { event.preventDefault(); window.open( href, '_blank' ); } From 7dfc3fe240365be85fdc8db3262de7cfb0bccb09 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Wed, 26 Jun 2019 17:16:54 -0300 Subject: [PATCH 3/4] use current window for any dashboard URL --- .../client/header/activity-panel/panels/inbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js b/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js index 035ad517555..b5e5775929d 100644 --- a/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js +++ b/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js @@ -37,7 +37,7 @@ class InboxPanel extends Component { const { triggerNoteAction } = this.props; const href = event.target.href || ''; - if ( href.length && href.indexOf( 'wc-admin#/' ) <= 0 ) { + if ( ! href.startsWith( wcSettings.adminUrl ) ) { event.preventDefault(); window.open( href, '_blank' ); } From 93bcd60f58dbb0bf7ad9307e368f63e0a793d430 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Thu, 27 Jun 2019 09:33:46 -0300 Subject: [PATCH 4/4] check that url is not an empty string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Albert Juhé Lluveras --- .../client/header/activity-panel/panels/inbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js b/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js index b5e5775929d..e1045627ce6 100644 --- a/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js +++ b/plugins/woocommerce-admin/client/header/activity-panel/panels/inbox.js @@ -37,7 +37,7 @@ class InboxPanel extends Component { const { triggerNoteAction } = this.props; const href = event.target.href || ''; - if ( ! href.startsWith( wcSettings.adminUrl ) ) { + if ( href.length && ! href.startsWith( wcSettings.adminUrl ) ) { event.preventDefault(); window.open( href, '_blank' ); }