Skip to content

Commit 4268f4d

Browse files
committed
stop replReducer setting isRunning to true when using conductor, as it should be a no-op
also change featureSelector to take a flag instead of just its name
1 parent 2c1a17f commit 4268f4d

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { OverallState } from '../application/ApplicationTypes';
2+
import { FeatureFlag } from './FeatureFlag';
23

3-
export const featureSelector = (flagName: string) => (state: OverallState) =>
4-
state.featureFlags.modifiedFlags[flagName];
4+
export const featureSelector = (featureFlag: FeatureFlag<any>) => (state: OverallState) =>
5+
state.featureFlags.modifiedFlags[featureFlag.flagName];

src/commons/featureFlags/selectFeatureSaga.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { FeatureFlag } from './FeatureFlag';
55
import { featureSelector } from './featureSelector';
66

77
export function* selectFeatureSaga<T>(featureFlag: FeatureFlag<T>): SagaIterator<T> {
8-
const { flagName, defaultValue } = featureFlag;
9-
const flagValue = yield select(featureSelector(flagName));
8+
const { defaultValue } = featureFlag;
9+
const flagValue = yield select(featureSelector(featureFlag));
1010
return flagValue ?? defaultValue;
1111
}

src/commons/workspace/reducers/replReducer.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { ActionReducerMapBuilder } from '@reduxjs/toolkit';
2+
import { selectConductorEnable } from 'src/features/conductor/flagConductorEnable';
3+
import { store } from 'src/pages/createStore';
24

35
import { CodeOutput, InterpreterOutput } from '../../application/ApplicationTypes';
46
import Constants from '../../utils/Constants';
@@ -103,6 +105,9 @@ export const handleReplActions = (builder: ActionReducerMapBuilder<WorkspaceMana
103105
state[workspaceLocation].replHistory.records = newReplHistoryRecords;
104106
})
105107
.addCase(WorkspaceActions.evalRepl, (state, action) => {
108+
if (selectConductorEnable(store.getState())) {
109+
return; // no-op: either we will already be running, or it will not start running
110+
}
106111
const workspaceLocation = getWorkspaceLocation(action);
107112
state[workspaceLocation].isRunning = true;
108113
})
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { createFeatureFlag } from 'src/commons/featureFlags';
2+
import { featureSelector } from 'src/commons/featureFlags/featureSelector';
23

34
export const flagConductorEnable = createFeatureFlag(
45
'conductor.enable',
56
false,
67
'Enables the Conductor framework for evaluation of user programs.'
78
);
9+
10+
export const selectConductorEnable = featureSelector(flagConductorEnable);

0 commit comments

Comments
 (0)