Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const Alert: React.FunctionComponent<AlertProps & InjectedOuiaProps> = ({
aria-label={ariaLabel}
{...(ouiaContext.isOuia && {
'data-ouia-component-type': 'Alert',
'data-ouia-component-ns': 'PF4',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be defined in one place, instead of within each component?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dlabrecq it's a good point but my knowledge of typescript is limited, I believe it can be done somewhere here https://github.com/patternfly/patternfly-react/blob/master/packages/patternfly-4/react-core/src/components/withOuia/withOuia.tsx

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking we just need to import a common file. Perhaps ouia.ts or withOuia.tsx would be a good location to store the namespace?

.../packages/patternfly-4/react-core/src/components/withOuia/ouia.ts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance we can use a qualified URI as the namespace, instead of a basic string? Something like https://www.patternfly.org/v4 as the namespace is more semantic and readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
})}
{...(isLiveRegion && {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const Breadcrumb: React.FunctionComponent<BreadcrumbProps & InjectedOuiaProps> =
className={css(styles.breadcrumb, className)}
{...(ouiaContext.isOuia && {
'data-ouia-component-type': 'Breadcrumb',
'data-ouia-component-ns': 'PF4',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
})}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const Button: React.FunctionComponent<ButtonProps & InjectedOuiaProps> = ({
type={isButtonElement ? type : null}
{...(ouiaContext.isOuia && {
'data-ouia-component-type': 'Button',
'data-ouia-component-ns': 'PF4',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
})}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Chip extends React.Component<ChipProps & InjectedOuiaProps, ChipState> {
className={css(styles.chip, styles.modifiers.overflow, className)}
{...ouiaContext.isOuia && {
'data-ouia-component-type': 'OverflowChip',
'data-ouia-component-ns': 'PF4',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
}}
>
Expand Down Expand Up @@ -93,6 +94,7 @@ class Chip extends React.Component<ChipProps & InjectedOuiaProps, ChipState> {
className={css(styles.chip, isReadOnly && styles.modifiers.readOnly, className)}
{...ouiaContext.isOuia && {
'data-ouia-component-type': 'Chip',
'data-ouia-component-ns': 'PF4',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
}}
>
Expand All @@ -118,6 +120,7 @@ class Chip extends React.Component<ChipProps & InjectedOuiaProps, ChipState> {
className={css(styles.chip, isReadOnly && styles.modifiers.readOnly, className)}
{...ouiaContext.isOuia && {
'data-ouia-component-type': 'Chip',
'data-ouia-component-ns': 'PF4',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class DropdownWithContext extends React.Component<DropdownProps & InjectedOuiaPr
ref={this.baseComponentRef}
{...ouiaContext.isOuia && {
'data-ouia-component-type': ouiaComponentType,
'data-ouia-component-ns': 'PF4',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class Nav extends React.Component<NavProps & InjectedOuiaProps> {
}
{...(ouiaContext.isOuia && {
'data-ouia-component-type': 'Nav',
'data-ouia-component-ns': 'PF4',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
})}
{...props}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ const Pagination: React.FunctionComponent<PaginationProps & InjectedOuiaProps> =
id={widgetId}
{...(ouiaContext.isOuia && {
'data-ouia-component-type': 'Pagination',
'data-ouia-component-ns': 'PF4',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
})}
{...props}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ class Select extends React.Component<SelectProps & InjectedOuiaProps, SelectStat
style={{ width }}
{...(ouiaContext.isOuia && {
'data-ouia-component-type': 'Select',
'data-ouia-component-ns': 'PF4',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
})}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Switch extends React.Component<SwitchProps & InjectedOuiaProps> {
htmlFor={this.id}
{...(ouiaContext.isOuia && {
'data-ouia-component-type': 'Switch',
'data-ouia-component-ns': 'PF4',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
})}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ class Tabs extends React.Component<TabsProps & InjectedOuiaProps, TabsState> {
)}
{...(ouiaContext.isOuia && {
'data-ouia-component-type': 'Tabs',
'data-ouia-component-ns': 'PF4',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
})}
id={id && id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const { ouiaContext, ouiaId } = this.props;
className=""
htmlFor=""
{...ouiaContext.isOuia && {
'data-ouia-component-type': 'Switch',
'data-ouia-component-type': 'Switch',
'data-ouia-component-ns': 'PF4',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
}}
>my label</label>
Expand All @@ -36,20 +37,20 @@ const { ouiaContext, ouiaId } = this.props;
```
<Switch />
```
> render's ouia attribute **data-ouia-component-type="Switch"**
> render's ouia attribute **data-ouia-component-type="Switch" data-ouia-component-ns="PF4"**
#### Case 3: enable ouia through local storage and generate id
##### in local storage _ouia: true_
##### in local storage _ouia-generate-id: true_
```
<Switch />
```
> render's ouia attributes **data-ouia-component-type="Switch" data-ouia-component-id="0"**
> render's ouia attributes **data-ouia-component-type="Switch" data-ouia-component-ns="PF4" data-ouia-component-id="0"**
#### Case 4: enable ouia through local storage and provide id
##### in local storage _ouia: true_
```
<Switch ouiaId="my_switch_id" />
```
> render's ouia attributes **data-ouia-component-type="Switch" data-ouia-component-id="my_switch_id"**
> render's ouia attributes **data-ouia-component-type="Switch" data-ouia-component-ns="PF4" data-ouia-component-id="my_switch_id"**
#### Case 5: enable ouia through context and provide id
##### Note: If context provided _isOuia_ is true and local storage provided _isOuia_ is false, context will win out. Context will also win if its _isOuia_ is false and local storage's is true. Context > local storage
```
Expand All @@ -58,4 +59,4 @@ import { OuiaContext } from '@patternfly/react-core';
<Switch ouiaId="my_switch_id" />
</OuiaContext.Provider>
```
> render's ouia attributes **data-ouia-component-type="Switch" data-ouia-component-id="my_switch_id"**
> render's ouia attributes **data-ouia-component-type="Switch" data-ouia-component-ns="PF4" data-ouia-component-id="my_switch_id"**
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ describe('Switch Demo Test', () => {

it('Verify OUIA attributes exist', () => {
cy.get('.pf-c-switch[for="simple-switch"]').should('have.attr', 'data-ouia-component-type', 'Switch');
cy.get('.pf-c-switch[for="simple-switch"]').should('have.attr', 'data-ouia-component-ns', 'PF4');
cy.get('.pf-c-switch[for="simple-switch"]').should('have.attr', 'data-ouia-component-id', 'first_switch');
cy.get('.pf-c-switch[for="disabled-switch-off"]').should('have.attr', 'data-ouia-component-type', 'Switch');
cy.get('.pf-c-switch[for="disabled-switch-off"]').should('have.attr', 'data-ouia-component-ns', 'PF4');
cy.get('.pf-c-switch[for="disabled-switch-off"]').should('not.have.attr', 'data-ouia-component-id');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class RowWrapper extends React.Component<RowWrapperProps & InjectedOuiaProps, {}
hidden={isExpanded !== undefined && !isExpanded}
{...ouiaContext.isOuia && {
'data-ouia-component-type': 'TableRow',
'data-ouia-component-ns': 'PF4',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ class Table extends React.Component<TableProps & InjectedOuiaProps, {}> {
)}
{...ouiaContext.isOuia && {
'data-ouia-component-type': 'Table',
'data-ouia-component-ns': 'PF4',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
}}
>
Expand Down