mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Scopes: Allow node title to expand the container (#89682)
This commit is contained in:
@@ -4,7 +4,7 @@ import { useEffect, useMemo, useState } from 'react';
|
||||
import Skeleton from 'react-loading-skeleton';
|
||||
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { Checkbox, FilterInput, IconButton, RadioButtonDot, useStyles2 } from '@grafana/ui';
|
||||
import { Checkbox, FilterInput, Icon, RadioButtonDot, useStyles2 } from '@grafana/ui';
|
||||
import { t, Trans } from 'app/core/internationalization';
|
||||
|
||||
import { NodesMap, TreeScope } from './types';
|
||||
@@ -105,20 +105,24 @@ export function ScopesTreeLevel({
|
||||
)
|
||||
) : null}
|
||||
|
||||
{childNode.isExpandable && (
|
||||
<IconButton
|
||||
name={!childNode.isExpanded ? 'angle-right' : 'angle-down'}
|
||||
{childNode.isExpandable ? (
|
||||
<button
|
||||
className={styles.itemExpand}
|
||||
data-testid={`scopes-tree-${childNode.name}-expand`}
|
||||
aria-label={
|
||||
childNode.isExpanded ? t('scopes.tree.collapse', 'Collapse') : t('scopes.tree.expand', 'Expand')
|
||||
}
|
||||
data-testid={`scopes-tree-${childNode.name}-expand`}
|
||||
onClick={() => {
|
||||
onNodeUpdate(childNodePath, !childNode.isExpanded, childNode.query);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
>
|
||||
<Icon name={!childNode.isExpanded ? 'angle-right' : 'angle-down'} />
|
||||
|
||||
<span data-testid={`scopes-tree-${childNode.name}-title`}>{childNode.title}</span>
|
||||
{childNode.title}
|
||||
</button>
|
||||
) : (
|
||||
<span data-testid={`scopes-tree-${childNode.name}-title`}>{childNode.title}</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className={styles.itemChildren}>
|
||||
@@ -165,6 +169,15 @@ const getStyles = (theme: GrafanaTheme2) => {
|
||||
gap: 0,
|
||||
}),
|
||||
}),
|
||||
itemExpand: css({
|
||||
alignItems: 'center',
|
||||
background: 'none',
|
||||
border: 0,
|
||||
display: 'flex',
|
||||
gap: theme.spacing(1),
|
||||
margin: 0,
|
||||
padding: 0,
|
||||
}),
|
||||
itemChildren: css({
|
||||
paddingLeft: theme.spacing(4),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user