mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
add simple param type field
This commit is contained in:
parent
0ba7ca0659
commit
f04f3e9b29
@ -74,7 +74,7 @@ class AddFeatureToggleComponent extends Component {
|
||||
onChange={() => {
|
||||
setValue('enabled', !enabled);
|
||||
}}>Enabled</Switch>
|
||||
<br />
|
||||
<hr />
|
||||
</section>
|
||||
|
||||
<StrategiesSection
|
||||
|
@ -3,7 +3,7 @@ import { connect } from 'react-redux';
|
||||
import { createMapper, createActions } from '../input-helpers';
|
||||
import { createStrategy } from '../../store/strategy/actions';
|
||||
|
||||
import AddStrategy, { PARAM_PREFIX } from './add-strategy';
|
||||
import AddStrategy, { PARAM_PREFIX, TYPE_PREFIX } from './add-strategy';
|
||||
|
||||
const ID = 'add-strategy';
|
||||
|
||||
@ -15,7 +15,7 @@ const prepare = (methods, dispatch) => {
|
||||
const parametersTemplate = {};
|
||||
Object.keys(input).forEach(key => {
|
||||
if (key.startsWith(PARAM_PREFIX)) {
|
||||
parametersTemplate[input[key]] = 'string';
|
||||
parametersTemplate[input[key]] = input[key.replace(PARAM_PREFIX, TYPE_PREFIX)] || 'string';
|
||||
}
|
||||
});
|
||||
input.parametersTemplate = parametersTemplate;
|
||||
|
@ -16,17 +16,29 @@ function gerArrayWithEntries (num) {
|
||||
return Array.from(Array(num));
|
||||
}
|
||||
export const PARAM_PREFIX = 'param_';
|
||||
export const TYPE_PREFIX = 'type_';
|
||||
|
||||
const genParams = (input, num = 0, setValue) => (<div>{gerArrayWithEntries(num).map((v, i) => {
|
||||
const key = `${PARAM_PREFIX}${i + 1}`;
|
||||
const typeKey = `${TYPE_PREFIX}${i + 1}`;
|
||||
return (
|
||||
<Textfield
|
||||
style={{ width: '100%' }}
|
||||
floatingLabel
|
||||
label={`Parameter name ${i + 1}`}
|
||||
name={key} key={key}
|
||||
onChange={({ target }) => setValue(key, target.value)}
|
||||
value={input[key]} />
|
||||
<div key={key}>
|
||||
<Textfield
|
||||
style={{ width: '50%' }}
|
||||
floatingLabel
|
||||
label={`Parameter name ${i + 1}`}
|
||||
name={key}
|
||||
onChange={({ target }) => setValue(key, target.value)}
|
||||
value={input[key]} />
|
||||
<Textfield
|
||||
style={{ width: '50%' }}
|
||||
floatingLabel
|
||||
label={`Type ${i + 1}`}
|
||||
name={typeKey}
|
||||
onChange={({ target }) => setValue(typeKey, target.value)}
|
||||
value={input[typeKey]} />
|
||||
|
||||
</div>
|
||||
);
|
||||
})}</div>);
|
||||
|
||||
@ -63,10 +75,10 @@ const AddStrategy = ({
|
||||
|
||||
<section style={{ margin: '0 20px' }}>
|
||||
{genParams(input, input._params, setValue)}
|
||||
<IconButton name="add" title="Add parameter" onClick={(e) => {
|
||||
<IconButton raised name="add" title="Add parameter" onClick={(e) => {
|
||||
e.preventDefault();
|
||||
incValue('_params');
|
||||
}}/> Add parameter
|
||||
}}/> &nsbp;Add parameter
|
||||
</section>
|
||||
|
||||
<br />
|
||||
|
Loading…
Reference in New Issue
Block a user