vault/ui/app/components/auth-config-form/options.js
Noelle Daley 67454f20e4
ui/storybook/add form components (#6533)
* storybook: add .md suffix to stories blueprint

* storybook: add FormField

* storybook: update AuthConfigForm docs

* storybook: add FormFieldGroups

* storybook: add MaskedInput

* storybook: add example FormField attr

* storybook: remove actions addon
2019-04-05 14:58:55 -07:00

42 lines
1.2 KiB
JavaScript

import AuthConfigComponent from './config';
import { inject as service } from '@ember/service';
import { task } from 'ember-concurrency';
import DS from 'ember-data';
/**
* @module AuthConfigForm/Options
* The `AuthConfigForm/Options` is options portion of the auth config form.
*
* @example
* ```js
* {{auth-config-form/options model.model}}
* ```
*
* @property model=null {DS.Model} - The corresponding auth model that is being configured.
*
*/
export default AuthConfigComponent.extend({
router: service(),
wizard: service(),
saveModel: task(function*() {
let data = this.model.config.serialize();
data.description = this.model.description;
try {
yield this.model.tune(data);
} catch (err) {
// AdapterErrors are handled by the error-message component
// in the form
if (err instanceof DS.AdapterError === false) {
throw err;
}
return;
}
if (this.wizard.currentMachine === 'authentication' && this.wizard.featureState === 'config') {
this.wizard.transitionFeatureMachine(this.wizard.featureState, 'CONTINUE');
}
this.router.transitionTo('vault.cluster.access.methods').followRedirects();
this.flashMessages.success('The configuration was saved successfully.');
}),
});