SecondaryActions.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { css, cx } from '@emotion/css';
  2. import React from 'react';
  3. import { GrafanaTheme2 } from '@grafana/data';
  4. import { Button, HorizontalGroup, useTheme2 } from '@grafana/ui';
  5. type Props = {
  6. addQueryRowButtonDisabled?: boolean;
  7. addQueryRowButtonHidden?: boolean;
  8. richHistoryRowButtonHidden?: boolean;
  9. richHistoryButtonActive?: boolean;
  10. queryInspectorButtonActive?: boolean;
  11. onClickAddQueryRowButton: () => void;
  12. onClickRichHistoryButton: () => void;
  13. onClickQueryInspectorButton: () => void;
  14. };
  15. const getStyles = (theme: GrafanaTheme2) => {
  16. return {
  17. containerMargin: css`
  18. margin-top: ${theme.spacing(2)};
  19. `,
  20. };
  21. };
  22. export function SecondaryActions(props: Props) {
  23. const theme = useTheme2();
  24. const styles = getStyles(theme);
  25. return (
  26. <div className={styles.containerMargin}>
  27. <HorizontalGroup>
  28. {!props.addQueryRowButtonHidden && (
  29. <Button
  30. variant="secondary"
  31. aria-label="Add row button"
  32. onClick={props.onClickAddQueryRowButton}
  33. disabled={props.addQueryRowButtonDisabled}
  34. icon="plus"
  35. >
  36. Add query
  37. </Button>
  38. )}
  39. {!props.richHistoryRowButtonHidden && (
  40. <Button
  41. variant="secondary"
  42. aria-label="Rich history button"
  43. className={cx({ ['explore-active-button']: props.richHistoryButtonActive })}
  44. onClick={props.onClickRichHistoryButton}
  45. icon="history"
  46. >
  47. Query history
  48. </Button>
  49. )}
  50. <Button
  51. variant="secondary"
  52. aria-label="Query inspector button"
  53. className={cx({ ['explore-active-button']: props.queryInspectorButtonActive })}
  54. onClick={props.onClickQueryInspectorButton}
  55. icon="info-circle"
  56. >
  57. Inspector
  58. </Button>
  59. </HorizontalGroup>
  60. </div>
  61. );
  62. }