2021-07-12 09:42:04 -05:00
|
|
|
import { css, cx } from '@emotion/css';
|
2022-04-22 08:33:13 -05:00
|
|
|
import React from 'react';
|
|
|
|
|
2021-07-12 09:42:04 -05:00
|
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
2020-04-30 02:26:59 -05:00
|
|
|
import { selectors } from '@grafana/e2e-selectors';
|
2022-04-22 08:33:13 -05:00
|
|
|
import { IconButton, IconName, useStyles2 } from '@grafana/ui';
|
2020-04-09 14:23:22 -05:00
|
|
|
|
2022-06-21 09:53:10 -05:00
|
|
|
export interface QueryOperationActionProps {
|
2020-04-09 14:23:22 -05:00
|
|
|
icon: IconName;
|
Chore: Fix all Typescript strict null errors (#26204)
* 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>
2020-07-10 05:46:59 -05:00
|
|
|
title: string;
|
2020-04-09 14:23:22 -05:00
|
|
|
onClick: (e: React.MouseEvent) => void;
|
|
|
|
disabled?: boolean;
|
2021-07-12 09:42:04 -05:00
|
|
|
active?: boolean;
|
2020-04-09 14:23:22 -05:00
|
|
|
}
|
|
|
|
|
2021-07-12 09:42:04 -05:00
|
|
|
export const QueryOperationAction: React.FC<QueryOperationActionProps> = ({
|
|
|
|
icon,
|
|
|
|
active,
|
|
|
|
disabled,
|
|
|
|
title,
|
|
|
|
onClick,
|
|
|
|
}) => {
|
|
|
|
const styles = useStyles2(getStyles);
|
2020-04-11 09:07:18 -05:00
|
|
|
|
2020-04-09 14:23:22 -05:00
|
|
|
return (
|
2021-07-12 09:42:04 -05:00
|
|
|
<div className={cx(styles.icon, active && styles.active)}>
|
|
|
|
<IconButton
|
|
|
|
name={icon}
|
|
|
|
title={title}
|
|
|
|
className={styles.icon}
|
|
|
|
disabled={!!disabled}
|
|
|
|
onClick={onClick}
|
|
|
|
type="button"
|
|
|
|
aria-label={selectors.components.QueryEditorRow.actionButton(title)}
|
|
|
|
/>
|
|
|
|
</div>
|
2020-04-09 14:23:22 -05:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-04-11 09:07:18 -05:00
|
|
|
QueryOperationAction.displayName = 'QueryOperationAction';
|
|
|
|
|
2021-07-12 09:42:04 -05:00
|
|
|
const getStyles = (theme: GrafanaTheme2) => {
|
2020-04-09 14:23:22 -05:00
|
|
|
return {
|
2020-04-11 09:07:18 -05:00
|
|
|
icon: css`
|
2021-07-12 09:42:04 -05:00
|
|
|
display: flex;
|
|
|
|
position: relative;
|
|
|
|
color: ${theme.colors.text.secondary};
|
|
|
|
`,
|
|
|
|
active: css`
|
|
|
|
&::before {
|
|
|
|
display: block;
|
|
|
|
content: ' ';
|
|
|
|
position: absolute;
|
|
|
|
left: -1px;
|
|
|
|
right: 2px;
|
|
|
|
height: 3px;
|
|
|
|
border-radius: 2px;
|
|
|
|
bottom: -8px;
|
|
|
|
background-image: ${theme.colors.gradients.brandHorizontal} !important;
|
|
|
|
}
|
2020-04-11 09:07:18 -05:00
|
|
|
`,
|
2020-04-09 14:23:22 -05:00
|
|
|
};
|
2021-07-12 09:42:04 -05:00
|
|
|
};
|