Revert "Display user's time in scheduling emails"

This reverts commit 4624ac2a92.
This commit is contained in:
Pavel Dohnal
2019-04-29 16:22:05 +02:00
committed by M. Shull
parent 87d5c802cc
commit b8000c872c
7 changed files with 20 additions and 46 deletions

View File

@ -1,7 +1,6 @@
import mp from 'mailpoet'; import mp from 'mailpoet';
import jQuery from 'jquery'; import jQuery from 'jquery';
import Moment from 'moment'; import Moment from 'moment';
import MomentTZ from 'moment-timezone';
var MailPoet = mp; var MailPoet = mp;
@ -64,12 +63,6 @@ MailPoet.Date = {
format: 'H:i:s', format: 'H:i:s',
}); });
}, },
convertToServerTimeZone: function convertToServerTimeZone(date, serverTimezone) {
return MomentTZ(date).tz(serverTimezone).format('YYYY-MM-DD HH:mm:ss');
},
convertToUserTimeZone: function convertToUserTimeZone(date, serverTimezone) {
return MomentTZ.tz(date, serverTimezone).local().format('YYYY-MM-DD HH:mm:ss');
},
convertFormat: function convertFormat(format) { convertFormat: function convertFormat(format) {
var replacements; var replacements;
var convertedFormat; var convertedFormat;

View File

@ -67,13 +67,7 @@ const QueueMixin = {
<span> <span>
{ MailPoet.I18n.t('scheduledFor') } { MailPoet.I18n.t('scheduledFor') }
{' '} {' '}
{ { MailPoet.Date.format(newsletter.queue.scheduled_at) }
MailPoet.Date.format(
MailPoet.Date.convertToUserTimeZone(
newsletter.queue.scheduled_at, window.mailpoet_server_time_zone
)
)
}
</span> </span>
); );
} }

View File

@ -7,7 +7,7 @@ import PropTypes from 'prop-types';
import DateTime from 'newsletters/send/date_time.jsx'; import DateTime from 'newsletters/send/date_time.jsx';
import SenderField from 'newsletters/send/sender_address_field.jsx'; import SenderField from 'newsletters/send/sender_address_field.jsx';
const serverTimezone = window.mailpoet_server_time_zone; const currentTime = window.mailpoet_current_time || '00:00';
const defaultDateTime = `${window.mailpoet_current_date} 00:00:00`; const defaultDateTime = `${window.mailpoet_current_date} 00:00:00`;
const timeOfDayItems = window.mailpoet_schedule_time_of_day; const timeOfDayItems = window.mailpoet_schedule_time_of_day;
const dateDisplayFormat = window.mailpoet_date_display_format; const dateDisplayFormat = window.mailpoet_date_display_format;
@ -17,7 +17,7 @@ class StandardScheduling extends React.Component {
getCurrentValue = () => { getCurrentValue = () => {
const schedulingOptions = { const schedulingOptions = {
isScheduled: '0', isScheduled: '0',
scheduledAt: MailPoet.Date.convertToServerTimeZone(defaultDateTime, serverTimezone), scheduledAt: defaultDateTime,
}; };
return _.defaults( return _.defaults(
this.props.item[this.props.field.name] || {}, this.props.item[this.props.field.name] || {},
@ -33,23 +33,16 @@ class StandardScheduling extends React.Component {
isScheduled = () => this.getCurrentValue().isScheduled === '1'; isScheduled = () => this.getCurrentValue().isScheduled === '1';
handleCheckboxChange = event => this.handleValueChange({ handleCheckboxChange = (event) => {
name: event.target.name, const changeEvent = event;
value: event.target.checked ? '1' : '0', changeEvent.target.value = event.target.checked ? '1' : '0';
}); return this.handleValueChange(changeEvent);
handleTimeChange = (event) => {
const value = MailPoet.Date.convertToServerTimeZone(event.target.value, serverTimezone);
return this.handleValueChange({
name: event.target.name,
value,
});
}; };
handleValueChange = (value) => { handleValueChange = (event) => {
const oldValue = this.getCurrentValue(); const oldValue = this.getCurrentValue();
const newValue = {}; const newValue = {};
newValue[value.name] = value.value; newValue[event.target.name] = event.target.value;
return this.props.onValueChange({ return this.props.onValueChange({
target: { target: {
@ -67,12 +60,8 @@ class StandardScheduling extends React.Component {
<span id="mailpoet_scheduling"> <span id="mailpoet_scheduling">
<DateTime <DateTime
name="scheduledAt" name="scheduledAt"
value={ value={this.getCurrentValue().scheduledAt}
MailPoet.Date.convertToUserTimeZone( onChange={this.handleValueChange}
this.getCurrentValue().scheduledAt, serverTimezone
)
}
onChange={this.handleTimeChange}
disabled={this.props.field.disabled} disabled={this.props.field.disabled}
dateValidation={this.getDateValidation()} dateValidation={this.getDateValidation()}
defaultDateTime={defaultDateTime} defaultDateTime={defaultDateTime}
@ -80,6 +69,12 @@ class StandardScheduling extends React.Component {
dateDisplayFormat={dateDisplayFormat} dateDisplayFormat={dateDisplayFormat}
dateStorageFormat={dateStorageFormat} dateStorageFormat={dateStorageFormat}
/> />
&nbsp;
<span>
{MailPoet.I18n.t('websiteTimeIs')}
{' '}
<code>{currentTime}</code>
</span>
</span> </span>
); );
} }

View File

@ -647,7 +647,7 @@ class Menu {
$date_time = new DateTime(); $date_time = new DateTime();
$data['current_date'] = $date_time->getCurrentDate(DateTime::DEFAULT_DATE_FORMAT); $data['current_date'] = $date_time->getCurrentDate(DateTime::DEFAULT_DATE_FORMAT);
$data['current_time_zone'] = (new Carbon())->getTimezone()->getName(); $data['current_time'] = $date_time->getCurrentTime();
$data['schedule_time_of_day'] = $date_time->getTimeInterval( $data['schedule_time_of_day'] = $date_time->getTimeInterval(
'00:00:00', '00:00:00',
'+1 hour', '+1 hour',

8
package-lock.json generated
View File

@ -7354,14 +7354,6 @@
"resolved": "https://registry.npmjs.org/moment/-/moment-2.22.1.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.1.tgz",
"integrity": "sha512-shJkRTSebXvsVqk56I+lkb2latjBs8I+pc2TzWc545y2iFnSjm7Wg0QMh+ZWcdSLQyGEau5jI8ocnmkyTgr9YQ==" "integrity": "sha512-shJkRTSebXvsVqk56I+lkb2latjBs8I+pc2TzWc545y2iFnSjm7Wg0QMh+ZWcdSLQyGEau5jI8ocnmkyTgr9YQ=="
}, },
"moment-timezone": {
"version": "0.5.23",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.23.tgz",
"integrity": "sha512-WHFH85DkCfiNMDX5D3X7hpNH3/PUhjTGcD0U1SgfBGZxJ3qUmJh5FdvaFjcClxOvB3rzdfj4oRffbI38jEnC1w==",
"requires": {
"moment": ">= 2.9.0"
}
},
"move-concurrently": { "move-concurrently": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",

View File

@ -37,7 +37,6 @@
"intro.js": "2.9.0", "intro.js": "2.9.0",
"jquery": "3.3.1", "jquery": "3.3.1",
"moment": "^2.22.1", "moment": "^2.22.1",
"moment-timezone": "^0.5.23",
"papaparse": "4.1.1", "papaparse": "4.1.1",
"parsleyjs": "^2.8.1", "parsleyjs": "^2.8.1",
"prop-types": "^15.6.2", "prop-types": "^15.6.2",

View File

@ -14,7 +14,7 @@
var mailpoet_lists = <%= json_encode(lists) %>; var mailpoet_lists = <%= json_encode(lists) %>;
var mailpoet_roles = <%= json_encode(roles) %>; var mailpoet_roles = <%= json_encode(roles) %>;
var mailpoet_current_date = <%= json_encode(current_date) %>; var mailpoet_current_date = <%= json_encode(current_date) %>;
var mailpoet_server_time_zone = <%= json_encode(current_time_zone) %>; var mailpoet_current_time = <%= json_encode(current_time) %>;
var mailpoet_schedule_time_of_day = <%= json_encode(schedule_time_of_day) %>; var mailpoet_schedule_time_of_day = <%= json_encode(schedule_time_of_day) %>;
var mailpoet_date_display_format = "<%= wp_date_format() %>"; var mailpoet_date_display_format = "<%= wp_date_format() %>";
var mailpoet_start_of_week = "<%= wp_start_of_week() %>"; var mailpoet_start_of_week = "<%= wp_start_of_week() %>";
@ -209,6 +209,7 @@
'helpTooltipSendEmail': __('You cannot send the same email twice, as that would be considered spam. <br /> If you must send the same email more than one time, simply duplicate this email first.'), 'helpTooltipSendEmail': __('You cannot send the same email twice, as that would be considered spam. <br /> If you must send the same email more than one time, simply duplicate this email first.'),
'orSimply': __('or simply'), 'orSimply': __('or simply'),
'goBackToDesign': __('go back to the Design page'), 'goBackToDesign': __('go back to the Design page'),
'websiteTimeIs': __("Your websites time is"),
'noScheduledDateError': __('Please enter the scheduled date.'), 'noScheduledDateError': __('Please enter the scheduled date.'),
'schedule': __('Schedule'), 'schedule': __('Schedule'),