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 * Fixed incorrect type * removed unused import
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import React from 'react';
|
|
import { Icon } from '@grafana/ui';
|
|
|
|
export interface FunctionDescriptor {
|
|
text: string;
|
|
params: string[];
|
|
def: {
|
|
category: string;
|
|
defaultParams: string[];
|
|
description?: string;
|
|
fake: boolean;
|
|
name: string;
|
|
params: string[];
|
|
};
|
|
}
|
|
|
|
export interface FunctionEditorControlsProps {
|
|
onMoveLeft: (func: FunctionDescriptor) => void;
|
|
onMoveRight: (func: FunctionDescriptor) => void;
|
|
onRemove: (func: FunctionDescriptor) => void;
|
|
}
|
|
|
|
const FunctionHelpButton = (props: { description?: string; name: string; onDescriptionShow: () => void }) => {
|
|
if (props.description) {
|
|
return <Icon className="pointer" name="question-circle" onClick={props.onDescriptionShow} />;
|
|
}
|
|
|
|
return (
|
|
<Icon
|
|
className="pointer"
|
|
name="question-circle"
|
|
onClick={() => {
|
|
window.open(
|
|
'http://graphite.readthedocs.org/en/latest/functions.html#graphite.render.functions.' + props.name,
|
|
'_blank'
|
|
);
|
|
}}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export const FunctionEditorControls = (
|
|
props: FunctionEditorControlsProps & {
|
|
func: FunctionDescriptor;
|
|
onDescriptionShow: () => void;
|
|
}
|
|
) => {
|
|
const { func, onMoveLeft, onMoveRight, onRemove, onDescriptionShow } = props;
|
|
return (
|
|
<div
|
|
style={{
|
|
display: 'flex',
|
|
width: '60px',
|
|
justifyContent: 'space-between',
|
|
}}
|
|
>
|
|
<Icon name="arrow-left" onClick={() => onMoveLeft(func)} />
|
|
<FunctionHelpButton
|
|
name={func.def.name}
|
|
description={func.def.description}
|
|
onDescriptionShow={onDescriptionShow}
|
|
/>
|
|
<Icon name="times" onClick={() => onRemove(func)} />
|
|
<Icon name="arrow-right" onClick={() => onMoveRight(func)} />
|
|
</div>
|
|
);
|
|
};
|