mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Synchronise time ranges in split mode (#19274)
* Explore: create connected sync button when screen is splitted * Explore: create attachable button to TimePicker * WIP/Explore: set up redux boilerplate for synced state * WIP/Explore: add toggling functionality to sync buttons * WIP/Explore: Fix styling issue * First pass solution working * Explore: Clean up, update comments * Explore: refactore Timepicker, remove newly introduced class names * Explore: refactore ExploreTimeControls * Explore: more semantic variables naming * Explore: run query on syncable item when synced times activated * Explore: Add tooltip to sync times button * Explore: Remove typo * Explore: check exploreId * Explore: refactor ExploreTimeControls * Explore: refactor to include suggested changes * Explore: Create TimeSyncButton component, update colors * Explore: Toggle tooltip, use stylesFactory
This commit is contained in:
@@ -9,6 +9,7 @@ import { TimeRange, TimeOption, TimeZone, RawTimeRange, dateTimeForTimeZone } fr
|
||||
|
||||
// Components
|
||||
import { TimePicker } from '@grafana/ui';
|
||||
import { TimeSyncButton } from './TimeSyncButton';
|
||||
|
||||
// Utils & Services
|
||||
import { defaultSelectOptions } from '@grafana/ui/src/components/TimePicker/TimePicker';
|
||||
@@ -18,6 +19,9 @@ export interface Props {
|
||||
exploreId: ExploreId;
|
||||
range: TimeRange;
|
||||
timeZone: TimeZone;
|
||||
splitted: boolean;
|
||||
syncedTimes: boolean;
|
||||
onChangeTimeSync: () => void;
|
||||
onChangeTime: (range: RawTimeRange) => void;
|
||||
}
|
||||
|
||||
@@ -67,18 +71,18 @@ export class ExploreTimeControls extends Component<Props> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { range, timeZone } = this.props;
|
||||
const { range, timeZone, splitted, syncedTimes, onChangeTimeSync } = this.props;
|
||||
const timeSyncButton = splitted ? <TimeSyncButton onClick={onChangeTimeSync} isSynced={syncedTimes} /> : null;
|
||||
const timePickerCommonProps = {
|
||||
value: range,
|
||||
onChange: this.onChangeTimePicker,
|
||||
timeZone,
|
||||
onMoveBackward: this.onMoveBack,
|
||||
onMoveForward: this.onMoveForward,
|
||||
onZoom: this.onZoom,
|
||||
selectOptions: this.setActiveTimeOption(defaultSelectOptions, range.raw),
|
||||
};
|
||||
|
||||
return (
|
||||
<TimePicker
|
||||
value={range}
|
||||
onChange={this.onChangeTimePicker}
|
||||
timeZone={timeZone}
|
||||
onMoveBackward={this.onMoveBack}
|
||||
onMoveForward={this.onMoveForward}
|
||||
onZoom={this.onZoom}
|
||||
selectOptions={this.setActiveTimeOption(defaultSelectOptions, range.raw)}
|
||||
/>
|
||||
);
|
||||
return <TimePicker {...timePickerCommonProps} timeSyncButton={timeSyncButton} isSynced={syncedTimes} />;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user