diff --git a/packages/patternfly-4/react-core/src/components/Nav/Nav.tsx b/packages/patternfly-4/react-core/src/components/Nav/Nav.tsx index 6a7dbff9cfc..27f9422145d 100644 --- a/packages/patternfly-4/react-core/src/components/Nav/Nav.tsx +++ b/packages/patternfly-4/react-core/src/components/Nav/Nav.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import styles from '@patternfly/react-styles/css/components/Nav/nav'; import { css } from '@patternfly/react-styles'; import { NavVariants } from './NavVariants'; +import { InjectedOuiaProps, withOuiaContext } from '../withOuia'; import { Omit } from '../../helpers/typeUtils'; @@ -29,7 +30,7 @@ export interface NavProps extends Omit { +class Nav extends React.Component { static defaultProps: NavProps = { 'aria-label': '', "children": null, @@ -82,7 +83,7 @@ export class Nav extends React.Component { } render() { - const { 'aria-label': ariaLabel, children, className, onSelect, onToggle, theme, ...props } = this.props; + const { 'aria-label': ariaLabel, children, className, onSelect, onToggle, theme, ouiaContext, ouiaId, ...props } = this.props; const { showLeftScrollButton, showRightScrollButton } = this.state; const childrenProps: any = (children as any).props; @@ -108,6 +109,10 @@ export class Nav extends React.Component { ? typeof childrenProps !== 'undefined' && childrenProps.variant === 'tertiary' ? 'Local' : 'Global' : ariaLabel } + {...ouiaContext.isOuia && { + 'data-ouia-component-type': 'Nav', + 'data-ouia-component-id': ouiaId || ouiaContext.ouiaId + }} {...props} > {children} @@ -116,3 +121,7 @@ export class Nav extends React.Component { ); } } + + +const NavWithOuiaContext = withOuiaContext(Nav); +export { NavWithOuiaContext as Nav }; diff --git a/packages/patternfly-4/react-core/src/components/Nav/__snapshots__/Nav.test.tsx.snap b/packages/patternfly-4/react-core/src/components/Nav/__snapshots__/Nav.test.tsx.snap index e72deda3933..0fab5400e6e 100644 --- a/packages/patternfly-4/react-core/src/components/Nav/__snapshots__/Nav.test.tsx.snap +++ b/packages/patternfly-4/react-core/src/components/Nav/__snapshots__/Nav.test.tsx.snap @@ -1,1520 +1,2082 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Dark Nav List 1`] = ` - +
  • + + Link 4 + +
  • + + + + + + + `; exports[`Default Nav List - Trigger item active update 1`] = ` - +
  • + + Link 4 + +
  • + + + + + + + `; exports[`Default Nav List 1`] = ` - + + +`; + +exports[`Expandable Nav List - Trigger toggle 1`] = ` + + -
  • - + Link 1 + + Link 2 - -
  • -
    - -
  • - + Link 3 - -
  • -
    - -
  • - + Link 4 - -
  • -
    - - - - -`; - -exports[`Expandable Nav List - Trigger toggle 1`] = ` - +
  • + + Link 4 + +
  • + + + + + + + + + + + `; exports[`Expandable Nav List 1`] = ` - +
  • + + Link 4 + +
  • + + + + + + + + + + + `; exports[`Expandable Nav List with aria label 1`] = ` - +
  • + + Link 4 + +
  • + + + + + + + + + + + `; exports[`Horizontal Nav List 1`] = ` - + + + + + + + + + + + `; exports[`Nav Grouped List 1`] = ` - + + + + + + `; exports[`Nav List with custom item nodes 1`] = ` - + + + + + + + + + + + `; exports[`Simple Nav List 1`] = ` - +
  • + + Link 4 + +
  • + + + + + + + `; exports[`Tertiary Nav List 1`] = ` - + + + + + + + + + + + `;