feat: make tooltip links in query variable editor clickable

This commit is contained in:
Adam Simpson
2022-04-29 14:56:47 -04:00
parent 7112c8494b
commit 87de4d7ebb
4 changed files with 25 additions and 4 deletions
@@ -23,6 +23,8 @@ export interface Props extends Omit<FieldProps, 'css' | 'horizontal' | 'descript
/** Error message to display */ /** Error message to display */
error?: string | null; error?: string | null;
htmlFor?: string; htmlFor?: string;
/** Make tooltip interactive */
interactive?: boolean;
} }
export const InlineField: FC<Props> = ({ export const InlineField: FC<Props> = ({
@@ -38,6 +40,7 @@ export const InlineField: FC<Props> = ({
grow, grow,
error, error,
transparent, transparent,
interactive,
...htmlProps ...htmlProps
}) => { }) => {
const theme = useTheme2(); const theme = useTheme2();
@@ -46,7 +49,13 @@ export const InlineField: FC<Props> = ({
const labelElement = const labelElement =
typeof label === 'string' ? ( typeof label === 'string' ? (
<InlineLabel width={labelWidth} tooltip={tooltip} htmlFor={inputId} transparent={transparent}> <InlineLabel
interactive={interactive}
width={labelWidth}
tooltip={tooltip}
htmlFor={inputId}
transparent={transparent}
>
{label} {label}
</InlineLabel> </InlineLabel>
) : ( ) : (
@@ -23,6 +23,8 @@ export interface Props extends Omit<LabelProps, 'css' | 'description' | 'categor
/** @deprecated */ /** @deprecated */
/** This prop is deprecated and is not used anymore */ /** This prop is deprecated and is not used anymore */
isInvalid?: boolean; isInvalid?: boolean;
/** Make tooltip interactive */
interactive?: boolean;
/** @beta */ /** @beta */
/** Controls which element the InlineLabel should be rendered into */ /** Controls which element the InlineLabel should be rendered into */
as?: React.ElementType; as?: React.ElementType;
@@ -34,6 +36,7 @@ export const InlineLabel: FunctionComponent<Props> = ({
tooltip, tooltip,
width, width,
transparent, transparent,
interactive,
as: Component = 'label', as: Component = 'label',
...rest ...rest
}) => { }) => {
@@ -43,7 +46,7 @@ export const InlineLabel: FunctionComponent<Props> = ({
<Component className={cx(styles.label, className)} {...rest}> <Component className={cx(styles.label, className)} {...rest}>
{children} {children}
{tooltip && ( {tooltip && (
<Tooltip placement="top" content={tooltip} theme="info"> <Tooltip interactive={interactive} placement="top" content={tooltip} theme="info">
<Icon tabIndex={0} name="info-circle" size="sm" className={styles.icon} /> <Icon tabIndex={0} name="info-circle" size="sm" className={styles.icon} />
</Tooltip> </Tooltip>
)} )}
@@ -166,6 +166,7 @@ export const VariableQueryEditor = ({ query, datasource, onChange }: Props) => {
placeholder="attribute name" placeholder="attribute name"
onBlur={(value: string) => onQueryChange({ ...parsedQuery, attributeName: value })} onBlur={(value: string) => onQueryChange({ ...parsedQuery, attributeName: value })}
label="Attribute Name" label="Attribute Name"
interactive={true}
tooltip={ tooltip={
<> <>
{'Attribute or tag to query on. Tags should be formatted "Tags.<name>". '} {'Attribute or tag to query on. Tags should be formatted "Tags.<name>". '}
@@ -10,12 +10,20 @@ interface VariableTextFieldProps {
value: string; value: string;
label: string; label: string;
tooltip?: PopoverContent; tooltip?: PopoverContent;
interactive?: boolean;
} }
export const VariableTextField: FC<VariableTextFieldProps> = ({ label, onBlur, placeholder, value, tooltip }) => { export const VariableTextField: FC<VariableTextFieldProps> = ({
interactive,
label,
onBlur,
placeholder,
value,
tooltip,
}) => {
const [localValue, setLocalValue] = useState(value); const [localValue, setLocalValue] = useState(value);
return ( return (
<InlineField label={label} labelWidth={LABEL_WIDTH} tooltip={tooltip} grow> <InlineField interactive={interactive} label={label} labelWidth={LABEL_WIDTH} tooltip={tooltip} grow>
<Input <Input
aria-label={label} aria-label={label}
placeholder={placeholder} placeholder={placeholder}