Add component with message about cache on subscriber list page
[MAILPOET-3646]
This commit is contained in:
@@ -82,3 +82,9 @@ p.sender_email_address_warning:first-child {
|
|||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mailpoet-subscribers-cache-notice {
|
||||||
|
.mailpoet-subscribers-cache-notice-button {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
40
assets/js/src/common/subscribers_cache_message.tsx
Normal file
40
assets/js/src/common/subscribers_cache_message.tsx
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import MailPoet from 'mailpoet';
|
||||||
|
import Button from 'common/button/button';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
cacheCalculation: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRecalculate = () => {
|
||||||
|
window.location.reload();
|
||||||
|
};
|
||||||
|
|
||||||
|
const SubscribersCacheMessage = ({ cacheCalculation }: Props): JSX.Element => {
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const datetimeDiff = new Date().getTime() - new Date(cacheCalculation).getTime();
|
||||||
|
const minutes = Math.floor((datetimeDiff / 1000) / 60);
|
||||||
|
return (
|
||||||
|
<div className="mailpoet-subscribers-cache-notice">
|
||||||
|
{MailPoet.I18n.t('subscribersCountWereCalculated')}
|
||||||
|
|
||||||
|
<abbr title={cacheCalculation}>{`${String(minutes)} ${String(MailPoet.I18n.t('subscribersMinutesAgo'))}`}</abbr>
|
||||||
|
<Button
|
||||||
|
className="mailpoet-subscribers-cache-notice-button"
|
||||||
|
type="button"
|
||||||
|
variant="secondary"
|
||||||
|
dimension="small"
|
||||||
|
onClick={() => {
|
||||||
|
setLoading(true);
|
||||||
|
handleRecalculate();
|
||||||
|
}}
|
||||||
|
withSpinner={loading}
|
||||||
|
>
|
||||||
|
{MailPoet.I18n.t('recalculateNow')}
|
||||||
|
</Button>
|
||||||
|
<div className="mailpoet-gap" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { SubscribersCacheMessage };
|
@@ -6,6 +6,7 @@ import plusIcon from 'common/button/icon/plus';
|
|||||||
import SubscribersInPlan from 'common/subscribers_in_plan';
|
import SubscribersInPlan from 'common/subscribers_in_plan';
|
||||||
import SubscribersLimitNotice from 'notices/subscribers_limit_notice';
|
import SubscribersLimitNotice from 'notices/subscribers_limit_notice';
|
||||||
import InvalidMssKeyNotice from 'notices/invalid_mss_key_notice';
|
import InvalidMssKeyNotice from 'notices/invalid_mss_key_notice';
|
||||||
|
import { SubscribersCacheMessage } from 'common/subscribers_cache_message';
|
||||||
|
|
||||||
const ListHeading = () => (
|
const ListHeading = () => (
|
||||||
<>
|
<>
|
||||||
@@ -25,6 +26,8 @@ const ListHeading = () => (
|
|||||||
subscribersInPlanLimit={MailPoet.subscribersLimit}
|
subscribersInPlanLimit={MailPoet.subscribersLimit}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<SubscribersCacheMessage cacheCalculation="2021-06-28 18:22:00" />
|
||||||
|
|
||||||
<SubscribersLimitNotice />
|
<SubscribersLimitNotice />
|
||||||
<InvalidMssKeyNotice
|
<InvalidMssKeyNotice
|
||||||
mssKeyInvalid={MailPoet.hasInvalidMssApiKey}
|
mssKeyInvalid={MailPoet.hasInvalidMssApiKey}
|
||||||
|
@@ -225,5 +225,9 @@
|
|||||||
'anyConditions': _x('<strong>Any</strong> of the following conditions', 'Dynamic segment creation: The user can select join between condition when he has more than one'),
|
'anyConditions': _x('<strong>Any</strong> of the following conditions', 'Dynamic segment creation: The user can select join between condition when he has more than one'),
|
||||||
'filterConnectAnd': _x('and', 'Dynamic segment creation: The user can see logical operator between condition when has more than one'),
|
'filterConnectAnd': _x('and', 'Dynamic segment creation: The user can see logical operator between condition when has more than one'),
|
||||||
'filterConnectOr': _x('or', 'Dynamic segment creation: The user can see logical operator between condition when has more than one'),
|
'filterConnectOr': _x('or', 'Dynamic segment creation: The user can see logical operator between condition when has more than one'),
|
||||||
|
|
||||||
|
'subscribersCountWereCalculated': __('Lists and Segments subscribers counts were calculated'),
|
||||||
|
'subscribersMinutesAgo': __('minutes ago'),
|
||||||
|
'recalculateNow': __('Recalculate now'),
|
||||||
}) %>
|
}) %>
|
||||||
<% endblock %>
|
<% endblock %>
|
||||||
|
Reference in New Issue
Block a user