diff --git a/ghost/admin/app/controllers/editor.js b/ghost/admin/app/controllers/editor.js index 5271b6a76b..6d075bf3b3 100644 --- a/ghost/admin/app/controllers/editor.js +++ b/ghost/admin/app/controllers/editor.js @@ -3,6 +3,7 @@ import PostModel from 'ghost-admin/models/post'; import boundOneWay from 'ghost-admin/utils/bound-one-way'; import config from 'ghost-admin/config/environment'; import isNumber from 'ghost-admin/utils/isNumber'; +import moment from 'moment'; import {alias, mapBy} from '@ember/object/computed'; import {computed} from '@ember/object'; import {inject as controller} from '@ember/controller'; @@ -88,6 +89,7 @@ export default Controller.extend({ router: service(), slugGenerator: service(), session: service(), + settings: service(), ui: service(), /* public properties -----------------------------------------------------*/ @@ -799,9 +801,14 @@ export default Controller.extend({ return hasDirtyAttributes; }, - _showSaveNotification(prevStatus, status, delay) { - let message = messageMap.success.post[prevStatus][status]; + _showSaveNotification(prevStatus, status, delayed) { + // scheduled messaging is completely custom + if (status === 'scheduled') { + return this._showScheduledNotification(delayed); + } + let notifications = this.notifications; + let message = messageMap.success.post[prevStatus][status]; let actions, type, path; if (status === 'published' || status === 'scheduled') { @@ -814,7 +821,45 @@ export default Controller.extend({ actions = `View ${type}`; } - notifications.showNotification(message, {type: 'success', actions: actions.htmlSafe(), delayed: delay}); + notifications.showNotification(message, {type: 'success', actions: actions.htmlSafe(), delayed}); + }, + + _showScheduledNotification(delayed) { + let { + publishedAtUTC, + sendEmailWhenPublished, + visibility, + previewUrl + } = this.post; + let publishedAtBlogTZ = moment.tz(publishedAtUTC, this.settings.get('timezone')); + + let title = 'Scheduled'; + let description = ['Will be published']; + + if (sendEmailWhenPublished) { + description.push('and delivered to'); + + if (visibility === 'paid') { + description.push('paid members'); + } else { + description.push('all members'); + } + } + + description.push(`on ${publishedAtBlogTZ.format('MMM Mo')}`); + + description.push(`at ${publishedAtBlogTZ.format('HH:mm')}`); + if (publishedAtBlogTZ.utcOffset() === 0) { + description.push('(UTC)'); + } else { + description.push(`(UTC${publishedAtBlogTZ.format('Z').replace(/([+-])0/, '$1').replace(/:00/, '')})`); + } + + description = description.join(' ').htmlSafe(); + + let actions = `View Preview`.htmlSafe(); + + return this.notifications.showNotification(title, {description, actions, type: 'success', delayed}); }, _showErrorAlert(prevStatus, status, error, delay) { diff --git a/ghost/admin/app/styles/components/notifications.css b/ghost/admin/app/styles/components/notifications.css index 6a850f152d..5df8b80af3 100644 --- a/ghost/admin/app/styles/components/notifications.css +++ b/ghost/admin/app/styles/components/notifications.css @@ -55,6 +55,10 @@ max-width: 215px; } +.gh-notification-content p span { + white-space: nowrap; +} + .gh-notification-title { display: block; margin-top: 1px; @@ -122,7 +126,7 @@ animation-duration: 0.8s, 0.35s; animation-iteration-count: 1; animation-timing-function: cubic-bezier(0.445, 0.050, 0.550, 0.950); -} +} .gh-notification-passive:hover { animation: notification-fade-in-spring;