mirror of
https://github.com/ansible/awx.git
synced 2026-03-13 23:17:32 -02:30
@@ -37,7 +37,7 @@ class DataListToolbar extends React.Component {
|
||||
additionalControls,
|
||||
i18n,
|
||||
qsConfig,
|
||||
pagination
|
||||
pagination,
|
||||
} = this.props;
|
||||
|
||||
const showExpandCollapse = onCompact && onExpand;
|
||||
@@ -92,11 +92,9 @@ class DataListToolbar extends React.Component {
|
||||
<ToolbarItem key={control.key}>{control}</ToolbarItem>
|
||||
))}
|
||||
</ToolbarGroup>
|
||||
{(pagination && itemCount > 0) &&
|
||||
<ToolbarItem variant="pagination">
|
||||
{pagination}
|
||||
</ToolbarItem>
|
||||
}
|
||||
{pagination && itemCount > 0 && (
|
||||
<ToolbarItem variant="pagination">{pagination}</ToolbarItem>
|
||||
)}
|
||||
</ToolbarContent>
|
||||
</Toolbar>
|
||||
);
|
||||
|
||||
@@ -285,21 +285,4 @@ describe('<DataListToolbar />', () => {
|
||||
const checkbox = toolbar.find('Checkbox');
|
||||
expect(checkbox.prop('isChecked')).toBe(true);
|
||||
});
|
||||
|
||||
test('it shows item count', () => {
|
||||
const searchColumns = [{ name: 'Name', key: 'name', isDefault: true }];
|
||||
const sortColumns = [{ name: 'Name', key: 'name' }];
|
||||
const itemCount = 5;
|
||||
|
||||
toolbar = mountWithContexts(
|
||||
<DataListToolbar
|
||||
qsConfig={QS_CONFIG}
|
||||
searchColumns={searchColumns}
|
||||
sortColumns={sortColumns}
|
||||
itemCount={itemCount}
|
||||
/>
|
||||
);
|
||||
const count = toolbar.find('#item-count');
|
||||
expect(count.at(0).text()).toEqual('5 results');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -98,7 +98,7 @@ class ListHeader extends React.Component {
|
||||
renderToolbar,
|
||||
qsConfig,
|
||||
location,
|
||||
pagination
|
||||
pagination,
|
||||
} = this.props;
|
||||
const params = parseQueryString(qsConfig, location.search);
|
||||
const isEmpty = itemCount === 0 && Object.keys(params).length === 0;
|
||||
@@ -128,7 +128,7 @@ class ListHeader extends React.Component {
|
||||
onRemove: this.handleRemove,
|
||||
clearAllFilters: this.handleRemoveAll,
|
||||
qsConfig,
|
||||
pagination
|
||||
pagination,
|
||||
})}
|
||||
</Fragment>
|
||||
)}
|
||||
@@ -143,11 +143,10 @@ ListHeader.propTypes = {
|
||||
searchColumns: SearchColumns.isRequired,
|
||||
sortColumns: SortColumns.isRequired,
|
||||
renderToolbar: PropTypes.func,
|
||||
pagination: PropTypes.element
|
||||
};
|
||||
|
||||
ListHeader.defaultProps = {
|
||||
renderToolbar: props => <DataListToolbar {...props} />
|
||||
renderToolbar: props => <DataListToolbar {...props} />,
|
||||
};
|
||||
|
||||
export default withRouter(ListHeader);
|
||||
|
||||
@@ -121,7 +121,7 @@ class PaginatedDataList extends React.Component {
|
||||
);
|
||||
}
|
||||
|
||||
let ToolbarPagination = (
|
||||
const ToolbarPagination = (
|
||||
<Pagination
|
||||
isCompact
|
||||
dropDirection="down"
|
||||
@@ -141,7 +141,7 @@ class PaginatedDataList extends React.Component {
|
||||
onSetPage={this.handleSetPage}
|
||||
onPerPageSelect={this.handleSetPageSize}
|
||||
/>
|
||||
)
|
||||
);
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
@@ -153,8 +153,7 @@ class PaginatedDataList extends React.Component {
|
||||
sortColumns={sortColumns}
|
||||
qsConfig={qsConfig}
|
||||
pagination={ToolbarPagination}
|
||||
>
|
||||
</ListHeader>
|
||||
/>
|
||||
{Content}
|
||||
{items.length ? (
|
||||
<Pagination
|
||||
|
||||
@@ -55,7 +55,7 @@ describe('<PaginatedDataList />', () => {
|
||||
{ context: { router: { history } } }
|
||||
);
|
||||
|
||||
const pagination = wrapper.find('Pagination');
|
||||
const pagination = wrapper.find('Pagination').at(1);
|
||||
pagination.prop('onSetPage')(null, 2);
|
||||
expect(history.location.search).toEqual('?item.page=2');
|
||||
wrapper.update();
|
||||
@@ -82,7 +82,7 @@ describe('<PaginatedDataList />', () => {
|
||||
{ context: { router: { history } } }
|
||||
);
|
||||
|
||||
const pagination = wrapper.find('Pagination');
|
||||
const pagination = wrapper.find('Pagination').at(1);
|
||||
pagination.prop('onPerPageSelect')(null, 25, 2);
|
||||
expect(history.location.search).toEqual('?item.page=2&item.page_size=25');
|
||||
wrapper.update();
|
||||
|
||||
Reference in New Issue
Block a user