open-vault/ui/app/components/wizard/mounts-wizard.js

74 lines
2.5 KiB
JavaScript
Raw Normal View History

import { inject as service } from '@ember/service';
import { alias } from '@ember/object/computed';
import Component from '@ember/component';
import { computed } from '@ember/object';
2018-08-28 05:03:55 +00:00
import { engines } from 'vault/helpers/mountable-secret-engines';
import { methods } from 'vault/helpers/mountable-auth-methods';
import { supportedSecretBackends } from 'vault/helpers/supported-secret-backends';
const supportedSecrets = supportedSecretBackends();
import { supportedAuthBackends } from 'vault/helpers/supported-auth-backends';
const supportedAuth = supportedAuthBackends();
export default Component.extend({
wizard: service(),
featureState: alias('wizard.featureState'),
currentState: alias('wizard.currentState'),
currentMachine: alias('wizard.currentMachine'),
mountSubtype: alias('wizard.componentState'),
fullNextStep: alias('wizard.nextStep'),
nextFeature: alias('wizard.nextFeature'),
2018-08-28 05:03:55 +00:00
nextStep: computed('fullNextStep', function() {
return this.get('fullNextStep').split('.').lastObject;
}),
needsEncryption: computed('mountSubtype', function() {
return this.get('mountSubtype') === 'transit';
}),
stepComponent: alias('wizard.stepComponent'),
2018-08-28 05:03:55 +00:00
detailsComponent: computed('mountSubtype', function() {
let suffix = this.get('currentMachine') === 'secrets' ? 'engine' : 'method';
return this.get('mountSubtype') ? `wizard/${this.get('mountSubtype')}-${suffix}` : null;
}),
isSupported: computed('mountSubtype', function() {
if (this.get('currentMachine') === 'secrets') {
return supportedSecrets.includes(this.get('mountSubtype'));
} else {
return supportedAuth.includes(this.get('mountSubtype'));
}
}),
mountName: computed('mountSubtype', function() {
if (this.get('currentMachine') === 'secrets') {
var secret = engines().find(engine => {
return engine.type === this.get('mountSubtype');
});
if (secret) {
return secret.displayName;
}
} else {
var auth = methods().find(method => {
return method.type === this.get('mountSubtype');
});
if (auth) {
return auth.displayName;
}
}
return null;
}),
actionText: computed('mountSubtype', function() {
switch (this.get('mountSubtype')) {
case 'aws':
2019-03-29 23:40:12 +00:00
return 'Generate credential';
2018-08-28 05:03:55 +00:00
case 'ssh':
2019-03-29 23:40:12 +00:00
return 'Sign keys';
2018-08-28 05:03:55 +00:00
case 'pki':
2019-03-29 23:40:12 +00:00
return 'Generate certificate';
2018-08-28 05:03:55 +00:00
default:
return null;
}
}),
onAdvance() {},
onRepeat() {},
onReset() {},
onDone() {},
});