FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(Table): Added OUIA compatibility to Table component by quarckster · Pull Request #2964 · patternfly/patternfly-react · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .snap  (2) .tsx  (2) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
    • RowWrapper.tsx
    • Table.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { debounce } from '@patternfly/react-core';
import { InjectedOuiaProps, withOuiaContext,debounce } from '@patternfly/react-core';
import styles from '@patternfly/react-styles/css/components/Table/table';
import { css } from '@patternfly/react-styles';

Expand All @@ -18,7 +18,7 @@ export interface RowWrapperProps {
rowProps?: Object;
}

export class RowWrapper extends React.Component<RowWrapperProps, {}> {
class RowWrapper extends React.Component<RowWrapperProps & InjectedOuiaProps, {}> {
static defaultProps = {
className: '' as string,
row: {
Expand Down Expand Up @@ -82,6 +82,8 @@ export class RowWrapper extends React.Component<RowWrapperProps, {}> {
onResize,
row: { isExpanded },
rowProps,
ouiaContext,
ouiaId,
...props
} = this.props;

Expand All @@ -95,7 +97,15 @@ export class RowWrapper extends React.Component<RowWrapperProps, {}> {
isExpanded && styles.modifiers.expanded
)}
hidden={isExpanded !== undefined && !isExpanded}
{...ouiaContext.isOuia && {
'data-ouia-component-type': 'TableRow',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
}}
/>
);
}
}

const RowWrapperWithOuiaContext = withOuiaContext(RowWrapper);

export { RowWrapperWithOuiaContext as RowWrapper };
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import styles from '@patternfly/react-styles/css/components/Table/table';
import stylesGrid from '@patternfly/react-styles/css/components/Table/table-grid';
import { DropdownPosition, DropdownDirection, DropdownItemProps, Omit } from '@patternfly/react-core';
import { InjectedOuiaProps, withOuiaContext, DropdownPosition, DropdownDirection, DropdownItemProps, Omit } from '@patternfly/react-core';
import { css, getModifier } from '@patternfly/react-styles';
import { Provider } from './base';
import { BodyCell } from './BodyCell';
Expand Down Expand Up @@ -229,7 +229,7 @@ export const TableContext = React.createContext({
rows: [] as (IRow | string[])[]
});

export class Table extends React.Component<TableProps, {}> {
class Table extends React.Component<TableProps & InjectedOuiaProps, {}> {
static defaultProps = {
children: null as React.ReactNode,
className: '',
Expand Down Expand Up @@ -286,6 +286,8 @@ export class Table extends React.Component<TableProps, {}> {
rowWrapper,
borders,
role,
ouiaContext,
ouiaId,
...props
} = this.props;

Expand Down Expand Up @@ -345,6 +347,10 @@ export class Table extends React.Component<TableProps, {}> {
variant === TableVariant.compact && borders === false ? styles.modifiers.noBorderRows : null,
className
)}
{...ouiaContext.isOuia && {
'data-ouia-component-type': 'Table',
'data-ouia-component-id': ouiaId || ouiaContext.ouiaId
}}
>
{caption && <caption>{caption}</caption>}
{children}
Expand All @@ -353,3 +359,7 @@ export class Table extends React.Component<TableProps, {}> {
);
}
}

const TableWithOuiaContext = withOuiaContext(Table);

export { TableWithOuiaContext as Table };
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@
exports[`RowWrapper renders correctly 1`] = `
<table>
<tbody>
<RowWrapper
className=""
<Component
onResize={[MockFunction]}
onScroll={[MockFunction]}
row={
Object {
"isExpanded": undefined,
"isOpen": undefined,
}
}
rowProps={null}
trRef={
[MockFunction] {
"calls": Array [
Expand All @@ -32,32 +24,120 @@ exports[`RowWrapper renders correctly 1`] = `
}
}
>
<tr
className=""
hidden={false}
/>
</RowWrapper>
<ComponentWithOuia
component={[Function]}
componentProps={
Object {
"onResize": [MockFunction],
"onScroll": [MockFunction],
"trRef": [MockFunction] {
"calls": Array [
Array [
<tr
class=""
/>,
],
],
"results": Array [
Object {
"isThrow": false,
"value": undefined,
},
],
},
}
}
consumerContext={null}
>
<RowWrapper
className=""
onResize={[MockFunction]}
onScroll={[MockFunction]}
ouiaContext={
Object {
"isOuia": false,
"ouiaId": null,
}
}
row={
Object {
"isExpanded": undefined,
"isOpen": undefined,
}
}
rowProps={null}
trRef={
[MockFunction] {
"calls": Array [
Array [
<tr
class=""
/>,
],
],
"results": Array [
Object {
"isThrow": false,
"value": undefined,
},
],
}
}
>
<tr
className=""
hidden={false}
/>
</RowWrapper>
</ComponentWithOuia>
</Component>
</tbody>
</table>
`;

exports[`RowWrapper renders expanded correctly 1`] = `
<table>
<tbody>
<RowWrapper
className=""
<Component
row={
Object {
"isExpanded": true,
}
}
rowProps={null}
>
<tr
className="pf-c-table__expandable-row pf-m-expanded"
hidden={false}
/>
</RowWrapper>
<ComponentWithOuia
component={[Function]}
componentProps={
Object {
"row": Object {
"isExpanded": true,
},
}
}
consumerContext={null}
>
<RowWrapper
className=""
ouiaContext={
Object {
"isOuia": false,
"ouiaId": null,
}
}
row={
Object {
"isExpanded": true,
}
}
rowProps={null}
>
<tr
className="pf-c-table__expandable-row pf-m-expanded"
hidden={false}
/>
</RowWrapper>
</ComponentWithOuia>
</Component>
</tbody>
</table>
`;
Loading

Back | FazBrowse Home | New Git URL