From 15ef4606b75d90cba8c63bc8abe1a9875d7da6bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Fri, 7 May 2021 09:36:15 +0200 Subject: [PATCH] fix: support custom stickiness for flexible strategies --- .../feature/strategy/EditStrategyModal/EditStrategyModal.jsx | 4 +++- .../feature/strategy/EditStrategyModal/FlexibleStrategy.jsx | 4 ++-- .../strategy/EditStrategyModal/strategy-input-props.js | 1 + .../component/feature/strategy/strategies-list-component.jsx | 2 ++ .../component/feature/strategy/strategies-list-container.jsx | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/component/feature/strategy/EditStrategyModal/EditStrategyModal.jsx b/frontend/src/component/feature/strategy/EditStrategyModal/EditStrategyModal.jsx index ab3dd1e7b2..bf90bd4d7e 100644 --- a/frontend/src/component/feature/strategy/EditStrategyModal/EditStrategyModal.jsx +++ b/frontend/src/component/feature/strategy/EditStrategyModal/EditStrategyModal.jsx @@ -22,6 +22,7 @@ const EditStrategyModal = ({ saveStrategy, updateStrategy, strategyDefinition, + context, }) => { const updateParameters = parameters => { const updatedStrategy = { ...strategy, parameters }; @@ -81,6 +82,7 @@ const EditStrategyModal = ({ updateParameter={updateParameter} strategyDefinition={strategyDefinition} editable + context={context} /> @@ -105,7 +107,7 @@ EditStrategyModal.propTypes = { onCancel: PropTypes.func.isRequired, saveStrategy: PropTypes.func.isRequired, strategyDefinition: PropTypes.object.isRequired, - context: PropTypes.array, // TODO: fix me + context: PropTypes.array.isRequired, }; export default EditStrategyModal; diff --git a/frontend/src/component/feature/strategy/EditStrategyModal/FlexibleStrategy.jsx b/frontend/src/component/feature/strategy/EditStrategyModal/FlexibleStrategy.jsx index 95114c9e03..fb6d269889 100644 --- a/frontend/src/component/feature/strategy/EditStrategyModal/FlexibleStrategy.jsx +++ b/frontend/src/component/feature/strategy/EditStrategyModal/FlexibleStrategy.jsx @@ -12,7 +12,7 @@ const builtInStickinessOptions = [ { key: 'random', label: 'random' }, ]; -const FlexibleStrategy = ({ updateParameter, parameters, context = [] }) => { +const FlexibleStrategy = ({ updateParameter, parameters, context }) => { const onUpdate = field => (_, newValue) => { updateParameter(field, newValue); }; @@ -63,7 +63,7 @@ const FlexibleStrategy = ({ updateParameter, parameters, context = [] }) => { FlexibleStrategy.propTypes = { parameters: PropTypes.object.isRequired, updateParameter: PropTypes.func.isRequired, - context: PropTypes.array, // TODO: fix me + context: PropTypes.array.isRequired, }; export default FlexibleStrategy; diff --git a/frontend/src/component/feature/strategy/EditStrategyModal/strategy-input-props.js b/frontend/src/component/feature/strategy/EditStrategyModal/strategy-input-props.js index 3108ff0511..3a5fec268c 100644 --- a/frontend/src/component/feature/strategy/EditStrategyModal/strategy-input-props.js +++ b/frontend/src/component/feature/strategy/EditStrategyModal/strategy-input-props.js @@ -8,4 +8,5 @@ export default { parameters: PropTypes.object.isRequired, updateParameter: PropTypes.func.isRequired, editable: PropTypes.bool.isRequired, + context: PropTypes.array.isRequired, }; diff --git a/frontend/src/component/feature/strategy/strategies-list-component.jsx b/frontend/src/component/feature/strategy/strategies-list-component.jsx index 4b76340cbd..294d1d6588 100644 --- a/frontend/src/component/feature/strategy/strategies-list-component.jsx +++ b/frontend/src/component/feature/strategy/strategies-list-component.jsx @@ -157,6 +157,7 @@ const StrategiesList = props => { editingStrategy.name )} onCancel={clearAll} + context={props.context} /> ) : null} ({ strategies: state.strategies.get('list').toArray(), + context: state.context.toJS(), }); export default connect(mapStateToProps, undefined)(StrategiesList);