1
0
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:
Ivar Conradi Østhus 2021-05-07 09:36:15 +02:00
parent 37bd960133
commit 15ef4606b7
5 changed files with 9 additions and 3 deletions

View File

@ -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}
/>
</DialogContent>
<DialogActions>
@ -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;

View File

@ -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;

View File

@ -8,4 +8,5 @@ export default {
parameters: PropTypes.object.isRequired,
updateParameter: PropTypes.func.isRequired,
editable: PropTypes.bool.isRequired,
context: PropTypes.array.isRequired,
};

View File

@ -157,6 +157,7 @@ const StrategiesList = props => {
editingStrategy.name
)}
onCancel={clearAll}
context={props.context}
/>
) : null}
<ConditionallyRender
@ -238,6 +239,7 @@ StrategiesList.propTypes = {
featureToggleName: PropTypes.string.isRequired,
saveStrategies: PropTypes.func,
editable: PropTypes.bool,
context: PropTypes.array.isRequired,
};
export default StrategiesList;

View File

@ -3,6 +3,7 @@ import StrategiesList from './strategies-list-component';
const mapStateToProps = state => ({
strategies: state.strategies.get('list').toArray(),
context: state.context.toJS(),
});
export default connect(mapStateToProps, undefined)(StrategiesList);