mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 22:02:11 +03:00
a5eeb1865b
refs https://github.com/TryGhost/Ghost/issues/5071 Upgrade messages are now shown on the About screen rather than as alerts. Notifications that are marked as `top` or `custom` are still shown as alerts to allow for certain upgrade messages to be given more visibility. - remove old `upgrade-notification` service - update the `upgrade-status` service: - add a `message` property that contains an upgrade notification if any exists - add a `handleUpgradeNotification` method that accepts a Notification model instance and extracts the `notification.message` property into a html safe string for use in templates - when loading server notifications during app boot, pass notifications that aren't marked as `top` or `custom` to the new `handleUpgradeNotification` method - update the `about.hbs` template to pull the upgrade message from the `upgradeStatus` service
35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
import Service, {inject as service} from '@ember/service';
|
|
import {get, set} from '@ember/object';
|
|
import {htmlSafe} from '@ember/string';
|
|
|
|
export default Service.extend({
|
|
notifications: service(),
|
|
|
|
isRequired: false,
|
|
message: '',
|
|
|
|
// called when notifications are fetched during app boot for notifications
|
|
// where the `location` is not 'top' and `custom` is false
|
|
handleUpgradeNotification(notification) {
|
|
let message = get(notification, 'message');
|
|
set(this, 'message', htmlSafe(message));
|
|
},
|
|
|
|
// called when a MaintenanceError is encountered
|
|
maintenanceAlert() {
|
|
get(this, 'notifications').showAlert(
|
|
'Sorry, Ghost is currently undergoing maintenance, please wait a moment then try again.',
|
|
{type: 'error', key: 'api-error.under-maintenance'}
|
|
);
|
|
},
|
|
|
|
// called when a VersionMismatchError is encountered
|
|
requireUpgrade() {
|
|
set(this, 'isRequired', true);
|
|
get(this, 'notifications').showAlert(
|
|
'Ghost has been upgraded, please copy any unsaved data and refresh the page to continue.',
|
|
{type: 'error', key: 'api-error.upgrade-required'}
|
|
);
|
|
}
|
|
});
|