Added certificate upload support for Glance in VmWare tab

Added file upload support that allows certificate upload on
the VmWare tab.

Change-Id: I3dcb73f588ed968dd41f5dc2f94ce7538154a9d0
Partial-Bug: 1559067
This commit is contained in:
Anton Zemlyanov 2016-04-14 17:10:25 +03:00
parent 7001bca18c
commit 3041d69527
2 changed files with 30 additions and 14 deletions

View File

@ -21,7 +21,7 @@ import models from 'models';
var VmWareModels = {};
VmWareModels.isRegularField = (field) => {
return _.contains(['text', 'password', 'checkbox', 'select'], field.type);
return _.includes(['text', 'password', 'checkbox', 'select', 'file'], field.type);
};
// models for testing restrictions

View File

@ -38,20 +38,36 @@ var Field = React.createClass({
render() {
var metadata = this.props.metadata;
var value = this.props.model.get(metadata.name);
return (
<Input
{... _.pick(metadata, 'name', 'type', 'label', 'description')}
value={metadata.type === 'select' ? value.current.id : value}
checked={value}
toggleable={metadata.type === 'password'}
onChange={this.onChange}
disabled={this.props.disabled}
error={(this.props.model.validationError || {})[metadata.name]}
>
{metadata.type === 'select' && value.options.map((value) => {
var children = null;
var props = _.extend({
onChange: this.onChange,
disabled: this.props.disabled,
error: (this.props.model.validationError || {})[metadata.name]
}, _.pick(metadata, 'name', 'type', 'label', 'description'));
switch (metadata.type) {
case 'password':
props.toggleable = true;
break;
case 'radio':
case 'checkbox':
props.checked = value;
break;
case 'select':
props.value = value.current.id;
children = value.options.map((value) => {
return <option key={value.id} value={value.id}>{value.label}</option>;
})}
</Input>
});
break;
case 'file':
props.key = value && value.name;
props.defaultValue = value;
break;
default:
props.value = value;
break;
}
return (
<Input {...props}>{children}</Input>
);
}
});