mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
[Panel Header - Fullstory]: Make sure new menu's are findable in fullstory (#65167)
This commit is contained in:
parent
d73fdcfc11
commit
42b58fbca6
@ -72,6 +72,7 @@ export const Components = {
|
|||||||
Panel: {
|
Panel: {
|
||||||
title: (title: string) => `data-testid Panel header ${title}`,
|
title: (title: string) => `data-testid Panel header ${title}`,
|
||||||
headerItems: (item: string) => `Panel header item ${item}`,
|
headerItems: (item: string) => `Panel header item ${item}`,
|
||||||
|
menuItems: (item: string) => `data-testid Panel menu item ${item}`,
|
||||||
containerByTitle: (title: string) => `${title} panel`,
|
containerByTitle: (title: string) => `${title} panel`,
|
||||||
headerCornerInfo: (mode: string) => `Panel header ${mode}`,
|
headerCornerInfo: (mode: string) => `Panel header ${mode}`,
|
||||||
},
|
},
|
||||||
|
@ -46,6 +46,8 @@ export interface MenuItemProps<T = any> {
|
|||||||
customSubMenuContainerStyles?: CSSProperties;
|
customSubMenuContainerStyles?: CSSProperties;
|
||||||
/** Shortcut key combination */
|
/** Shortcut key combination */
|
||||||
shortcut?: string;
|
shortcut?: string;
|
||||||
|
/** Test id for e2e tests and fullstory*/
|
||||||
|
testId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
@ -68,6 +70,7 @@ export const MenuItem = React.memo(
|
|||||||
tabIndex = -1,
|
tabIndex = -1,
|
||||||
customSubMenuContainerStyles,
|
customSubMenuContainerStyles,
|
||||||
shortcut,
|
shortcut,
|
||||||
|
testId,
|
||||||
} = props;
|
} = props;
|
||||||
const styles = useStyles2(getStyles);
|
const styles = useStyles2(getStyles);
|
||||||
const [isActive, setIsActive] = useState(active);
|
const [isActive, setIsActive] = useState(active);
|
||||||
@ -150,6 +153,7 @@ export const MenuItem = React.memo(
|
|||||||
role={url === undefined ? role : undefined}
|
role={url === undefined ? role : undefined}
|
||||||
data-role="menuitem" // used to identify menuitem in Menu.tsx
|
data-role="menuitem" // used to identify menuitem in Menu.tsx
|
||||||
ref={localRef}
|
ref={localRef}
|
||||||
|
data-testid={testId}
|
||||||
aria-label={ariaLabel}
|
aria-label={ariaLabel}
|
||||||
aria-checked={ariaChecked}
|
aria-checked={ariaChecked}
|
||||||
tabIndex={tabIndex}
|
tabIndex={tabIndex}
|
||||||
|
@ -2,6 +2,7 @@ import classnames from 'classnames';
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
|
|
||||||
import { PanelMenuItem } from '@grafana/data';
|
import { PanelMenuItem } from '@grafana/data';
|
||||||
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
import { Menu } from '@grafana/ui';
|
import { Menu } from '@grafana/ui';
|
||||||
|
|
||||||
import { PanelHeaderMenuItem } from './PanelHeaderMenuItem';
|
import { PanelHeaderMenuItem } from './PanelHeaderMenuItem';
|
||||||
@ -63,6 +64,7 @@ export function PanelHeaderMenuNew({ items }: Props) {
|
|||||||
url={item.href}
|
url={item.href}
|
||||||
onClick={item.onClick}
|
onClick={item.onClick}
|
||||||
shortcut={item.shortcut}
|
shortcut={item.shortcut}
|
||||||
|
testId={selectors.components.Panels.Panel.menuItems(item.text)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -20,10 +20,13 @@ export const PanelHeaderMenuItem = (props: Props & PanelMenuItem) => {
|
|||||||
return isDivider ? (
|
return isDivider ? (
|
||||||
<li className="divider" />
|
<li className="divider" />
|
||||||
) : (
|
) : (
|
||||||
<li className={isSubMenu ? `dropdown-submenu ${getDropdownLocationCssClass(ref)}` : undefined} ref={setRef}>
|
<li
|
||||||
|
className={isSubMenu ? `dropdown-submenu ${getDropdownLocationCssClass(ref)}` : undefined}
|
||||||
|
ref={setRef}
|
||||||
|
data-testid={selectors.components.Panels.Panel.menuItems(props.text)}
|
||||||
|
>
|
||||||
<a onClick={props.onClick} href={props.href}>
|
<a onClick={props.onClick} href={props.href}>
|
||||||
{icon && <Icon name={icon} className={styles.menuIconClassName} />}
|
{icon && <Icon name={icon} className={styles.menuIconClassName} />}
|
||||||
|
|
||||||
<span className="dropdown-item-text" aria-label={selectors.components.Panels.Panel.headerItems(props.text)}>
|
<span className="dropdown-item-text" aria-label={selectors.components.Panels.Panel.headerItems(props.text)}>
|
||||||
{props.text}
|
{props.text}
|
||||||
{isSubMenu && <Icon name="angle-right" className={styles.shortcutIconClassName} />}
|
{isSubMenu && <Icon name="angle-right" className={styles.shortcutIconClassName} />}
|
||||||
|
Loading…
Reference in New Issue
Block a user