mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
Fix input-store list bug.
Because we convert items from Immutable Object to js we can not just look up items in a list property via the object itself, as it is not the same. The easy fix is to just use the index of the item in the list, as we already know it anyway. closes #5
This commit is contained in:
parent
71cb26dede
commit
993222a749
@ -25,12 +25,12 @@ const prepare = (methods, dispatch) => {
|
||||
methods.pushToList('strategies', v);
|
||||
};
|
||||
|
||||
methods.updateStrategy = (v, n) => {
|
||||
methods.updateInList('strategies', v, n);
|
||||
methods.updateStrategy = (index, n) => {
|
||||
methods.updateInList('strategies', index, n);
|
||||
};
|
||||
|
||||
methods.removeStrategy = (v) => {
|
||||
methods.removeFromList('strategies', v);
|
||||
methods.removeStrategy = (index) => {
|
||||
methods.removeFromList('strategies', index);
|
||||
};
|
||||
|
||||
methods.validateName = (v) => {
|
||||
|
@ -40,12 +40,12 @@ const prepare = (methods, dispatch) => {
|
||||
methods.pushToList('strategies', v);
|
||||
};
|
||||
|
||||
methods.removeStrategy = (v) => {
|
||||
methods.removeFromList('strategies', v);
|
||||
methods.removeStrategy = (index) => {
|
||||
methods.removeFromList('strategies', index);
|
||||
};
|
||||
|
||||
methods.updateStrategy = (v, n) => {
|
||||
methods.updateInList('strategies', v, n);
|
||||
methods.updateStrategy = (index, n) => {
|
||||
methods.updateInList('strategies', index, n);
|
||||
};
|
||||
|
||||
methods.validateName = () => {};
|
||||
|
@ -26,8 +26,8 @@ class StrategiesList extends React.Component {
|
||||
<ConfigureStrategy
|
||||
key={`${strat.name}-${i}`}
|
||||
strategy={strat}
|
||||
removeStrategy={this.props.removeStrategy}
|
||||
updateStrategy={this.props.updateStrategy}
|
||||
removeStrategy={this.props.removeStrategy.bind(null, i)}
|
||||
updateStrategy={this.props.updateStrategy.bind(null, i)}
|
||||
strategyDefinition={strategies.find(s => s.name === strat.name)} />
|
||||
));
|
||||
return (
|
||||
|
@ -13,26 +13,18 @@ class StrategyConfigure extends React.Component {
|
||||
};
|
||||
}
|
||||
|
||||
updateStrategy = (evt) => {
|
||||
evt.preventDefault();
|
||||
this.props.updateStrategy({
|
||||
name: this.state.selectedStrategy.name,
|
||||
parameters: this.state.parameters,
|
||||
});
|
||||
};
|
||||
|
||||
handleConfigChange = (key, value) => {
|
||||
const parameters = this.props.strategy.parameters || {};
|
||||
parameters[key] = value;
|
||||
|
||||
const updatedStrategy = Object.assign({}, this.props.strategy, { parameters });
|
||||
|
||||
this.props.updateStrategy(this.props.strategy, updatedStrategy);
|
||||
this.props.updateStrategy(updatedStrategy);
|
||||
};
|
||||
|
||||
handleRemove = (evt) => {
|
||||
evt.preventDefault();
|
||||
this.props.removeStrategy(this.props.strategy);
|
||||
this.props.removeStrategy();
|
||||
}
|
||||
|
||||
renderInputFields (strategyDefinition) {
|
||||
|
@ -48,7 +48,7 @@ export default class FeatureListComponent extends React.Component {
|
||||
)}
|
||||
<ListDivider />
|
||||
<Link to="/features/create">
|
||||
<ListItem caption="Add" legend="new feature toggle" leftIcon="add" />
|
||||
<ListItem caption="Create" legend="new feature toggle" leftIcon="add" />
|
||||
</Link>
|
||||
</List>
|
||||
);
|
||||
|
@ -53,12 +53,12 @@ export function createActions ({ id, prepare = (v) => v }) {
|
||||
dispatch(createPush({ id: getId(id, ownProps), key, value }));
|
||||
},
|
||||
|
||||
removeFromList (key, value) {
|
||||
dispatch(createPop({ id: getId(id, ownProps), key, value }));
|
||||
removeFromList (key, index) {
|
||||
dispatch(createPop({ id: getId(id, ownProps), key, index }));
|
||||
},
|
||||
|
||||
updateInList (key, value, newValue) {
|
||||
dispatch(createUp({ id: getId(id, ownProps), key, value, newValue }));
|
||||
updateInList (key, index, newValue) {
|
||||
dispatch(createUp({ id: getId(id, ownProps), key, index, newValue }));
|
||||
},
|
||||
|
||||
incValue (key) {
|
||||
|
@ -3,7 +3,7 @@ import AddFeatureToggleForm from '../../component/feature/form-add-container';
|
||||
|
||||
const render = () => (
|
||||
<div>
|
||||
<h3>Create feature toggle</h3>
|
||||
<h6>Create feature toggle</h6>
|
||||
<AddFeatureToggleForm />
|
||||
</div>
|
||||
);
|
||||
|
@ -11,7 +11,7 @@ export default class Features extends Component {
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<h3>Edit feature toggle</h3>
|
||||
<h6>Edit feature toggle</h6>
|
||||
<EditFeatureToggleForm featureToggleName={this.props.params.name} />
|
||||
</div>
|
||||
);
|
||||
|
@ -12,8 +12,8 @@ export const createInit = ({ id, value }) => ({ type: actions.INIT, id, value })
|
||||
export const createInc = ({ id, key }) => ({ type: actions.INCREMENT_VALUE, id, key });
|
||||
export const createSet = ({ id, key, value }) => ({ type: actions.SET_VALUE, id, key, value });
|
||||
export const createPush = ({ id, key, value }) => ({ type: actions.LIST_PUSH, id, key, value });
|
||||
export const createPop = ({ id, key, value }) => ({ type: actions.LIST_POP, id, key, value });
|
||||
export const createUp = ({ id, key, value, newValue }) => ({ type: actions.LIST_UP, id, key, value, newValue });
|
||||
export const createPop = ({ id, key, index }) => ({ type: actions.LIST_POP, id, key, index });
|
||||
export const createUp = ({ id, key, index, newValue }) => ({ type: actions.LIST_UP, id, key, index, newValue });
|
||||
export const createClear = ({ id }) => ({ type: actions.CLEAR, id });
|
||||
|
||||
export default actions;
|
||||
|
@ -48,18 +48,18 @@ function addToList (state, { id, key, value }) {
|
||||
return state.updateIn(id.concat([key]), (list) => list.push(value));
|
||||
}
|
||||
|
||||
function updateInList (state, { id, key, value, newValue }) {
|
||||
function updateInList (state, { id, key, index, newValue }) {
|
||||
state = assertId(state, id);
|
||||
state = assertList(state, id, key);
|
||||
|
||||
return state.updateIn(id.concat([key]), (list) => list.set(list.indexOf(value), newValue));
|
||||
return state.updateIn(id.concat([key]), (list) => list.set(index, newValue));
|
||||
}
|
||||
|
||||
function removeFromList (state, { id, key, value }) {
|
||||
function removeFromList (state, { id, key, index }) {
|
||||
state = assertId(state, id);
|
||||
state = assertList(state, id, key);
|
||||
|
||||
return state.updateIn(id.concat([key]), (list) => list.remove(list.indexOf(value)));
|
||||
return state.updateIn(id.concat([key]), (list) => list.remove(index));
|
||||
}
|
||||
|
||||
const inputState = (state = getInitState(), action) => {
|
||||
|
Loading…
Reference in New Issue
Block a user