grafana/public/app/features/explore/TimeSyncButton.tsx
Giordano Ricci dfed7e59a5
Explore: move items out of topnav & use canvas variant for toolbar buttons (#60630)
* Explore: remove topnav

* PageToolbar: fix left items margin when no title or page icon is set

* add missing key prop & fix tests

* use canvas variant in live logs

* avoid rendering empty space

* fix test

* avoid disabling split resize button when live tailing

* minor touchups

* Update packages/grafana-ui/src/components/PageLayout/PageToolbar.tsx

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2023-01-05 22:26:58 +00:00

30 lines
736 B
TypeScript

import React from 'react';
import { Tooltip, ToolbarButton } from '@grafana/ui';
interface TimeSyncButtonProps {
isSynced: boolean;
onClick: () => void;
}
export function TimeSyncButton(props: TimeSyncButtonProps) {
const { onClick, isSynced } = props;
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">
<ToolbarButton
icon="link"
variant={isSynced ? 'active' : 'canvas'}
aria-label={isSynced ? 'Synced times' : 'Unsynced times'}
onClick={onClick}
/>
</Tooltip>
);
}