open-vault/ui/app/components/control-group-success.js
Matthew Irish d509588cd2
Ember update (#5386)
Ember update - update ember-cli, ember-data, and ember to 3.4 series
2018-09-25 11:28:26 -05:00

36 lines
1 KiB
JavaScript

import { inject as service } from '@ember/service';
import Component from '@ember/component';
import { task } from 'ember-concurrency';
export default Component.extend({
router: service(),
controlGroup: service(),
store: service(),
// public attrs
model: null,
controlGroupResponse: null,
//internal state
error: null,
unwrapData: null,
unwrap: task(function*(token) {
let adapter = this.get('store').adapterFor('tools');
this.set('error', null);
try {
let response = yield adapter.toolAction('unwrap', null, { clientToken: token });
this.set('unwrapData', response.auth || response.data);
this.get('controlGroup').deleteControlGroupToken(this.get('model.id'));
} catch (e) {
this.set('error', `Token unwrap failed: ${e.errors[0]}`);
}
}).drop(),
markAndNavigate: task(function*() {
this.get('controlGroup').markTokenForUnwrap(this.get('model.id'));
let { url } = this.get('controlGroupResponse.uiParams');
yield this.get('router').transitionTo(url);
}).drop(),
});