mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Change loading state to done after live-tailing stops (#19955)
This commit is contained in:
parent
35e0e078b7
commit
6390e51b8c
@ -21,6 +21,7 @@ import {
|
|||||||
toggleGraphAction,
|
toggleGraphAction,
|
||||||
toggleTableAction,
|
toggleTableAction,
|
||||||
changeRangeAction,
|
changeRangeAction,
|
||||||
|
changeRefreshIntervalAction,
|
||||||
} from './actionTypes';
|
} from './actionTypes';
|
||||||
import { Reducer } from 'redux';
|
import { Reducer } from 'redux';
|
||||||
import { ActionOf } from 'app/core/redux/actionCreatorFactory';
|
import { ActionOf } from 'app/core/redux/actionCreatorFactory';
|
||||||
@ -28,7 +29,7 @@ import { updateLocation } from 'app/core/actions/location';
|
|||||||
import { serializeStateToUrlParam } from 'app/core/utils/explore';
|
import { serializeStateToUrlParam } from 'app/core/utils/explore';
|
||||||
import TableModel from 'app/core/table_model';
|
import TableModel from 'app/core/table_model';
|
||||||
import { DataSourceApi, DataQuery } from '@grafana/ui';
|
import { DataSourceApi, DataQuery } from '@grafana/ui';
|
||||||
import { LogsModel, LogsDedupStrategy, dateTime } from '@grafana/data';
|
import { LogsModel, LogsDedupStrategy, dateTime, LoadingState } from '@grafana/data';
|
||||||
|
|
||||||
describe('Explore item reducer', () => {
|
describe('Explore item reducer', () => {
|
||||||
describe('scanning', () => {
|
describe('scanning', () => {
|
||||||
@ -42,7 +43,7 @@ describe('Explore item reducer', () => {
|
|||||||
.givenReducer(itemReducer as Reducer<ExploreItemState, ActionOf<any>>, initalState)
|
.givenReducer(itemReducer as Reducer<ExploreItemState, ActionOf<any>>, initalState)
|
||||||
.whenActionIsDispatched(scanStartAction({ exploreId: ExploreId.left }))
|
.whenActionIsDispatched(scanStartAction({ exploreId: ExploreId.left }))
|
||||||
.thenStateShouldEqual({
|
.thenStateShouldEqual({
|
||||||
...initalState,
|
...makeExploreItemState(),
|
||||||
scanning: true,
|
scanning: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -57,7 +58,7 @@ describe('Explore item reducer', () => {
|
|||||||
.givenReducer(itemReducer as Reducer<ExploreItemState, ActionOf<any>>, initalState)
|
.givenReducer(itemReducer as Reducer<ExploreItemState, ActionOf<any>>, initalState)
|
||||||
.whenActionIsDispatched(scanStopAction({ exploreId: ExploreId.left }))
|
.whenActionIsDispatched(scanStopAction({ exploreId: ExploreId.left }))
|
||||||
.thenStateShouldEqual({
|
.thenStateShouldEqual({
|
||||||
...initalState,
|
...makeExploreItemState(),
|
||||||
scanning: false,
|
scanning: false,
|
||||||
scanRange: undefined,
|
scanRange: undefined,
|
||||||
});
|
});
|
||||||
@ -174,6 +175,50 @@ describe('Explore item reducer', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('changing refresh intervals', () => {
|
||||||
|
it("should result in 'streaming' state, when live-tailing is active", () => {
|
||||||
|
const initalState = makeExploreItemState();
|
||||||
|
const expectedState = {
|
||||||
|
...makeExploreItemState(),
|
||||||
|
refreshInterval: 'LIVE',
|
||||||
|
isLive: true,
|
||||||
|
loading: true,
|
||||||
|
logsResult: {
|
||||||
|
hasUniqueLabels: false,
|
||||||
|
rows: [] as any[],
|
||||||
|
},
|
||||||
|
queryResponse: {
|
||||||
|
...makeExploreItemState().queryResponse,
|
||||||
|
state: LoadingState.Streaming,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
reducerTester()
|
||||||
|
.givenReducer(itemReducer, initalState)
|
||||||
|
.whenActionIsDispatched(changeRefreshIntervalAction({ exploreId: ExploreId.left, refreshInterval: 'LIVE' }))
|
||||||
|
.thenStateShouldEqual(expectedState);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should result in 'done' state, when live-tailing is stopped", () => {
|
||||||
|
const initalState = makeExploreItemState();
|
||||||
|
const expectedState = {
|
||||||
|
...makeExploreItemState(),
|
||||||
|
refreshInterval: '',
|
||||||
|
logsResult: {
|
||||||
|
hasUniqueLabels: false,
|
||||||
|
rows: [] as any[],
|
||||||
|
},
|
||||||
|
queryResponse: {
|
||||||
|
...makeExploreItemState().queryResponse,
|
||||||
|
state: LoadingState.Done,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
reducerTester()
|
||||||
|
.givenReducer(itemReducer, initalState)
|
||||||
|
.whenActionIsDispatched(changeRefreshIntervalAction({ exploreId: ExploreId.left, refreshInterval: '' }))
|
||||||
|
.thenStateShouldEqual(expectedState);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('toggling panels', () => {
|
describe('toggling panels', () => {
|
||||||
describe('when toggleGraphAction is dispatched', () => {
|
describe('when toggleGraphAction is dispatched', () => {
|
||||||
it('then it should set correct state', () => {
|
it('then it should set correct state', () => {
|
||||||
|
@ -204,7 +204,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|||||||
refreshInterval,
|
refreshInterval,
|
||||||
queryResponse: {
|
queryResponse: {
|
||||||
...state.queryResponse,
|
...state.queryResponse,
|
||||||
state: live ? LoadingState.Streaming : LoadingState.NotStarted,
|
state: live ? LoadingState.Streaming : LoadingState.Done,
|
||||||
},
|
},
|
||||||
isLive: live,
|
isLive: live,
|
||||||
isPaused: live ? false : state.isPaused,
|
isPaused: live ? false : state.isPaused,
|
||||||
|
Loading…
Reference in New Issue
Block a user