mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
fix: support custom stickiness for flexible strategies
This commit is contained in:
parent
37bd960133
commit
15ef4606b7
@ -22,6 +22,7 @@ const EditStrategyModal = ({
|
|||||||
saveStrategy,
|
saveStrategy,
|
||||||
updateStrategy,
|
updateStrategy,
|
||||||
strategyDefinition,
|
strategyDefinition,
|
||||||
|
context,
|
||||||
}) => {
|
}) => {
|
||||||
const updateParameters = parameters => {
|
const updateParameters = parameters => {
|
||||||
const updatedStrategy = { ...strategy, parameters };
|
const updatedStrategy = { ...strategy, parameters };
|
||||||
@ -81,6 +82,7 @@ const EditStrategyModal = ({
|
|||||||
updateParameter={updateParameter}
|
updateParameter={updateParameter}
|
||||||
strategyDefinition={strategyDefinition}
|
strategyDefinition={strategyDefinition}
|
||||||
editable
|
editable
|
||||||
|
context={context}
|
||||||
/>
|
/>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
@ -105,7 +107,7 @@ EditStrategyModal.propTypes = {
|
|||||||
onCancel: PropTypes.func.isRequired,
|
onCancel: PropTypes.func.isRequired,
|
||||||
saveStrategy: PropTypes.func.isRequired,
|
saveStrategy: PropTypes.func.isRequired,
|
||||||
strategyDefinition: PropTypes.object.isRequired,
|
strategyDefinition: PropTypes.object.isRequired,
|
||||||
context: PropTypes.array, // TODO: fix me
|
context: PropTypes.array.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default EditStrategyModal;
|
export default EditStrategyModal;
|
||||||
|
@ -12,7 +12,7 @@ const builtInStickinessOptions = [
|
|||||||
{ key: 'random', label: 'random' },
|
{ key: 'random', label: 'random' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const FlexibleStrategy = ({ updateParameter, parameters, context = [] }) => {
|
const FlexibleStrategy = ({ updateParameter, parameters, context }) => {
|
||||||
const onUpdate = field => (_, newValue) => {
|
const onUpdate = field => (_, newValue) => {
|
||||||
updateParameter(field, newValue);
|
updateParameter(field, newValue);
|
||||||
};
|
};
|
||||||
@ -63,7 +63,7 @@ const FlexibleStrategy = ({ updateParameter, parameters, context = [] }) => {
|
|||||||
FlexibleStrategy.propTypes = {
|
FlexibleStrategy.propTypes = {
|
||||||
parameters: PropTypes.object.isRequired,
|
parameters: PropTypes.object.isRequired,
|
||||||
updateParameter: PropTypes.func.isRequired,
|
updateParameter: PropTypes.func.isRequired,
|
||||||
context: PropTypes.array, // TODO: fix me
|
context: PropTypes.array.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default FlexibleStrategy;
|
export default FlexibleStrategy;
|
||||||
|
@ -8,4 +8,5 @@ export default {
|
|||||||
parameters: PropTypes.object.isRequired,
|
parameters: PropTypes.object.isRequired,
|
||||||
updateParameter: PropTypes.func.isRequired,
|
updateParameter: PropTypes.func.isRequired,
|
||||||
editable: PropTypes.bool.isRequired,
|
editable: PropTypes.bool.isRequired,
|
||||||
|
context: PropTypes.array.isRequired,
|
||||||
};
|
};
|
||||||
|
@ -157,6 +157,7 @@ const StrategiesList = props => {
|
|||||||
editingStrategy.name
|
editingStrategy.name
|
||||||
)}
|
)}
|
||||||
onCancel={clearAll}
|
onCancel={clearAll}
|
||||||
|
context={props.context}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
@ -238,6 +239,7 @@ StrategiesList.propTypes = {
|
|||||||
featureToggleName: PropTypes.string.isRequired,
|
featureToggleName: PropTypes.string.isRequired,
|
||||||
saveStrategies: PropTypes.func,
|
saveStrategies: PropTypes.func,
|
||||||
editable: PropTypes.bool,
|
editable: PropTypes.bool,
|
||||||
|
context: PropTypes.array.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default StrategiesList;
|
export default StrategiesList;
|
||||||
|
@ -3,6 +3,7 @@ import StrategiesList from './strategies-list-component';
|
|||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
strategies: state.strategies.get('list').toArray(),
|
strategies: state.strategies.get('list').toArray(),
|
||||||
|
context: state.context.toJS(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps, undefined)(StrategiesList);
|
export default connect(mapStateToProps, undefined)(StrategiesList);
|
||||||
|
Loading…
Reference in New Issue
Block a user