1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-13 11:17:26 +02:00
unleash.unleash/frontend/src/component/feature/FeatureStrategy
Thomas Heartman e4ead3bd67
Refactor: get rid of editable constraint wrapper (#9921)
This (admittedly pretty big) PR removes a component layer, moves all
logic for updating constraint values into a single module, and dumbs
down other components.

The main changes are:
- EditableConstraintWrapper is gone. All the logic in there has been
moved into the new `useEditableConstraint` hook. Previously it was split
between the wrapper, editableConstraint itself, the legalValues
component.
- the `useEditableConstraint` hook accepts a constraint and a save
function and returns an editable version of that constraint, the
validator for input values, a function that accepts update commands,
and, when relevant, existing and deleted legal values.
- All the logic for updating a constraint now exists in the
`constraint-reducer` file. As a pure function, it'll be easy to unit
test pretty thoroughly to make sure all commands work as they should
(tests will come later)
- The legal values selector has been dumbed down consiberably as it no
longer needs to create its own internal weak map. The internal
representation of selected values is now a set, so any kind of lookup is
now constant time, which should remove the need for the extra layer of
abstraction.

## Discussion points

I know the reducer pattern isn't one we use a *lot* in Unleash, but I
found a couple examples of it in the front end and it's also quite
similar to how we handle state updates to change request states. I'd be
happy to find a different way to represent it if we can keep it in a
single, testable interface.

Semi-relatedly: I've exposed the actions to submit for the updates at
the moment, but we could map these to functions instead. It'd make
invocations a little easier (you wouldn't need to specify the action
yourself; only use the payload as a function arg if there is one), but
we'd end up doing more mapping to create them. I'm not sure it's worth
it, but I also don't mind if we do 💁🏼
2025-05-09 11:47:22 +02:00
..
FeatureStrategyConstraints Refactor: get rid of editable constraint wrapper (#9921) 2025-05-09 11:47:22 +02:00
FeatureStrategyCreate chore: fix strategy tests (#9922) 2025-05-09 11:10:45 +03:00
FeatureStrategyEdit refactor: deprecate old ConstraintAccordion and point to new version (#9613) 2025-04-17 11:16:32 +02:00
FeatureStrategyForm feat: strategy status as checkbox (#9760) 2025-04-15 13:11:11 +03:00
FeatureStrategyIcon
FeatureStrategyIcons
FeatureStrategyMenu feat: strategy menu interaction between two dialogues. (#9732) 2025-04-09 15:14:45 +03:00
FeatureStrategyProdGuard
FeatureStrategySegment feat: recently used segment chip (#9895) 2025-05-06 11:56:46 +03:00
FeatureStrategyType
featureStrategy.utils.ts