/usr/share/grafana/public/app/features/explore
import { useCallback } from 'react'; import * as React from 'react'; import { RefreshPicker } from '@grafana/ui'; import { useDispatch } from 'app/types/store'; import { setPausedStateAction, runQueries, clearLogs } from './state/query'; import { changeRefreshInterval } from './state/time'; /** * Hook that gives you all the functions needed to control the live tailing. */ export function useLiveTailControls(exploreId: string) { const dispatch = useDispatch(); const pause = useCallback(() => { dispatch(setPausedStateAction({ exploreId, isPaused: true })); }, [exploreId, dispatch]); const resume = useCallback(() => { dispatch(setPausedStateAction({ exploreId, isPaused: false })); }, [exploreId, dispatch]); const stop = useCallback(() => { // We need to pause here first because there is transition where we are not live but live logs are still shown // to cross fade with the normal view. This will prevent reordering of the logs in the live view during the // transition. pause(); // TODO referencing this from perspective of refresh picker when there is designated button for it now is not // great. Needs a bit of refactoring. dispatch(changeRefreshInterval({ exploreId, refreshInterval: RefreshPicker.offOption.value })); dispatch(runQueries({ exploreId })); }, [exploreId, dispatch, pause]); const start = useCallback(() => { dispatch(changeRefreshInterval({ exploreId, refreshInterval: RefreshPicker.liveOption.value })); }, [exploreId, dispatch]); const clear = useCallback(() => { dispatch(clearLogs({ exploreId })); }, [exploreId, dispatch]); return { pause, resume, stop, start, clear, }; } type Props = { exploreId: string; children: (controls: ReturnType<typeof useLiveTailControls>) => React.ReactElement; }; /** * If you can't use the hook you can use this as a render prop pattern. */ export function LiveTailControls(props: Props) { const controls = useLiveTailControls(props.exploreId); return props.children(controls); }
.
Edit
..
Edit
ContentOutline
Edit
CorrelationEditorModeBar.tsx
Edit
CorrelationHelper.tsx
Edit
CorrelationTransformationAddModal.tsx
Edit
CorrelationUnsavedChangesModal.tsx
Edit
CustomContainer.tsx
Edit
ElapsedTime.tsx
Edit
ErrorContainer.test.tsx
Edit
ErrorContainer.tsx
Edit
Explore.test.tsx
Edit
Explore.tsx
Edit
ExploreActions.tsx
Edit
ExploreDrawer.tsx
Edit
ExplorePage.tsx
Edit
ExplorePaneContainer.tsx
Edit
ExploreQueryInspector.test.tsx
Edit
ExploreQueryInspector.tsx
Edit
ExploreRunQueryButton.test.tsx
Edit
ExploreRunQueryButton.tsx
Edit
ExploreTimeControls.tsx
Edit
ExploreToolbar.tsx
Edit
FeatureTogglePage.tsx
Edit
FlameGraph
Edit
Graph
Edit
LimitedDataDisclaimer.tsx
Edit
LiveTailButton.tsx
Edit
Logs
Edit
MetaInfoText.test.tsx
Edit
MetaInfoText.tsx
Edit
NoData.tsx
Edit
NoDataSourceCallToAction.tsx
Edit
NodeGraph
Edit
PrometheusListView
Edit
QueriesDrawer
Edit
QueryLibrary
Edit
QueryRows.test.tsx
Edit
QueryRows.tsx
Edit
RawPrometheus
Edit
ResponseErrorContainer.test.tsx
Edit
ResponseErrorContainer.tsx
Edit
RichHistory
Edit
SecondaryActions.test.tsx
Edit
SecondaryActions.tsx
Edit
ShortLinkButtonMenu.tsx
Edit
SupplementaryResultError.test.tsx
Edit
SupplementaryResultError.tsx
Edit
Table
Edit
Time.tsx
Edit
TimeSyncButton.test.tsx
Edit
TimeSyncButton.tsx
Edit
TraceView
Edit
correlationEditLogic.test.ts
Edit
correlationEditLogic.ts
Edit
extensions
Edit
hooks
Edit
mocks
Edit
spec
Edit
state
Edit
useLiveTailControls.ts
Edit
utils
Edit