refactor: better naming

This commit is contained in:
Gábor Farkas 2022-09-05 14:24:35 +02:00
parent 5b874b09cd
commit a82d4ace67
3 changed files with 12 additions and 12 deletions

View File

@ -18,7 +18,7 @@ import { getTimeZone } from '../profile/state/selectors';
import { LiveLogsWithTheme } from './LiveLogs'; import { LiveLogsWithTheme } from './LiveLogs';
import { Logs } from './Logs'; import { Logs } from './Logs';
import { splitOpen } from './state/main'; import { splitOpen } from './state/main';
import { addResultsToCache, clearCache, loadLogsVolumeData, toggleLogsVolume } from './state/query'; import { addResultsToCache, clearCache, loadLogsVolumeData, setLogsVolumeEnabled } from './state/query';
import { updateTimeRange } from './state/time'; import { updateTimeRange } from './state/time';
import { LiveTailControls } from './useLiveTailControls'; import { LiveTailControls } from './useLiveTailControls';
import { LogsCrossFadeTransition } from './utils/LogsCrossFadeTransition'; import { LogsCrossFadeTransition } from './utils/LogsCrossFadeTransition';
@ -129,7 +129,7 @@ class LogsContainer extends PureComponent<LogsContainerProps> {
logsMeta={logsMeta} logsMeta={logsMeta}
logsSeries={logsSeries} logsSeries={logsSeries}
logsVolumeEnabled={this.props.logsVolumeEnabled} logsVolumeEnabled={this.props.logsVolumeEnabled}
onSetLogsVolumeEnabled={(enabled) => this.props.toggleLogsVolume(exploreId, enabled)} onSetLogsVolumeEnabled={(enabled) => this.props.setLogsVolumeEnabled(exploreId, enabled)}
logsVolumeData={logsVolumeData} logsVolumeData={logsVolumeData}
logsQueries={logsQueries} logsQueries={logsQueries}
width={width} width={width}
@ -204,7 +204,7 @@ const mapDispatchToProps = {
addResultsToCache, addResultsToCache,
clearCache, clearCache,
loadLogsVolumeData, loadLogsVolumeData,
toggleLogsVolume, setLogsVolumeEnabled,
}; };
const connector = connect(mapStateToProps, mapDispatchToProps); const connector = connect(mapStateToProps, mapDispatchToProps);

View File

@ -35,7 +35,7 @@ import {
scanStartAction, scanStartAction,
scanStopAction, scanStopAction,
storeLogsVolumeDataProviderAction, storeLogsVolumeDataProviderAction,
toggleLogsVolume, setLogsVolumeEnabled,
} from './query'; } from './query';
import { makeExplorePaneState } from './utils'; import { makeExplorePaneState } from './utils';
@ -445,7 +445,7 @@ describe('reducer', () => {
it('do not load logsVolume data when disabled', async () => { it('do not load logsVolume data when disabled', async () => {
// turn logsvolume off // turn logsvolume off
dispatch(toggleLogsVolume(ExploreId.left, false)); dispatch(setLogsVolumeEnabled(ExploreId.left, false));
expect(getState().explore[ExploreId.left].logsVolumeEnabled).toBe(false); expect(getState().explore[ExploreId.left].logsVolumeEnabled).toBe(false);
// verify that if we run a query, it will not do logsvolume, but the Provider will still be set // verify that if we run a query, it will not do logsvolume, but the Provider will still be set
@ -457,14 +457,14 @@ describe('reducer', () => {
it('load logsVolume data when it gets enabled', async () => { it('load logsVolume data when it gets enabled', async () => {
// first it is disabled // first it is disabled
dispatch(toggleLogsVolume(ExploreId.left, false)); dispatch(setLogsVolumeEnabled(ExploreId.left, false));
// runQueries sets up the logsVolume query, but does not run it // runQueries sets up the logsVolume query, but does not run it
await dispatch(runQueries(ExploreId.left)); await dispatch(runQueries(ExploreId.left));
expect(getState().explore[ExploreId.left].logsVolumeDataProvider).toBeDefined(); expect(getState().explore[ExploreId.left].logsVolumeDataProvider).toBeDefined();
// we turn logsvolume on // we turn logsvolume on
await dispatch(toggleLogsVolume(ExploreId.left, true)); await dispatch(setLogsVolumeEnabled(ExploreId.left, true));
// verify it was turned on // verify it was turned on
expect(getState().explore[ExploreId.left].logsVolumeEnabled).toBe(true); expect(getState().explore[ExploreId.left].logsVolumeEnabled).toBe(true);

View File

@ -108,8 +108,8 @@ export const queryStoreSubscriptionAction = createAction<QueryStoreSubscriptionP
'explore/queryStoreSubscription' 'explore/queryStoreSubscription'
); );
const toggleLogsVolumeAction = createAction<{ exploreId: ExploreId; enabled: boolean }>( const setLogsVolumeEnabledAction = createAction<{ exploreId: ExploreId; enabled: boolean }>(
'explore/toggleLogsVolumeAction' 'explore/setLogsVolumeEnabledAction'
); );
export interface StoreLogsVolumeDataProvider { export interface StoreLogsVolumeDataProvider {
@ -632,9 +632,9 @@ export function loadLogsVolumeData(exploreId: ExploreId): ThunkResult<void> {
}; };
} }
export function toggleLogsVolume(exploreId: ExploreId, enabled: boolean): ThunkResult<void> { export function setLogsVolumeEnabled(exploreId: ExploreId, enabled: boolean): ThunkResult<void> {
return (dispatch, getState) => { return (dispatch, getState) => {
dispatch(toggleLogsVolumeAction({ exploreId, enabled })); dispatch(setLogsVolumeEnabledAction({ exploreId, enabled }));
storeLogsVolumeEnabled(enabled); storeLogsVolumeEnabled(enabled);
if (enabled) { if (enabled) {
dispatch(loadLogsVolumeData(exploreId)); dispatch(loadLogsVolumeData(exploreId));
@ -738,7 +738,7 @@ export const queryReducer = (state: ExploreItemState, action: AnyAction): Explor
}; };
} }
if (toggleLogsVolumeAction.match(action)) { if (setLogsVolumeEnabledAction.match(action)) {
const { enabled } = action.payload; const { enabled } = action.payload;
if (state.logsVolumeDataSubscription) { if (state.logsVolumeDataSubscription) {
state.logsVolumeDataSubscription.unsubscribe(); state.logsVolumeDataSubscription.unsubscribe();