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