Hide some listing actions on mobile devices

[MAILPOET-2780]
This commit is contained in:
Ján Mikláš
2020-10-12 12:53:16 +02:00
committed by Veljko V
parent c73681c89b
commit 9b6ca37a07
11 changed files with 38 additions and 4 deletions

View File

@@ -43,6 +43,12 @@ span.mailpoet-gap-half {
touch-action: none; touch-action: none;
} }
.mailpoet-hide-on-mobile {
@include respond-to(small-screen) {
display: none !important;
}
}
// Media query helpers // Media query helpers
.small-screen { .small-screen {
display: none; display: none;

View File

@@ -115,6 +115,7 @@ function getFormPlacement(settings) {
const itemActions = [ const itemActions = [
{ {
name: 'edit', name: 'edit',
className: 'mailpoet-hide-on-mobile',
label: MailPoet.I18n.t('edit'), label: MailPoet.I18n.t('edit'),
link: function link(item) { link: function link(item) {
return ( return (
@@ -124,6 +125,7 @@ const itemActions = [
}, },
{ {
name: 'duplicate', name: 'duplicate',
className: 'mailpoet-hide-on-mobile',
label: MailPoet.I18n.t('duplicate'), label: MailPoet.I18n.t('duplicate'),
onClick: function onClick(item, refresh) { onClick: function onClick(item, refresh) {
return MailPoet.Ajax.post({ return MailPoet.Ajax.post({
@@ -151,6 +153,7 @@ const itemActions = [
}, },
{ {
name: 'trash', name: 'trash',
className: 'mailpoet-hide-on-mobile',
}, },
]; ];

View File

@@ -76,7 +76,10 @@ class ListingItem extends React.Component {
if (action.name === 'trash') { if (action.name === 'trash') {
customAction = ( customAction = (
<span key={`action-${action.name}`} className="trash"> <span
key={`action-${action.name}`}
className={classNames(action.name, action.className)}
>
<a <a
type="button" type="button"
href="#" href="#"
@@ -94,7 +97,7 @@ class ListingItem extends React.Component {
<span <span
onClick={this.props.onRefreshItems} onClick={this.props.onRefreshItems}
key={`action-${action.name}`} key={`action-${action.name}`}
className={action.name} className={classNames(action.name, action.className)}
role="button" role="button"
tabIndex={index} tabIndex={index}
onKeyDown={(event) => { onKeyDown={(event) => {
@@ -112,7 +115,7 @@ class ListingItem extends React.Component {
customAction = ( customAction = (
<span <span
key={`action-${action.name}`} key={`action-${action.name}`}
className={action.name} className={classNames(action.name, action.className)}
> >
{ action.link(this.props.item, this.props.location) } { action.link(this.props.item, this.props.location) }
</span> </span>
@@ -121,7 +124,7 @@ class ListingItem extends React.Component {
customAction = ( customAction = (
<span <span
key={`action-${action.name}`} key={`action-${action.name}`}
className={action.name} className={classNames(action.name, action.className)}
> >
<a <a
href="#" href="#"

View File

@@ -114,6 +114,7 @@ const newsletterActions = [
}, },
{ {
name: 'edit', name: 'edit',
className: 'mailpoet-hide-on-mobile',
link: function link(newsletter) { link: function link(newsletter) {
return ( return (
<a href={`?page=mailpoet-newsletter-editor&id=${newsletter.id}`}> <a href={`?page=mailpoet-newsletter-editor&id=${newsletter.id}`}>
@@ -124,6 +125,7 @@ const newsletterActions = [
}, },
{ {
name: 'duplicate', name: 'duplicate',
className: 'mailpoet-hide-on-mobile',
label: MailPoet.I18n.t('duplicate'), label: MailPoet.I18n.t('duplicate'),
onClick: (newsletter, refresh) => MailPoet.Ajax.post({ onClick: (newsletter, refresh) => MailPoet.Ajax.post({
api_version: window.mailpoet_api_version, api_version: window.mailpoet_api_version,
@@ -146,6 +148,7 @@ const newsletterActions = [
}, },
{ {
name: 'trash', name: 'trash',
className: 'mailpoet-hide-on-mobile',
}, },
]; ];

View File

@@ -122,6 +122,7 @@ const newsletterActions = [
}, },
{ {
name: 'edit', name: 'edit',
className: 'mailpoet-hide-on-mobile',
link: function link(newsletter) { link: function link(newsletter) {
return ( return (
<a href={`?page=mailpoet-newsletter-editor&id=${newsletter.id}`}> <a href={`?page=mailpoet-newsletter-editor&id=${newsletter.id}`}>
@@ -132,6 +133,7 @@ const newsletterActions = [
}, },
{ {
name: 'duplicate', name: 'duplicate',
className: 'mailpoet-hide-on-mobile',
label: MailPoet.I18n.t('duplicate'), label: MailPoet.I18n.t('duplicate'),
onClick: function onClick(newsletter, refresh) { onClick: function onClick(newsletter, refresh) {
return MailPoet.Ajax.post({ return MailPoet.Ajax.post({
@@ -160,6 +162,7 @@ const newsletterActions = [
}, },
{ {
name: 'trash', name: 'trash',
className: 'mailpoet-hide-on-mobile',
}, },
]; ];

View File

@@ -110,6 +110,7 @@ const newsletterActions = addStatsCTAAction([
}, },
{ {
name: 'trash', name: 'trash',
className: 'mailpoet-hide-on-mobile',
}, },
]); ]);

View File

@@ -133,11 +133,13 @@ let newsletterActions = [
}, },
{ {
name: 'edit', name: 'edit',
className: 'mailpoet-hide-on-mobile',
label: MailPoet.I18n.t('edit'), label: MailPoet.I18n.t('edit'),
onClick: confirmEdit, onClick: confirmEdit,
}, },
{ {
name: 'duplicate', name: 'duplicate',
className: 'mailpoet-hide-on-mobile',
label: MailPoet.I18n.t('duplicate'), label: MailPoet.I18n.t('duplicate'),
onClick: function onClick(newsletter, refresh) { onClick: function onClick(newsletter, refresh) {
return MailPoet.Ajax.post({ return MailPoet.Ajax.post({
@@ -166,6 +168,7 @@ let newsletterActions = [
}, },
{ {
name: 'trash', name: 'trash',
className: 'mailpoet-hide-on-mobile',
}, },
]; ];
newsletterActions = addStatsCTAAction(newsletterActions); newsletterActions = addStatsCTAAction(newsletterActions);

View File

@@ -120,6 +120,7 @@ let newsletterActions = [
}, },
{ {
name: 'duplicate', name: 'duplicate',
className: 'mailpoet-hide-on-mobile',
label: MailPoet.I18n.t('duplicate'), label: MailPoet.I18n.t('duplicate'),
onClick: (newsletter, refresh) => MailPoet.Ajax.post({ onClick: (newsletter, refresh) => MailPoet.Ajax.post({
api_version: window.mailpoet_api_version, api_version: window.mailpoet_api_version,
@@ -142,6 +143,7 @@ let newsletterActions = [
}, },
{ {
name: 'edit', name: 'edit',
className: 'mailpoet-hide-on-mobile',
link: function link(newsletter) { link: function link(newsletter) {
return ( return (
<a href={`?page=mailpoet-newsletter-editor&id=${newsletter.id}`}> <a href={`?page=mailpoet-newsletter-editor&id=${newsletter.id}`}>
@@ -152,6 +154,7 @@ let newsletterActions = [
}, },
{ {
name: 'trash', name: 'trash',
className: 'mailpoet-hide-on-mobile',
}, },
]; ];
newsletterActions = addStatsCTAAction(newsletterActions); newsletterActions = addStatsCTAAction(newsletterActions);

View File

@@ -85,6 +85,7 @@ const messages = {
const itemActions = [ const itemActions = [
{ {
name: 'edit', name: 'edit',
className: 'mailpoet-hide-on-mobile',
link: (item) => ( link: (item) => (
<Link to={`/edit-segment/${item.id}`}> <Link to={`/edit-segment/${item.id}`}>
{MailPoet.I18n.t('edit')} {MailPoet.I18n.t('edit')}
@@ -101,6 +102,7 @@ const itemActions = [
}, },
{ {
name: 'trash', name: 'trash',
className: 'mailpoet-hide-on-mobile',
}, },
]; ];

View File

@@ -108,6 +108,7 @@ const bulkActions = [
const itemActions = [ const itemActions = [
{ {
name: 'edit', name: 'edit',
className: 'mailpoet-hide-on-mobile',
link: function link(item) { link: function link(item) {
return ( return (
<Link to={`/edit/${item.id}`}>{MailPoet.I18n.t('edit')}</Link> <Link to={`/edit/${item.id}`}>{MailPoet.I18n.t('edit')}</Link>
@@ -119,6 +120,7 @@ const itemActions = [
}, },
{ {
name: 'duplicate_segment', name: 'duplicate_segment',
className: 'mailpoet-hide-on-mobile',
label: MailPoet.I18n.t('duplicate'), label: MailPoet.I18n.t('duplicate'),
onClick: (item, refresh) => MailPoet.Ajax.post({ onClick: (item, refresh) => MailPoet.Ajax.post({
api_version: window.mailpoet_api_version, api_version: window.mailpoet_api_version,
@@ -144,6 +146,7 @@ const itemActions = [
}, },
{ {
name: 'read_more', name: 'read_more',
className: 'mailpoet-hide-on-mobile',
link: function link() { link: function link() {
return ( return (
<a <a
@@ -203,12 +206,14 @@ const itemActions = [
}, },
{ {
name: 'trash', name: 'trash',
className: 'mailpoet-hide-on-mobile',
display: function display(segment) { display: function display(segment) {
return !isSpecialSegment(segment) && segment.automated_emails_subjects.length === 0; return !isSpecialSegment(segment) && segment.automated_emails_subjects.length === 0;
}, },
}, },
{ {
name: 'delete', name: 'delete',
className: 'mailpoet-hide-on-mobile',
label: MailPoet.I18n.t('moveToTrash'), label: MailPoet.I18n.t('moveToTrash'),
onClick: function onClick(segment) { onClick: function onClick(segment) {
MailPoet.Notice.error( MailPoet.Notice.error(

View File

@@ -266,6 +266,7 @@ const itemActions = [
}, },
{ {
name: 'sendConfirmationEmail', name: 'sendConfirmationEmail',
className: 'mailpoet-hide-on-mobile',
label: MailPoet.I18n.t('resendConfirmationEmail'), label: MailPoet.I18n.t('resendConfirmationEmail'),
display: function display(subscriber) { display: function display(subscriber) {
return subscriber.status === 'unconfirmed' && subscriber.count_confirmations < window.mailpoet_max_confirmation_emails; return subscriber.status === 'unconfirmed' && subscriber.count_confirmations < window.mailpoet_max_confirmation_emails;
@@ -285,6 +286,7 @@ const itemActions = [
}, },
{ {
name: 'trash', name: 'trash',
className: 'mailpoet-hide-on-mobile',
}, },
]; ];