TimeSyncButton.tsx 737 B

1234567891011121314151617181920212223242526272829
  1. import React from 'react';
  2. import { Tooltip, ToolbarButton } from '@grafana/ui';
  3. interface TimeSyncButtonProps {
  4. isSynced: boolean;
  5. onClick: () => void;
  6. }
  7. export function TimeSyncButton(props: TimeSyncButtonProps) {
  8. const { onClick, isSynced } = props;
  9. const syncTimesTooltip = () => {
  10. const { isSynced } = props;
  11. const tooltip = isSynced ? 'Unsync all views' : 'Sync all views to this time range';
  12. return <>{tooltip}</>;
  13. };
  14. return (
  15. <Tooltip content={syncTimesTooltip} placement="bottom">
  16. <ToolbarButton
  17. icon="link"
  18. variant={isSynced ? 'active' : 'default'}
  19. aria-label={isSynced ? 'Synced times' : 'Unsynced times'}
  20. onClick={onClick}
  21. />
  22. </Tooltip>
  23. );
  24. }