mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* Chore: Fix typescript strict null errors * Added new limit * Fixed ts issue * fixed tests * trying to fix type inference * Fixing more ts errors * Revert tsconfig option * Fix * Fixed code * More fixes * fix tests * Updated snapshot * Chore: More ts strict null fixes * More fixes in some really messed up azure config components * More fixes, current count: 441 * 419 * More fixes * Fixed invalid initial state in explore * Fixing tests * Fixed tests * Explore fix * More fixes * Progress * Sub 300 * Now at 218 * Progress * Update * Progress * Updated tests * at 159 * fixed tests * Progress * YAy blow 100! at 94 * 10,9,8,7,6,5,4,3,2,1... lift off * Fixed tests * Fixed more type errors Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { IconButton, IconName, stylesFactory, useTheme } from '@grafana/ui';
|
|
import React from 'react';
|
|
import { css } from 'emotion';
|
|
import { GrafanaTheme } from '@grafana/data';
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
|
|
interface QueryOperationActionProps {
|
|
icon: IconName;
|
|
title: string;
|
|
onClick: (e: React.MouseEvent) => void;
|
|
disabled?: boolean;
|
|
}
|
|
|
|
export const QueryOperationAction: React.FC<QueryOperationActionProps> = ({ icon, disabled, title, ...otherProps }) => {
|
|
const theme = useTheme();
|
|
const styles = getStyles(theme);
|
|
|
|
const onClick = (e: React.MouseEvent) => {
|
|
if (!disabled) {
|
|
otherProps.onClick(e);
|
|
}
|
|
};
|
|
return (
|
|
<IconButton
|
|
name={icon}
|
|
title={title}
|
|
className={styles.icon}
|
|
disabled={!!disabled}
|
|
onClick={onClick}
|
|
surface="header"
|
|
aria-label={selectors.components.QueryEditorRow.actionButton(title)}
|
|
/>
|
|
);
|
|
};
|
|
|
|
QueryOperationAction.displayName = 'QueryOperationAction';
|
|
|
|
const getStyles = stylesFactory((theme: GrafanaTheme) => {
|
|
return {
|
|
icon: css`
|
|
color: ${theme.colors.textWeak};
|
|
`,
|
|
};
|
|
});
|