mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 16:01:40 +03:00
bd348dc297
no issue Updates the labels of the post history components to reflect the type of content (post or page). It modifies the `restore-revision`, `gh-post-settings-menu`, and `modal-post-history` components.
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import {htmlSafe} from '@ember/template';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency';
|
|
|
|
export default class RestoreRevisionModal extends Component {
|
|
@service notifications;
|
|
|
|
get title() {
|
|
return this.args.data.post.isPublished === true
|
|
? `Restore version for published ${this.args.data.post.displayName}?`
|
|
: `Restore this version?`;
|
|
}
|
|
|
|
get body() {
|
|
return this.args.data.post.isPublished === true
|
|
? htmlSafe(`
|
|
Heads up! This ${this.args.data.post.displayName} has already been <strong>published</strong>, restoring a previous
|
|
version will automatically update the ${this.args.data.post.displayName} on your site.
|
|
`)
|
|
: `Replace your existing draft with this version of the ${this.args.data.post.displayName}.`;
|
|
}
|
|
|
|
@task
|
|
*restoreRevisionTask() {
|
|
try {
|
|
const {
|
|
post,
|
|
revision,
|
|
updateTitle,
|
|
updateEditor,
|
|
closePostHistoryModal
|
|
} = this.args.data;
|
|
|
|
post.lexical = revision.lexical;
|
|
post.title = revision.title;
|
|
|
|
yield post.save({adapterOptions: {saveRevision: true}});
|
|
|
|
updateTitle();
|
|
updateEditor();
|
|
|
|
this.notifications.showNotification('Revision successfully restored.', {type: 'success'});
|
|
|
|
closePostHistoryModal();
|
|
|
|
return true;
|
|
} catch (error) {
|
|
this.notifications.showNotification('Failed to restore revision.', {type: 'error'});
|
|
} finally {
|
|
this.args.close();
|
|
}
|
|
}
|
|
}
|