2020-02-27 06:50:15 +03:00
|
|
|
import ModalComponent from 'ghost-admin/components/modal-base';
|
|
|
|
import copyTextToClipboard from 'ghost-admin/utils/copy-text-to-clipboard';
|
|
|
|
import {alias} from '@ember/object/computed';
|
2022-11-03 14:14:36 +03:00
|
|
|
import {inject} from 'ghost-admin/decorators/inject';
|
2020-02-27 06:50:15 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
import {task, timeout} from 'ember-concurrency';
|
|
|
|
|
|
|
|
export default ModalComponent.extend({
|
|
|
|
store: service(),
|
|
|
|
|
|
|
|
classNames: 'modal-impersonate-member',
|
|
|
|
|
|
|
|
signinUrl: null,
|
2022-11-03 14:14:36 +03:00
|
|
|
config: inject(),
|
|
|
|
|
2020-02-27 06:50:15 +03:00
|
|
|
member: alias('model'),
|
|
|
|
|
|
|
|
didInsertElement() {
|
|
|
|
this._super(...arguments);
|
|
|
|
|
|
|
|
this._signinUrlUpdateTask.perform();
|
|
|
|
},
|
|
|
|
|
2021-06-18 12:12:36 +03:00
|
|
|
actions: {
|
|
|
|
// noop - we don't want the enter key doing anything
|
|
|
|
confirm() {}
|
|
|
|
},
|
|
|
|
|
2020-02-27 06:50:15 +03:00
|
|
|
copySigninUrl: task(function* () {
|
2022-01-21 22:25:47 +03:00
|
|
|
copyTextToClipboard(this.signinUrl);
|
2020-02-27 06:50:15 +03:00
|
|
|
yield timeout(1000);
|
|
|
|
return true;
|
|
|
|
}),
|
|
|
|
|
|
|
|
_signinUrlUpdateTask: task(function*() {
|
|
|
|
const memberSigninURL = yield this.member.fetchSigninUrl.perform();
|
|
|
|
|
|
|
|
this.set('signinUrl', memberSigninURL.url);
|
|
|
|
}).drop()
|
|
|
|
});
|