mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
updated to use new model._meta
- use model._meta to access the meta object in the delete response - removed unused `_deleteUser` method - move the success/failure method bodies into the main `deleteUser` task to improve readability - added a timeout after calling `_exportDb()` so that the iframe is not removed from the DOM immediately after it's `src` value is set due to a transition away from the member screen
This commit is contained in:
parent
7bb24df7b9
commit
9186280ac9
2 changed files with 13 additions and 17 deletions
|
@ -8,7 +8,7 @@ import {computed} from '@ember/object';
|
||||||
import {isArray as isEmberArray} from '@ember/array';
|
import {isArray as isEmberArray} from '@ember/array';
|
||||||
import {run} from '@ember/runloop';
|
import {run} from '@ember/runloop';
|
||||||
import {inject as service} from '@ember/service';
|
import {inject as service} from '@ember/service';
|
||||||
import {task, taskGroup} from 'ember-concurrency';
|
import {task, taskGroup, timeout} from 'ember-concurrency';
|
||||||
|
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
ajax: service(),
|
ajax: service(),
|
||||||
|
@ -331,16 +331,6 @@ export default Controller.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_deleteUserSuccess() {
|
|
||||||
this.notifications.closeAlerts('user.delete');
|
|
||||||
this.store.unloadAll('post');
|
|
||||||
this.transitionToRoute('staff');
|
|
||||||
},
|
|
||||||
|
|
||||||
_deleteUserFailure() {
|
|
||||||
this.notifications.showAlert('The user could not be deleted. Please try again.', {type: 'error', key: 'user.delete.failed'});
|
|
||||||
},
|
|
||||||
|
|
||||||
_exportDb(filename) {
|
_exportDb(filename) {
|
||||||
let exportUrl = this.get('ghostPaths.url').api('db');
|
let exportUrl = this.get('ghostPaths.url').api('db');
|
||||||
let downloadURL = `${exportUrl}?filename=${filename}`;
|
let downloadURL = `${exportUrl}?filename=${filename}`;
|
||||||
|
@ -360,13 +350,19 @@ export default Controller.extend({
|
||||||
try {
|
try {
|
||||||
const result = yield this.user.destroyRecord();
|
const result = yield this.user.destroyRecord();
|
||||||
|
|
||||||
if (result.get('meta') && result.get('meta.filename')) {
|
if (result._meta && result._meta.filename) {
|
||||||
yield this._exportDb(result.meta.filename);
|
this._exportDb(result._meta.filename);
|
||||||
|
// give the iframe some time to trigger the download before
|
||||||
|
// it's removed from the dom when transitioning
|
||||||
|
yield timeout(300);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._deleteUserSuccess();
|
this.notifications.closeAlerts('user.delete');
|
||||||
} catch {
|
this.store.unloadAll('post');
|
||||||
this._deleteUserFailure();
|
this.transitionToRoute('staff');
|
||||||
|
} catch (error) {
|
||||||
|
this.notifications.showAlert('The user could not be deleted. Please try again.', {type: 'error', key: 'user.delete.failed'});
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import Model from 'ember-data/model';
|
import Model from '@ember-data/model';
|
||||||
|
|
||||||
export default Model.extend({
|
export default Model.extend({
|
||||||
// this is a hack that gives us access to meta data in single resource responses
|
// this is a hack that gives us access to meta data in single resource responses
|
||||||
|
|
Loading…
Add table
Reference in a new issue