Fix bug where toggling backend experiment also updates frontend

This commit is contained in:
Moon 2022-02-28 12:18:16 -08:00
parent 525f86faeb
commit 98ad392109
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, type: TYPES.TOGGLE_EXPERIMENT,
experimentName, experimentName,
newVariation, newVariation,
source,
}; };
} }

View File

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

View File

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