mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-28 14:11:10 +01:00
UI - add description as helpText, and add sensitive from x-vault-displaySensitive (#6411)
* add description from openAPI as helpText in the models, and add sensitive from x-vault-displaySensitive * use TypeDurationSecond for TTLs on the GitHub auth method config * remove empty vals in a loop and add tests * hold off on changing GH config * remove isEmpty import * fix defaultValue
This commit is contained in:
parent
f5dbe1933a
commit
96f7ccd71e
@ -2,6 +2,7 @@ import DS from 'ember-data';
|
|||||||
const { attr } = DS;
|
const { attr } = DS;
|
||||||
import { assign } from '@ember/polyfills';
|
import { assign } from '@ember/polyfills';
|
||||||
import { isEmpty } from '@ember/utils';
|
import { isEmpty } from '@ember/utils';
|
||||||
|
import { camelize, capitalize } from '@ember/string';
|
||||||
|
|
||||||
export const expandOpenApiProps = function(props) {
|
export const expandOpenApiProps = function(props) {
|
||||||
let attrs = {};
|
let attrs = {};
|
||||||
@ -18,25 +19,25 @@ export const expandOpenApiProps = function(props) {
|
|||||||
if (details.format === 'seconds') {
|
if (details.format === 'seconds') {
|
||||||
editType = 'ttl';
|
editType = 'ttl';
|
||||||
} else if (details.items) {
|
} else if (details.items) {
|
||||||
editType = details.items.type + details.type.capitalize();
|
editType = details.items.type + capitalize(details.type);
|
||||||
}
|
}
|
||||||
attrs[prop.camelize()] = {
|
let attrDefn = {
|
||||||
editType: editType,
|
editType: editType,
|
||||||
type: details.type,
|
type: details.type,
|
||||||
|
helpText: details.description,
|
||||||
|
sensitive: details['x-vault-displaySensitive'],
|
||||||
|
label: details['x-vault-displayName'],
|
||||||
|
possibleValues: details['enum'],
|
||||||
|
defaultValue:
|
||||||
|
details['x-vault-displayValue'] || (!isEmpty(details['default']) ? details['default'] : null),
|
||||||
};
|
};
|
||||||
if (details['x-vault-displayName']) {
|
// loop to remove empty vals
|
||||||
attrs[prop.camelize()].label = details['x-vault-displayName'];
|
for (let attrProp in attrDefn) {
|
||||||
}
|
if (attrDefn[attrProp] == null) {
|
||||||
if (details['enum']) {
|
delete attrDefn[attrProp];
|
||||||
attrs[prop.camelize()].possibleValues = details['enum'];
|
|
||||||
}
|
|
||||||
if (details['x-vault-displayValue']) {
|
|
||||||
attrs[prop.camelize()].defaultValue = details['x-vault-displayValue'];
|
|
||||||
} else {
|
|
||||||
if (!isEmpty(details['default'])) {
|
|
||||||
attrs[prop.camelize()].defaultValue = details['default'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
attrs[camelize(prop)] = attrDefn;
|
||||||
}
|
}
|
||||||
return attrs;
|
return attrs;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,6 +8,7 @@ module('Unit | Util | OpenAPI Data Utilities', function() {
|
|||||||
ttl: {
|
ttl: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
format: 'seconds',
|
format: 'seconds',
|
||||||
|
description: 'this is a TTL!',
|
||||||
'x-vault-displayName': 'TTL',
|
'x-vault-displayName': 'TTL',
|
||||||
},
|
},
|
||||||
'awesome-people': {
|
'awesome-people': {
|
||||||
@ -30,9 +31,15 @@ module('Unit | Util | OpenAPI Data Utilities', function() {
|
|||||||
default: 30,
|
default: 30,
|
||||||
type: 'integer',
|
type: 'integer',
|
||||||
},
|
},
|
||||||
|
'super-secret': {
|
||||||
|
type: 'string',
|
||||||
|
'x-vault-displaySensitive': true,
|
||||||
|
description: 'A really secret thing',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
const EXPANDED_PROPS = {
|
const EXPANDED_PROPS = {
|
||||||
ttl: {
|
ttl: {
|
||||||
|
helpText: 'this is a TTL!',
|
||||||
editType: 'ttl',
|
editType: 'ttl',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
label: 'TTL',
|
label: 'TTL',
|
||||||
@ -57,6 +64,13 @@ module('Unit | Util | OpenAPI Data Utilities', function() {
|
|||||||
type: 'number',
|
type: 'number',
|
||||||
defaultValue: 30,
|
defaultValue: 30,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
superSecret: {
|
||||||
|
type: 'string',
|
||||||
|
editType: 'string',
|
||||||
|
sensitive: true,
|
||||||
|
helpText: 'A really secret thing',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const EXISTING_MODEL_ATTRS = [
|
const EXISTING_MODEL_ATTRS = [
|
||||||
@ -93,6 +107,7 @@ module('Unit | Util | OpenAPI Data Utilities', function() {
|
|||||||
editType: 'ttl',
|
editType: 'ttl',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
label: 'TTL',
|
label: 'TTL',
|
||||||
|
helpText: 'this is a TTL!',
|
||||||
}),
|
}),
|
||||||
awesomePeople: attr({
|
awesomePeople: attr({
|
||||||
label: 'People Who Are Awesome',
|
label: 'People Who Are Awesome',
|
||||||
@ -105,6 +120,12 @@ module('Unit | Util | OpenAPI Data Utilities', function() {
|
|||||||
editType: 'string',
|
editType: 'string',
|
||||||
possibleValues: ['vanilla', 'chocolate', 'strawberry'],
|
possibleValues: ['vanilla', 'chocolate', 'strawberry'],
|
||||||
}),
|
}),
|
||||||
|
superSecret: attr('string', {
|
||||||
|
type: 'string',
|
||||||
|
editType: 'string',
|
||||||
|
sensitive: true,
|
||||||
|
description: 'A really secret thing',
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
const NEW_FIELDS = ['one', 'two', 'three'];
|
const NEW_FIELDS = ['one', 'two', 'three'];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user