import { css } from '@emotion/css'; import * as React from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { Checkbox, Icon, useTheme2 } from '@grafana/ui'; import { FieldNameMeta } from './LogsTableWrap'; function getStyles(theme: GrafanaTheme2) { return { dragIcon: css({ cursor: 'drag', marginLeft: theme.spacing(1), opacity: 0.4, }), labelCount: css({ marginLeft: theme.spacing(0.5), marginRight: theme.spacing(0.5), appearance: 'none', background: 'none', border: 'none', fontSize: theme.typography.pxToRem(11), opacity: 0.6, }), contentWrap: css({ display: 'flex', alignItems: 'center', justifyContent: 'space-between', width: '100%', }), // Hide text that overflows, had to select elements within the Checkbox component, so this is a bit fragile checkboxLabel: css({ '> span': { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', display: 'block', maxWidth: '100%', }, }), }; } export function LogsTableNavField(props: { label: string; onChange: () => void; labels: Record; draggable?: boolean; showCount?: boolean; }): React.JSX.Element | undefined { const theme = useTheme2(); const styles = getStyles(theme); if (props.labels[props.label]) { return ( <>
{props.showCount && ( )}
{props.draggable && ( )} ); } return undefined; }