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

fix(table): set height auto modifier on table row by boaz0 · Pull Request #3133 · patternfly/patternfly-react · GitHub

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

Filter by extension

Filter by extension .md  (1) .snap  (2) .ts  (1) .tsx  (6) All 4 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
      • TableEmptyStateDemo.tsx
      • Body.tsx
      • RowWrapper.test.tsx
      • RowWrapper.tsx
      • Table.md
      • Table.test.tsx
      • Table.tsx
        • cellHeightAuto.ts
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
@@ -0,0 +1,70 @@
import * as React from 'react';
import {
Table,
TableHeader,
TableBody,
TableProps,
textCenter,
IRow,
ICell,
} from '@patternfly/react-table';
import {
EmptyState,
EmptyStateBody,
EmptyStateIcon,
EmptyStateSecondaryActions,
EmptyStateVariant,
Title,
Button
} from '@patternfly/react-core';
import { CubesIcon } from '@patternfly/react-icons';
class EmptyStateTable extends React.Component<TableProps, { columns: (ICell | string)[]; rows: IRow[] }> {
constructor(props: TableProps) {
super(props);
this.state = {
columns: [
{ title: 'Repositories' },
'Branches',
{ title: 'Pull requests' },
'Workspaces',
{ title: 'Last Commit' }
],
rows: [
{
heightAuto: true,
props: { colSpan: '8' },
title: (
<EmptyState variant={EmptyStateVariant.small}>
<EmptyStateIcon icon={CubesIcon} />
<Title headingLevel="h5" size="lg">
Empty State
</Title>
<EmptyStateBody>
This represents an the empty state pattern in Patternfly 4. Hopefully it's simple enough to use but
flexible enough to meet a variety of needs.
</EmptyStateBody>
<Button variant="primary">Primary Action</Button>
<EmptyStateSecondaryActions>
<Button variant="link">Multiple</Button>
<Button variant="link">Action Buttons</Button>
<Button variant="link">Can</Button>
<Button variant="link">Go here</Button>
<Button variant="link">In the secondary</Button>
<Button variant="link">Action area</Button>
</EmptyStateSecondaryActions>
</EmptyState>
)
}
]
};
}
render() {
const { columns, rows } = this.state;
return (
<Table caption="Empty State Table" cells={columns} rows={rows}>
<TableHeader />
<TableBody />
</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 @@ -85,6 +85,7 @@ class ContextBody extends React.Component<TableBodyProps, {}> {
...oneRow,
...this.mapCells(headerData, oneRow, oneRowKey),
isExpanded: isRowExpanded(oneRow, rows),
isHeightAuto: oneRow.heightAuto || false,
isFirst: oneRowKey === 0,
isLast: oneRowKey === rows.length - 1,
isFirstVisible: false,
Expand Down
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 @@ -21,4 +21,9 @@ describe('RowWrapper', () => {
const view = mount(getRowWrapper({ row: { isExpanded: true } }));
expect(view).toMatchSnapshot();
});
test('renders height auto modifier correctly', () => {
const view = mount(getRowWrapper({ row: { isHeightAuto: true } }));
console.log(view.debug())
expect(view.find('tr').prop('className')).toBe('pf-m-height-auto');
});
});
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 @@ -7,6 +7,7 @@ import { css } from '@patternfly/react-styles';
export interface RowWrapperRow {
isOpen?: Boolean;
isExpanded?: Boolean;
isHeightAuto?: Boolean;
}

export interface RowWrapperProps {
Expand All @@ -23,7 +24,8 @@ class RowWrapper extends React.Component<RowWrapperProps & InjectedOuiaProps, {}
className: '' as string,
row: {
isOpen: undefined as boolean,
isExpanded: undefined as boolean
isExpanded: undefined as boolean,
isHeightAuto: undefined as boolean
} as RowWrapperRow,
rowProps: null as any
};
Expand Down Expand Up @@ -80,7 +82,7 @@ class RowWrapper extends React.Component<RowWrapperProps & InjectedOuiaProps, {}
className,
onScroll,
onResize,
row: { isExpanded },
row: { isExpanded, isHeightAuto },
rowProps,
ouiaContext,
ouiaId,
Expand All @@ -94,7 +96,8 @@ class RowWrapper extends React.Component<RowWrapperProps & InjectedOuiaProps, {}
className={css(
className,
isExpanded !== undefined && styles.tableExpandableRow,
isExpanded && styles.modifiers.expanded
isExpanded && styles.modifiers.expanded,
isHeightAuto && styles.modifiers.heightAuto
)}
hidden={isExpanded !== undefined && !isExpanded}
{...ouiaContext.isOuia && {
Expand Down
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 @@ -26,10 +26,16 @@ import {
} from '@patternfly/react-table';

import {
Checkbox
Checkbox,
Button,
EmptyState,
EmptyStateBody,
EmptyStatePrimary,
Bullseye,
} from '@patternfly/react-core';

import {
SearchIcon,
CodeBranchIcon,
CodeIcon,
CubeIcon
Expand Down Expand Up @@ -1110,3 +1116,43 @@ class WrappableHeadersTable extends React.Component {
}
}
```

## Empty state table

```js
import React from 'react';
import { Table, TableHeader, TableBody } from '@patternfly/react-table';
import { Button, EmptyState, EmptyStateBody, EmptyStatePrimary, Bullseye } from '@patternfly/react-core';

EmptyStateTable = () => {
const columns = ['Repositories', 'Branches', 'Pull request', 'Workspaces', 'LastCommit']
const rows = [{
heightAuto: true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@priley86 what do you think about introducing row decorators? Similiar to how cell formatters work. This can be potentially problem in future when we'll update API and we will have to keep it intact.

cells: [
{
props: {colspan: '8'},
title: (
<Bullseye>
<EmptyState variant={EmptyStateVariant.small}>
<EmptyStateIcon icon={SearchIcon} />
<Title headingLevel="h2" size="lg">
No results found
</Title>
<EmptyStateBody>
No results match the filter criteria. Remove all filters or clear all filters to show results.
</EmptyStateBody>
<Button variant="link">Clear all filters</Button>
</EmptyState>
</Bullseye>
)
},
]
}]
return (
<Table cells={columns} rows={rows}>
<TableHeader />
<TableBody />
</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 @@ -229,3 +229,28 @@ test('Selectable table with selected expandable row', () => {

expect(view.find('input[name="check-all"]').prop('checked')).toEqual(true);
});

test('Empty state table', () => {
const data = {
cells: ['Hostname', 'IP address', 'Role', 'Team'],
rows: [
{
heightAuto: true,
cells: [{
title: (<div>Empty State Component</div>),
props: {colspan: '8'}
}],
}
],
};

const view = mount(
<Table aria-label="Aria labeled" {...data}>
<TableHeader />
<TableBody />
</Table>
);

expect(view.find('tr').at(1).prop('className')).toEqual('pf-m-height-auto');
expect(view.find('tbody').find('td').prop('colspan')).toEqual('8');
});
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 @@ -175,6 +175,7 @@ export interface IRow extends RowType {
props?: any;
fullWidth?: boolean;
noPadding?: boolean;
heightAuto?: boolean;
showSelect?: boolean;
isExpanded?: boolean;
isFirstVisible?: boolean;
Expand Down
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 @@ -62,6 +62,7 @@ exports[`RowWrapper renders correctly 1`] = `
row={
Object {
"isExpanded": undefined,
"isHeightAuto": undefined,
"isOpen": undefined,
}
}
Expand Down
Loading

Back | FazBrowse Home | New Git URL