diff --git a/app/soapbox/features/compose/components/compose_form.js b/app/soapbox/features/compose/components/compose_form.js
index 42d2cd826..c6a17b2c2 100644
--- a/app/soapbox/features/compose/components/compose_form.js
+++ b/app/soapbox/features/compose/components/compose_form.js
@@ -35,6 +35,7 @@ const messages = defineMessages({
spoiler_placeholder: { id: 'compose_form.spoiler_placeholder', defaultMessage: 'Write your warning here' },
publish: { id: 'compose_form.publish', defaultMessage: 'Publish' },
publishLoud: { id: 'compose_form.publish_loud', defaultMessage: '{publish}!' },
+ schedule: { id: 'compose_form.schedule', defaultMessage: 'Schedule' },
});
export default @injectIntl
@@ -262,6 +263,10 @@ class ComposeForm extends ImmutablePureComponent {
publishText = this.props.privacy !== 'unlisted' ? intl.formatMessage(messages.publishLoud, { publish: intl.formatMessage(messages.publish) }) : intl.formatMessage(messages.publish);
}
+ if (this.props.scheduledAt) {
+ publishText = intl.formatMessage(messages.schedule);
+ }
+
const composeClassNames = classNames({
'compose-form': true,
'condensed': condensed,
diff --git a/app/soapbox/features/compose/components/schedule_form.js b/app/soapbox/features/compose/components/schedule_form.js
index ad444ec95..bb6304a9f 100644
--- a/app/soapbox/features/compose/components/schedule_form.js
+++ b/app/soapbox/features/compose/components/schedule_form.js
@@ -3,25 +3,34 @@
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
-import { defineMessages, injectIntl } from 'react-intl';
+import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';
+import IconButton from 'soapbox/components/icon_button';
+import { removeSchedule } from 'soapbox/actions/compose';
const messages = defineMessages({
schedule: { id: 'schedule.post_time', defaultMessage: 'Post Date/Time' },
+ remove: { id: 'schedule.remove', defaultMessage: 'Remove schedule' },
});
+const mapStateToProps = (state, ownProps) => ({
+ scheduledAt: state.getIn(['compose', 'schedule']),
+});
+
+export default @connect(mapStateToProps)
+@injectIntl
class ScheduleForm extends React.Component {
static propTypes = {
- schedule: PropTypes.instanceOf(Date),
+ scheduledAt: PropTypes.instanceOf(Date),
intl: PropTypes.object.isRequired,
onSchedule: PropTypes.func.isRequired,
+ dispatch: PropTypes.func,
active: PropTypes.bool,
};
- setSchedule(date) {
- this.setState({ schedule: date });
+ setSchedule = date => {
this.props.onSchedule(date);
}
@@ -33,16 +42,6 @@ class ScheduleForm extends React.Component {
datePicker.setOpen(true);
}
- componentDidMount() {
- this.setState({ schedule: this.props.schedule });
- }
-
- constructor(props) {
- super(props);
-
- this.setSchedule = this.setSchedule.bind(this);
- }
-
isCurrentOrFutureDate(date) {
return date && new Date().setHours(0, 0, 0, 0) <= new Date(date).setHours(0, 0, 0, 0);
}
@@ -54,33 +53,42 @@ class ScheduleForm extends React.Component {
return fiveMinutesFromNow.getTime() < selectedDate.getTime();
};
+ handleRemove = e => {
+ this.props.dispatch(removeSchedule());
+ e.preventDefault();
+ }
+
render() {
- if (!this.props.active || !this.state) {
+ if (!this.props.active) {
return null;
}
- const { schedule } = this.state;
+ const { intl, scheduledAt } = this.props;
return (
-