Merge pull request #31 from woocommerce/update/fix-bug-with-toggling-experiment

Fix bug where toggling backend experiment also updates frontend
This commit is contained in:
Moon 2022-02-28 12:19:21 -08:00 committed by GitHub
commit 2f00410a8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 1 deletions

View File

@ -51,6 +51,7 @@ export function* toggleExperiment( experimentName, currentVariation, source ) {
type: TYPES.TOGGLE_EXPERIMENT,
experimentName,
newVariation,
source,
};
}

View File

@ -15,7 +15,8 @@ const reducer = ( state = DEFAULT_STATE, action ) => {
experiments: state.experiments.map( ( experiment ) => ( {
...experiment,
variation:
experiment.name === action.experimentName
experiment.name === action.experimentName &&
experiment.source === action.source
? action.newVariation
: experiment.variation,
} ) ),

View File

@ -20,6 +20,7 @@ function Experiments( { experiments, toggleExperiment } ) {
<tr>
<th>Experiment</th>
<th>Variation</th>
<th>Source</th>
<th>Toggle</th>
</tr>
</thead>
@ -32,6 +33,7 @@ function Experiments( { experiments, toggleExperiment } ) {
{ name }
</td>
<td align="center">{ variation }</td>
<td align="center">{ source }</td>
<td align="center">
<Button
onClick={ () => {