From e928a5c2bcda9b1f15c3d52c4d3bd3d5c3698b36 Mon Sep 17 00:00:00 2001 From: Jonathan Labreuille Date: Fri, 12 Feb 2016 11:30:08 +0100 Subject: [PATCH] Segments page review - remove edit link for WordPress users list - hide trashed segments from Import - fixed display issue in listing's item actions --- assets/js/src/listing/listing.jsx | 29 +++++++++++++++++++---------- assets/js/src/segments/form.jsx | 6 +++--- assets/js/src/segments/list.jsx | 3 +++ lib/Models/Segment.php | 1 + 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/assets/js/src/listing/listing.jsx b/assets/js/src/listing/listing.jsx index 7aef70d8d5..5503221f32 100644 --- a/assets/js/src/listing/listing.jsx +++ b/assets/js/src/listing/listing.jsx @@ -74,10 +74,11 @@ define( ); } - var custom_actions = this.props.item_actions; - var item_actions = false; + const custom_actions = this.props.item_actions; + let item_actions = false; if(custom_actions.length > 0) { + let is_first = true; item_actions = custom_actions.map(function(action, index) { if(action.display !== undefined) { if(action.display(this.props.item) === false) { @@ -85,10 +86,12 @@ define( } } + let custom_action = null; + if(action.name === 'trash') { - return ( + custom_action = ( - {(index > 0) ? ' | ' : ''} + {(!is_first) ? ' | ' : ''} ); } else if(action.refresh) { - return ( + custom_action = ( - {(index > 0) ? ' | ' : ''} + {(!is_first) ? ' | ' : ''} { action.link(this.props.item) } ); } else if(action.link) { - return ( + custom_action = ( - {(index > 0) ? ' | ' : ''} + {(!is_first) ? ' | ' : ''} { action.link(this.props.item) } ); } else { - return ( + custom_action = ( - {(index > 0) ? ' | ' : ''} + {(!is_first) ? ' | ' : ''} ); } + + if(custom_action !== null && is_first === true) { + is_first = false; + } + + return custom_action; }.bind(this)); } else { item_actions = ( diff --git a/assets/js/src/segments/form.jsx b/assets/js/src/segments/form.jsx index 04ac4d8cb6..ca7b2526a7 100644 --- a/assets/js/src/segments/form.jsx +++ b/assets/js/src/segments/form.jsx @@ -12,7 +12,7 @@ define( Form ) { - var fields = [ + let fields = [ { name: 'name', label: 'Name', @@ -25,7 +25,7 @@ define( } ]; - var messages = { + const messages = { onUpdate: function() { MailPoet.Notice.success('Segment successfully updated!'); }, @@ -34,7 +34,7 @@ define( } }; - var SegmentForm = React.createClass({ + const SegmentForm = React.createClass({ mixins: [ Router.History ], diff --git a/assets/js/src/segments/list.jsx b/assets/js/src/segments/list.jsx index 456b782deb..6574e62d8d 100644 --- a/assets/js/src/segments/list.jsx +++ b/assets/js/src/segments/list.jsx @@ -96,6 +96,9 @@ const item_actions = [ return ( Edit ); + }, + display: function(segment) { + return (segment.type !== 'wp_users'); } }, { diff --git a/lib/Models/Segment.php b/lib/Models/Segment.php index 615983bdac..41ef874e1a 100644 --- a/lib/Models/Segment.php +++ b/lib/Models/Segment.php @@ -122,6 +122,7 @@ class Segment extends Model { ->group_by(self::$_table.'.id') ->group_by(self::$_table.'.name') ->where(self::$_table.'.type', 'default') + ->whereNull(self::$_table.'.deleted_at') ->findArray(); }