([]);
+ const { query, data, datasource } = props;
+ const styles = useStyles2(getStyles);
+
+ useEffect(() => {
+ const promQuery = { expr: query.expr, refId: query.refId };
+ const hints = datasource.getQueryHints(promQuery, data?.series || []).filter((hint) => hint.fix?.action);
+ setHints(hints);
+ }, [datasource, data, query]);
+
+ return (
+ <>
+ {hints.length > 0 && (
+
+ {hints.map((hint) => {
+ return (
+
+
+
+ );
+ })}
+
+ )}
+ >
+ );
+}
+
+function onHintButtonClick(hint: QueryHint, props: PromQueryEditorProps) {
+ reportInteraction('grafana_query_builder_hints_clicked', {
+ hint: hint.type,
+ datasourceType: props.datasource.type,
+ });
+
+ if (hint.fix?.action) {
+ const newQuery = props.datasource.modifyQuery(props.query, hint.fix.action);
+ return props.onChange(newQuery);
+ }
+}
+
+const getStyles = (theme: GrafanaTheme2) => {
+ return {
+ container: css({
+ display: 'flex',
+ alignItems: 'start',
+ }),
+ hint: css({
+ marginRight: theme.spacing(1),
+ padEnd: theme.spacing(2),
+ }),
+ };
+};