2018-01-11 01:57:43 +03:00
|
|
|
/* eslint-disable ghost/ember/alias-model-in-controller */
|
2018-01-09 13:36:41 +03:00
|
|
|
import Controller from '@ember/controller';
|
2018-10-04 14:16:41 +03:00
|
|
|
import config from 'ghost-admin/config/environment';
|
2019-04-04 14:25:16 +03:00
|
|
|
import copyTextToClipboard from 'ghost-admin/utils/copy-text-to-clipboard';
|
|
|
|
import {alias} from '@ember/object/computed';
|
|
|
|
import {computed} from '@ember/object';
|
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
import {task, timeout} from 'ember-concurrency';
|
2018-01-09 13:36:41 +03:00
|
|
|
|
|
|
|
export default Controller.extend({
|
2019-04-04 14:25:16 +03:00
|
|
|
ghostPaths: service(),
|
|
|
|
|
2018-10-04 14:16:41 +03:00
|
|
|
isTesting: undefined,
|
|
|
|
|
|
|
|
init() {
|
|
|
|
this._super(...arguments);
|
|
|
|
if (this.isTesting === undefined) {
|
|
|
|
this.isTesting = config.environment === 'test';
|
|
|
|
}
|
2019-04-04 14:25:16 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
integration: alias('model'),
|
|
|
|
|
|
|
|
apiUrl: computed(function () {
|
|
|
|
let origin = window.location.origin;
|
|
|
|
let subdir = this.ghostPaths.subdir;
|
|
|
|
let url = this.ghostPaths.url.join(origin, subdir);
|
|
|
|
|
|
|
|
return url.replace(/\/$/, '');
|
|
|
|
}),
|
|
|
|
|
|
|
|
copyAdminKey: task(function* () {
|
|
|
|
copyTextToClipboard(this.integration.adminKey.secret);
|
|
|
|
yield timeout(3000);
|
|
|
|
}),
|
|
|
|
|
|
|
|
copyApiUrl: task(function* () {
|
|
|
|
copyTextToClipboard(this.apiUrl);
|
|
|
|
yield timeout(3000);
|
|
|
|
})
|
2018-01-09 13:36:41 +03:00
|
|
|
});
|