mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-27 21:03:29 +03:00
d52347118c
no refs After making changes to code injection settings, currently exiting bricks the Admin due to incorrect save task naming in code injection settings. The fix updates the name for saveTask
67 lines
2.0 KiB
JavaScript
67 lines
2.0 KiB
JavaScript
/* eslint-disable ghost/ember/alias-model-in-controller */
|
|
import Controller from '@ember/controller';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency';
|
|
|
|
export default Controller.extend({
|
|
notifications: service(),
|
|
settings: service(),
|
|
|
|
actions: {
|
|
save() {
|
|
this.saveTask.perform();
|
|
},
|
|
|
|
toggleLeaveSettingsModal(transition) {
|
|
let leaveTransition = this.leaveSettingsTransition;
|
|
|
|
if (!transition && this.showLeaveSettingsModal) {
|
|
this.set('leaveSettingsTransition', null);
|
|
this.set('showLeaveSettingsModal', false);
|
|
return;
|
|
}
|
|
|
|
if (!leaveTransition || transition.targetName === leaveTransition.targetName) {
|
|
this.set('leaveSettingsTransition', transition);
|
|
|
|
// if a save is running, wait for it to finish then transition
|
|
if (this.saveTask.isRunning) {
|
|
return this.saveTask.last.then(() => {
|
|
transition.retry();
|
|
});
|
|
}
|
|
|
|
// we genuinely have unsaved data, show the modal
|
|
this.set('showLeaveSettingsModal', true);
|
|
}
|
|
},
|
|
|
|
leaveSettings() {
|
|
let transition = this.leaveSettingsTransition;
|
|
let settings = this.settings;
|
|
|
|
if (!transition) {
|
|
this.notifications.showAlert('Sorry, there was an error in the application. Please let the Ghost team know what happened.', {type: 'error'});
|
|
return;
|
|
}
|
|
|
|
// roll back changes on settings props
|
|
settings.rollbackAttributes();
|
|
|
|
return transition.retry();
|
|
}
|
|
|
|
},
|
|
|
|
saveTask: task(function* () {
|
|
let notifications = this.notifications;
|
|
|
|
try {
|
|
return yield this.settings.save();
|
|
} catch (error) {
|
|
notifications.showAPIError(error, {key: 'code-injection.save'});
|
|
throw error;
|
|
}
|
|
})
|
|
});
|