mirror of
https://github.com/grafana/grafana.git
synced 2025-01-15 19:22:34 -06:00
6937f3549b
* Remove icon types duplicates, update getAllIcons * Update Explore-related icons, positioning * Update Getting started icons * Update navmodel * Style adjustments, css changes * Update tests * Updatee icon name in test file
65 lines
1.7 KiB
TypeScript
65 lines
1.7 KiB
TypeScript
import React from 'react';
|
|
import { Icon } from '@grafana/ui';
|
|
|
|
function formatLatency(value: number) {
|
|
return `${(value / 1000).toFixed(1)}s`;
|
|
}
|
|
|
|
export type Props = {
|
|
canToggleEditorModes: boolean;
|
|
isDisabled?: boolean;
|
|
isNotStarted: boolean;
|
|
latency: number;
|
|
onClickToggleEditorMode: () => void;
|
|
onClickToggleDisabled: () => void;
|
|
onClickRemoveButton: () => void;
|
|
};
|
|
|
|
export function QueryRowActions(props: Props) {
|
|
const {
|
|
canToggleEditorModes,
|
|
onClickToggleEditorMode,
|
|
onClickToggleDisabled,
|
|
onClickRemoveButton,
|
|
isDisabled,
|
|
isNotStarted,
|
|
latency,
|
|
} = props;
|
|
|
|
return (
|
|
<div className="gf-form-inline flex-shrink-0">
|
|
{canToggleEditorModes && (
|
|
<div className="gf-form">
|
|
<button
|
|
aria-label="Edit mode button"
|
|
className="gf-form-label gf-form-label--btn"
|
|
onClick={onClickToggleEditorMode}
|
|
>
|
|
<Icon name="pen" />
|
|
</button>
|
|
</div>
|
|
)}
|
|
<div className="gf-form">
|
|
<button disabled className="gf-form-label" title="Query row latency">
|
|
{formatLatency(latency)}
|
|
</button>
|
|
</div>
|
|
<div className="gf-form">
|
|
<button
|
|
disabled={isNotStarted}
|
|
className="gf-form-label gf-form-label--btn"
|
|
onClick={onClickToggleDisabled}
|
|
title={isDisabled ? 'Enable query' : 'Disable query'}
|
|
>
|
|
<Icon name={isDisabled ? 'eye-slash' : 'eye'} />
|
|
</button>
|
|
</div>
|
|
<div className="gf-form">
|
|
<button className="gf-form-label gf-form-label--btn" onClick={onClickRemoveButton} title="Remove query">
|
|
<Icon name="minus" />
|
|
</button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|