open-vault/ui/app/components/control-group-success.js
Jordan Reimer 52fe56ec87
Eslint prefer-const (#17864)
* adds prefer-const to eslint config and runs fixer

* reverts unintended change
2022-11-09 15:15:31 -08:00

36 lines
1,012 B
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) {
const adapter = this.store.adapterFor('tools');
this.set('error', null);
try {
const response = yield adapter.toolAction('unwrap', null, { clientToken: token });
this.set('unwrapData', response.auth || response.data);
this.controlGroup.deleteControlGroupToken(this.model.id);
} catch (e) {
this.set('error', `Token unwrap failed: ${e.errors[0]}`);
}
}).drop(),
markAndNavigate: task(function* () {
this.controlGroup.markTokenForUnwrap(this.model.id);
const { url } = this.controlGroupResponse.uiParams;
yield this.router.transitionTo(url);
}).drop(),
});