Skip to content

Commit 05bee77

Browse files
authored
perf(ouia): make ouia functional, add namespace (#3927)
* helper implementation * update ouia components * rename data-ouia-id to data-ouia-component-id * fix lint
1 parent 83924aa commit 05bee77

File tree

81 files changed

+178936
-235682
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+178936
-235682
lines changed

packages/react-core/src/components/AboutModal/__tests__/Generated/__snapshots__/AboutModalBoxCloseButton.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports[`AboutModalBoxCloseButton should match snapshot (auto-generated) 1`] = `
44
<div
55
className="pf-c-about-modal-box__close ''"
66
>
7-
<Component
7+
<Button
88
aria-label="Close Dialog"
99
onClick={[Function]}
1010
variant="plain"
@@ -15,6 +15,6 @@ exports[`AboutModalBoxCloseButton should match snapshot (auto-generated) 1`] = `
1515
size="sm"
1616
title={null}
1717
/>
18-
</Component>
18+
</Button>
1919
</div>
2020
`;

packages/react-core/src/components/AboutModal/__tests__/__snapshots__/AboutModalBoxCloseButton.test.tsx.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports[`AboutModalBoxCloseButton Test 1`] = `
44
<div
55
className="pf-c-about-modal-box__close"
66
>
7-
<Component
7+
<Button
88
aria-label="Close Dialog"
99
onClick={[Function]}
1010
variant="plain"
@@ -15,15 +15,15 @@ exports[`AboutModalBoxCloseButton Test 1`] = `
1515
size="sm"
1616
title={null}
1717
/>
18-
</Component>
18+
</Button>
1919
</div>
2020
`;
2121

2222
exports[`AboutModalBoxCloseButton Test close button aria label 1`] = `
2323
<div
2424
className="pf-c-about-modal-box__close"
2525
>
26-
<Component
26+
<Button
2727
aria-label="Klose Daylok"
2828
onClick={[Function]}
2929
variant="plain"
@@ -34,15 +34,15 @@ exports[`AboutModalBoxCloseButton Test close button aria label 1`] = `
3434
size="sm"
3535
title={null}
3636
/>
37-
</Component>
37+
</Button>
3838
</div>
3939
`;
4040

4141
exports[`AboutModalBoxCloseButton Test onclose 1`] = `
4242
<div
4343
className="pf-c-about-modal-box__close"
4444
>
45-
<Component
45+
<Button
4646
aria-label="Close Dialog"
4747
onClick={[MockFunction]}
4848
variant="plain"
@@ -53,6 +53,6 @@ exports[`AboutModalBoxCloseButton Test onclose 1`] = `
5353
size="sm"
5454
title={null}
5555
/>
56-
</Component>
56+
</Button>
5757
</div>
5858
`;

packages/react-core/src/components/Alert/Alert.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { css } from '@patternfly/react-styles';
33
import styles from '@patternfly/react-styles/css/components/Alert/alert';
44
import accessibleStyles from '@patternfly/react-styles/css/utilities/Accessibility/accessibility';
55
import { AlertIcon } from './AlertIcon';
6-
import { capitalize } from '../../helpers/util';
6+
import { capitalize, getOUIAProps, OUIAProps } from '../../helpers';
77
import { Omit } from '../../helpers/typeUtils';
8-
import { InjectedOuiaProps, withOuiaContext } from '../withOuia';
98

109
export enum AlertVariant {
1110
success = 'success',
@@ -36,7 +35,7 @@ export interface AlertProps extends Omit<React.HTMLProps<HTMLDivElement>, 'actio
3635
isLiveRegion?: boolean;
3736
}
3837

39-
const Alert: React.FunctionComponent<AlertProps & InjectedOuiaProps> = ({
38+
export const Alert: React.FunctionComponent<AlertProps & OUIAProps> = ({
4039
variant = AlertVariant.info,
4140
isInline = false,
4241
isLiveRegion = false,
@@ -46,10 +45,9 @@ const Alert: React.FunctionComponent<AlertProps & InjectedOuiaProps> = ({
4645
title,
4746
children = '',
4847
className = '',
49-
ouiaContext = null,
50-
ouiaId = null,
48+
ouiaId,
5149
...props
52-
}: AlertProps & InjectedOuiaProps) => {
50+
}: AlertProps & OUIAProps) => {
5351
const readerTitle = (
5452
<React.Fragment>
5553
<span className={css(accessibleStyles.screenReader)}>{variantLabel}</span>
@@ -69,10 +67,7 @@ const Alert: React.FunctionComponent<AlertProps & InjectedOuiaProps> = ({
6967
{...props}
7068
className={customClassName}
7169
aria-label={ariaLabel}
72-
{...(ouiaContext.isOuia && {
73-
'data-ouia-component-type': 'Alert',
74-
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
75-
})}
70+
{...getOUIAProps('Alert', ouiaId)}
7671
{...(isLiveRegion && {
7772
'aria-live': 'polite',
7873
'aria-atomic': 'false'
@@ -87,6 +82,3 @@ const Alert: React.FunctionComponent<AlertProps & InjectedOuiaProps> = ({
8782
</div>
8883
);
8984
};
90-
91-
const AlertWithOuiaContext = withOuiaContext(Alert);
92-
export { AlertWithOuiaContext as Alert };
Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`Alert should match snapshot (auto-generated) 1`] = `
4-
<ContextConsumer>
5-
<Component />
6-
</ContextConsumer>
4+
<div
5+
aria-label="string"
6+
className="pf-c-alert pf-m-success ''"
7+
data-ouia-component-id={0}
8+
data-ouia-component-type="PF4/Alert"
9+
data-ouia-safe={true}
10+
>
11+
<AlertIcon
12+
variant="success"
13+
/>
14+
<h4
15+
className="pf-c-alert__title"
16+
>
17+
<span
18+
className="pf-u-screen-reader"
19+
>
20+
string
21+
</span>
22+
<div>
23+
ReactNode
24+
</div>
25+
</h4>
26+
</div>
727
`;

packages/react-core/src/components/Alert/__tests__/Generated/__snapshots__/AlertActionCloseButton.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`AlertActionCloseButton should match snapshot (auto-generated) 1`] = `
4-
<Component
4+
<Button
55
aria-label="''"
66
onClick={[Function]}
77
variant="plain"
@@ -12,5 +12,5 @@ exports[`AlertActionCloseButton should match snapshot (auto-generated) 1`] = `
1212
size="sm"
1313
title={null}
1414
/>
15-
</Component>
15+
</Button>
1616
`;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`AlertActionLink should match snapshot (auto-generated) 1`] = `
4-
<Component
4+
<Button
55
className="''"
66
variant="link"
77
>
88
''
9-
</Component>
9+
</Button>
1010
`;

0 commit comments

Comments
 (0)