Show error notice when trying to delete segment, which is assigned to automated email

[MAILPOET-2352]
This commit is contained in:
Ján Mikláš
2019-09-18 15:53:29 +02:00
committed by Jack Kitterhing
parent dad381c74d
commit 0ae466f5fa
2 changed files with 18 additions and 1 deletions

View File

@@ -202,7 +202,23 @@ const itemActions = [
{
name: 'trash',
display: function display(segment) {
return !isSpecialSegment(segment);
return !isSpecialSegment(segment) && segment.automated_emails_subjects.length === 0;
},
},
{
name: 'delete',
label: MailPoet.I18n.t('moveToTrash'),
onClick: function onClick(segment) {
MailPoet.Notice.error(
MailPoet.I18n.t('trashDisallowed').replace(
'%$1s',
segment.automated_emails_subjects.map((subject) => `'${subject}'`).join(', ')
),
{ scroll: true }
);
},
display: function display(segment) {
return !isSpecialSegment(segment) && segment.automated_emails_subjects.length > 0;
},
},
];