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