mirror of
https://github.com/ansible/awx.git
synced 2026-02-17 03:00:04 -03:30
retain search bar when zero results found
This commit is contained in:
@@ -46,16 +46,14 @@ class ListHeader extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSearch(key, value) {
|
handleSearch(key, value) {
|
||||||
const { history, qsConfig } = this.props;
|
const { location, qsConfig } = this.props;
|
||||||
const { search } = history.location;
|
const oldParams = parseQueryString(qsConfig, location.search);
|
||||||
const oldParams = parseQueryString(qsConfig, search);
|
|
||||||
this.pushHistoryState(mergeParams(oldParams, { [key]: value }));
|
this.pushHistoryState(mergeParams(oldParams, { [key]: value }));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleRemove(key, value) {
|
handleRemove(key, value) {
|
||||||
const { history, qsConfig } = this.props;
|
const { location, qsConfig } = this.props;
|
||||||
const { search } = history.location;
|
const oldParams = parseQueryString(qsConfig, location.search);
|
||||||
const oldParams = parseQueryString(qsConfig, search);
|
|
||||||
this.pushHistoryState(removeParams(qsConfig, oldParams, { [key]: value }));
|
this.pushHistoryState(removeParams(qsConfig, oldParams, { [key]: value }));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,9 +62,8 @@ class ListHeader extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSort(key, order) {
|
handleSort(key, order) {
|
||||||
const { history, qsConfig } = this.props;
|
const { location, qsConfig } = this.props;
|
||||||
const { search } = history.location;
|
const oldParams = parseQueryString(qsConfig, location.search);
|
||||||
const oldParams = parseQueryString(qsConfig, search);
|
|
||||||
this.pushHistoryState(
|
this.pushHistoryState(
|
||||||
replaceParams(oldParams, {
|
replaceParams(oldParams, {
|
||||||
order_by: order === 'ascending' ? key : `-${key}`,
|
order_by: order === 'ascending' ? key : `-${key}`,
|
||||||
@@ -89,11 +86,14 @@ class ListHeader extends React.Component {
|
|||||||
columns,
|
columns,
|
||||||
renderToolbar,
|
renderToolbar,
|
||||||
qsConfig,
|
qsConfig,
|
||||||
|
location,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const [orderBy, sortOrder] = this.getSortOrder();
|
const [orderBy, sortOrder] = this.getSortOrder();
|
||||||
|
const params = parseQueryString(qsConfig, location.search);
|
||||||
|
const isEmpty = itemCount === 0 && Object.keys(params).length === 0;
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
{itemCount === 0 ? (
|
{isEmpty ? (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<EmptyStateControlsWrapper>
|
<EmptyStateControlsWrapper>
|
||||||
{emptyStateControls}
|
{emptyStateControls}
|
||||||
|
|||||||
@@ -99,29 +99,17 @@ class PaginatedDataList extends React.Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.length <= 0) {
|
|
||||||
return (
|
|
||||||
<Fragment>
|
|
||||||
<ListHeader
|
|
||||||
emptyStateControls={emptyStateControls}
|
|
||||||
itemCount={itemCount}
|
|
||||||
columns={columns}
|
|
||||||
qsConfig={qsConfig}
|
|
||||||
/>
|
|
||||||
{Content}
|
|
||||||
</Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<ListHeader
|
<ListHeader
|
||||||
itemCount={itemCount}
|
itemCount={itemCount}
|
||||||
renderToolbar={renderToolbar}
|
renderToolbar={renderToolbar}
|
||||||
|
emptyStateControls={emptyStateControls}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
qsConfig={qsConfig}
|
qsConfig={qsConfig}
|
||||||
/>
|
/>
|
||||||
{Content}
|
{Content}
|
||||||
|
{items.length ? (
|
||||||
<Pagination
|
<Pagination
|
||||||
variant="bottom"
|
variant="bottom"
|
||||||
itemCount={itemCount}
|
itemCount={itemCount}
|
||||||
@@ -140,6 +128,7 @@ class PaginatedDataList extends React.Component {
|
|||||||
onSetPage={this.handleSetPage}
|
onSetPage={this.handleSetPage}
|
||||||
onPerPageSelect={this.handleSetPageSize}
|
onPerPageSelect={this.handleSetPageSize}
|
||||||
/>
|
/>
|
||||||
|
) : null}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,8 @@ class JobList extends Component {
|
|||||||
selected,
|
selected,
|
||||||
} = this.state;
|
} = this.state;
|
||||||
const { match, i18n } = this.props;
|
const { match, i18n } = this.props;
|
||||||
const isAllSelected = selected.length === jobs.length;
|
const isAllSelected =
|
||||||
|
selected.length === jobs.length && selected.length > 0;
|
||||||
return (
|
return (
|
||||||
<PageSection>
|
<PageSection>
|
||||||
<Card>
|
<Card>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -142,7 +142,8 @@ class OrganizationsList extends Component {
|
|||||||
|
|
||||||
const canAdd =
|
const canAdd =
|
||||||
actions && Object.prototype.hasOwnProperty.call(actions, 'POST');
|
actions && Object.prototype.hasOwnProperty.call(actions, 'POST');
|
||||||
const isAllSelected = selected.length === organizations.length;
|
const isAllSelected =
|
||||||
|
selected.length === organizations.length && selected.length > 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
|||||||
@@ -184,7 +184,8 @@ class TemplatesList extends Component {
|
|||||||
const { match, i18n } = this.props;
|
const { match, i18n } = this.props;
|
||||||
const canAdd =
|
const canAdd =
|
||||||
actions && Object.prototype.hasOwnProperty.call(actions, 'POST');
|
actions && Object.prototype.hasOwnProperty.call(actions, 'POST');
|
||||||
const isAllSelected = selected.length === templates.length;
|
const isAllSelected =
|
||||||
|
selected.length === templates.length && selected.length > 0;
|
||||||
return (
|
return (
|
||||||
<PageSection>
|
<PageSection>
|
||||||
<Card>
|
<Card>
|
||||||
|
|||||||
Reference in New Issue
Block a user