grafana/public/app/features/explore/RunButton.tsx
Piotr Jamróz 5715be4afa
Explore: Integration test for running a query and saving it in query history (#45728)
* Create basic query history test

* Clean up

* Clean up

* Use run button selector

* Mock AutoSizer instead of monkey-patching

* Reset local storage after each test

* Add accessible name to Run Query button and use it in the test

* Update public/app/features/explore/spec/helper/interactions.ts

Co-authored-by: Giordano Ricci <me@giordanoricci.com>

* Rename query to urlParams

* Fix linting errors

* Remove unused import

Co-authored-by: Giordano Ricci <me@giordanoricci.com>
2022-02-23 19:05:38 +01:00

48 lines
1.2 KiB
TypeScript

import React from 'react';
import { RefreshPicker, defaultIntervals } from '@grafana/ui';
import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv';
export type Props = {
isSmall?: boolean;
loading: boolean;
isLive: boolean;
onRun: (loading: boolean) => void;
refreshInterval?: string;
onChangeRefreshInterval: (interval: string) => void;
showDropdown: boolean;
};
export function RunButton(props: Props) {
const { isSmall, loading, onRun, onChangeRefreshInterval, refreshInterval, showDropdown, isLive } = props;
const intervals = getTimeSrv().getValidIntervals(defaultIntervals);
let text: string | undefined = loading ? 'Cancel' : 'Run query';
let tooltip = '';
let width = '108px';
if (isLive) {
return null;
}
if (isSmall) {
tooltip = text;
text = undefined;
width = '35px';
}
return (
<RefreshPicker
onIntervalChanged={onChangeRefreshInterval}
value={refreshInterval}
isLoading={loading}
text={text}
tooltip={tooltip}
intervals={intervals}
isLive={isLive}
onRefresh={() => onRun(loading)}
noIntervalPicker={!showDropdown}
primary={true}
width={width}
/>
);
}