mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 16:45:43 -06:00
* 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
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
import React from 'react';
|
|
import classNames from 'classnames';
|
|
import { css } from 'emotion';
|
|
|
|
import { GrafanaTheme, useTheme, stylesFactory } from '@grafana/ui';
|
|
|
|
//Components
|
|
import { Tooltip } from '@grafana/ui';
|
|
|
|
const getStyles = stylesFactory((theme: GrafanaTheme) => {
|
|
return {
|
|
timePickerSynced: css`
|
|
label: timePickerSynced;
|
|
border-color: ${theme.colors.orangeDark};
|
|
background-image: none;
|
|
background-color: transparent;
|
|
color: ${theme.colors.orangeDark};
|
|
&:focus,
|
|
:hover {
|
|
color: ${theme.colors.orangeDark};
|
|
background-image: none;
|
|
background-color: transparent;
|
|
}
|
|
`,
|
|
noRightBorderStyle: css`
|
|
label: noRightBorderStyle;
|
|
border-right: 0;
|
|
`,
|
|
};
|
|
});
|
|
|
|
interface TimeSyncButtonProps {
|
|
isSynced: boolean;
|
|
onClick: () => void;
|
|
}
|
|
|
|
export function TimeSyncButton(props: TimeSyncButtonProps) {
|
|
const { onClick, isSynced } = props;
|
|
const theme = useTheme();
|
|
const styles = getStyles(theme);
|
|
|
|
const syncTimesTooltip = () => {
|
|
const { isSynced } = props;
|
|
const tooltip = isSynced ? 'Unsync all views' : 'Sync all views to this time range';
|
|
return <>{tooltip}</>;
|
|
};
|
|
|
|
return (
|
|
<Tooltip content={syncTimesTooltip} placement="bottom">
|
|
<button
|
|
className={classNames('btn navbar-button navbar-button--attached', {
|
|
[styles.timePickerSynced]: isSynced,
|
|
})}
|
|
onClick={() => onClick()}
|
|
>
|
|
<i className="fa fa-link" />
|
|
</button>
|
|
</Tooltip>
|
|
);
|
|
}
|