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 { Logs } from './Logs';
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 { LiveTailControls } from './useLiveTailControls';
import { LogsCrossFadeTransition } from './utils/LogsCrossFadeTransition';
@ -129,7 +129,7 @@ class LogsContainer extends PureComponent<LogsContainerProps> {
logsMeta={logsMeta}
logsSeries={logsSeries}
logsVolumeEnabled={this.props.logsVolumeEnabled}
onSetLogsVolumeEnabled={(enabled) => this.props.toggleLogsVolume(exploreId, enabled)}
onSetLogsVolumeEnabled={(enabled) => this.props.setLogsVolumeEnabled(exploreId, enabled)}
logsVolumeData={logsVolumeData}
logsQueries={logsQueries}
width={width}
@ -204,7 +204,7 @@ const mapDispatchToProps = {
addResultsToCache,
clearCache,
loadLogsVolumeData,
toggleLogsVolume,
setLogsVolumeEnabled,
};
const connector = connect(mapStateToProps, mapDispatchToProps);

View File

@ -35,7 +35,7 @@ import {
scanStartAction,
scanStopAction,
storeLogsVolumeDataProviderAction,
toggleLogsVolume,
setLogsVolumeEnabled,
} from './query';
import { makeExplorePaneState } from './utils';
@ -445,7 +445,7 @@ describe('reducer', () => {
it('do not load logsVolume data when disabled', async () => {
// turn logsvolume off
dispatch(toggleLogsVolume(ExploreId.left, false));
dispatch(setLogsVolumeEnabled(ExploreId.left, 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
@ -457,14 +457,14 @@ describe('reducer', () => {
it('load logsVolume data when it gets enabled', async () => {
// 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
await dispatch(runQueries(ExploreId.left));
expect(getState().explore[ExploreId.left].logsVolumeDataProvider).toBeDefined();
// we turn logsvolume on
await dispatch(toggleLogsVolume(ExploreId.left, true));
await dispatch(setLogsVolumeEnabled(ExploreId.left, true));
// verify it was turned on
expect(getState().explore[ExploreId.left].logsVolumeEnabled).toBe(true);

View File

@ -108,8 +108,8 @@ export const queryStoreSubscriptionAction = createAction<QueryStoreSubscriptionP
'explore/queryStoreSubscription'
);
const toggleLogsVolumeAction = createAction<{ exploreId: ExploreId; enabled: boolean }>(
'explore/toggleLogsVolumeAction'
const setLogsVolumeEnabledAction = createAction<{ exploreId: ExploreId; enabled: boolean }>(
'explore/setLogsVolumeEnabledAction'
);
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) => {
dispatch(toggleLogsVolumeAction({ exploreId, enabled }));
dispatch(setLogsVolumeEnabledAction({ exploreId, enabled }));
storeLogsVolumeEnabled(enabled);
if (enabled) {
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;
if (state.logsVolumeDataSubscription) {
state.logsVolumeDataSubscription.unsubscribe();