open-vault/ui/app/models/pki-certificate-sign.js

36 lines
983 B
JavaScript
Raw Normal View History

import { copy } from 'ember-copy';
import { computed } from '@ember/object';
2018-04-03 14:16:57 +00:00
import DS from 'ember-data';
import Certificate from './pki-certificate';
2019-02-14 18:52:34 +00:00
import { combineFieldGroups } from 'vault/utils/openapi-to-attrs';
2018-04-03 14:16:57 +00:00
const { attr } = DS;
export default Certificate.extend({
signVerbatim: attr('boolean', {
readOnly: true,
defaultValue: false,
}),
2019-02-14 18:52:34 +00:00
useOpenAPI: true,
2018-04-03 14:16:57 +00:00
csr: attr('string', {
label: 'Certificate Signing Request (CSR)',
editType: 'textarea',
}),
fieldGroups: computed('signVerbatim', function() {
const options = { Options: ['altNames', 'ipSans', 'ttl', 'excludeCnFromSans', 'otherSans'] };
2019-02-14 18:52:34 +00:00
let groups = [
2018-04-03 14:16:57 +00:00
{
default: ['csr', 'commonName', 'format', 'signVerbatim'],
},
];
2019-02-14 18:52:34 +00:00
if (this.newFields) {
groups = combineFieldGroups(groups, this.newFields, []);
}
2018-04-03 14:16:57 +00:00
if (this.get('signVerbatim') === false) {
groups.push(options);
}
return this.fieldsToAttrs(copy(groups, true));
2018-04-03 14:16:57 +00:00
}),
});