diff --git a/awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx b/awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx index 331fcacafc..b8c0cb2ad9 100644 --- a/awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx +++ b/awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx @@ -7,7 +7,7 @@ import { } from '@patternfly/react-core'; import styled from 'styled-components'; import { SearchIcon } from '@patternfly/react-icons'; -import { DataToolbarGroup, DataToolbarToggleGroup, DataToolbarItem } from '@patternfly/react-core/dist/esm/experimental'; +import { DataToolbar, DataToolbarContent, DataToolbarGroup, DataToolbarToggleGroup, DataToolbarItem } from '@patternfly/react-core/dist/umd/experimental'; import ExpandCollapse from '../ExpandCollapse'; import Search from '../Search'; import Sort from '../Sort'; @@ -40,6 +40,7 @@ const DataToolbarSeparator = styled(DataToolbarItem)` class DataListToolbar extends React.Component { render() { const { + clearAllFilters, searchColumns, sortColumns, showSelectAll, @@ -59,64 +60,70 @@ class DataListToolbar extends React.Component { const showExpandCollapse = onCompact && onExpand; return ( - - {showSelectAll && ( - - - - - - - )} - } breakpoint="xl"> - - - - - - - - - {showExpandCollapse && ( - + + + {showSelectAll && ( + - - + + )} - - - - - {additionalControls} - - - - + } breakpoint="xl"> + + + + + + + + + {showExpandCollapse && ( + + + + + + )} + + + + + {additionalControls} + + + + + ); } } DataListToolbar.propTypes = { + clearAllFilters: PropTypes.func, qsConfig: QSConfig.isRequired, searchColumns: SearchColumns.isRequired, sortColumns: SortColumns.isRequired, @@ -133,6 +140,7 @@ DataListToolbar.propTypes = { }; DataListToolbar.defaultProps = { + clearAllFilters: null, showSelectAll: false, isAllSelected: false, isCompact: false, diff --git a/awx/ui_next/src/components/DataListToolbar/DataListToolbar.test.jsx b/awx/ui_next/src/components/DataListToolbar/DataListToolbar.test.jsx index 8e5b705244..402ee08d0b 100644 --- a/awx/ui_next/src/components/DataListToolbar/DataListToolbar.test.jsx +++ b/awx/ui_next/src/components/DataListToolbar/DataListToolbar.test.jsx @@ -20,10 +20,11 @@ describe('', () => { }); const onSearch = jest.fn(); + const onReplaceSearch = jest.fn(); const onSort = jest.fn(); const onSelectAll = jest.fn(); - test('it triggers the expected callbacks', () => { + test('it triggers the expected callbacks', () => { const searchColumns = [ { name: 'Name', key: 'name', isDefault: true } ]; @@ -43,6 +44,7 @@ describe('', () => { searchColumns={searchColumns} sortColumns={sortColumns} onSearch={onSearch} + onReplaceSearch={onReplaceSearch} onSort={onSort} onSelectAll={onSelectAll} showSelectAll @@ -259,6 +261,7 @@ describe('', () => { searchColumns={searchColumns} sortColumns={sortColumns} onSearch={onSearch} + onReplaceSearch={onReplaceSearch} onSort={onSort} onSelectAll={onSelectAll} additionalControls={[ @@ -289,6 +292,7 @@ describe('', () => { searchColumns={searchColumns} sortColumns={sortColumns} onSearch={onSearch} + onReplaceSearch={onReplaceSearch} onSort={onSort} onSelectAll={onSelectAll} showSelectAll diff --git a/awx/ui_next/src/components/ListHeader/ListHeader.jsx b/awx/ui_next/src/components/ListHeader/ListHeader.jsx index 54ca0ddca5..6adc6ccfd5 100644 --- a/awx/ui_next/src/components/ListHeader/ListHeader.jsx +++ b/awx/ui_next/src/components/ListHeader/ListHeader.jsx @@ -2,7 +2,7 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { withRouter } from 'react-router-dom'; import styled from 'styled-components'; -import { DataToolbar, DataToolbarContent } from '@patternfly/react-core/dist/esm/experimental'; +import { DataToolbar, DataToolbarContent } from '@patternfly/react-core/dist/umd/experimental'; import DataListToolbar from '@components/DataListToolbar'; import { @@ -105,22 +105,18 @@ class ListHeader extends React.Component { ) : ( - - - {renderToolbar({ - searchColumns, - sortColumns, - onSearch: this.handleSearch, - onReplaceSearch: this.handleReplaceSearch, - onSort: this.handleSort, - onRemove: this.handleRemove, - qsConfig, - })} - - + + {renderToolbar({ + searchColumns, + sortColumns, + onSearch: this.handleSearch, + onReplaceSearch: this.handleReplaceSearch, + onSort: this.handleSort, + onRemove: this.handleRemove, + clearAllFilters: this.handleRemoveAll, + qsConfig, + })} + )} ); diff --git a/awx/ui_next/src/components/Search/Search.jsx b/awx/ui_next/src/components/Search/Search.jsx index a2a5a6a906..6afa4f64ec 100644 --- a/awx/ui_next/src/components/Search/Search.jsx +++ b/awx/ui_next/src/components/Search/Search.jsx @@ -20,7 +20,7 @@ import { DataToolbarGroup, DataToolbarItem, DataToolbarFilter -} from '@patternfly/react-core/dist/esm/experimental'; +} from '@patternfly/react-core/dist/umd/experimental'; import { SearchIcon } from '@patternfly/react-icons'; import { parseQueryString } from '@util/qs'; import { QSConfig, SearchColumns } from '@types'; @@ -135,7 +135,7 @@ class Search extends React.Component { )); const filterDefaultParams = (paramsArr, config) => { - const defaultParamsKeys = Object.keys(config.defaultParams); + const defaultParamsKeys = Object.keys(config.defaultParams || {}); return paramsArr.filter(key => defaultParamsKeys.indexOf(key) === -1); }; @@ -147,7 +147,7 @@ class Search extends React.Component { queryParamsByKey[key] = {key, label: name, chips: []}; }); const nonDefaultParams = filterDefaultParams( - Object.keys(queryParams), + Object.keys(queryParams || {}), qsConfig ); diff --git a/awx/ui_next/src/components/Search/Search.test.jsx b/awx/ui_next/src/components/Search/Search.test.jsx index cddce90761..c69cf76bd8 100644 --- a/awx/ui_next/src/components/Search/Search.test.jsx +++ b/awx/ui_next/src/components/Search/Search.test.jsx @@ -1,4 +1,5 @@ import React from 'react'; +import { DataToolbar, DataToolbarContent } from '@patternfly/react-core/dist/umd/experimental'; import { mountWithContexts } from '../../../testUtils/enzymeHelpers'; import Search from './Search'; @@ -8,7 +9,7 @@ describe('', () => { const QS_CONFIG = { namespace: 'organization', dateFields: ['modified', 'created'], - defaulkntParams: { page: 1, page_size: 5, order_by: 'name' }, + defaultParams: { page: 1, page_size: 5, order_by: 'name' }, integerFields: ['page', 'page_size'], }; @@ -29,11 +30,18 @@ describe('', () => { const onSearch = jest.fn(); search = mountWithContexts( - + {}} + collapseListedFiltersBreakpoint="md" + > + + + + ); search.find(searchTextInput).instance().value = 'test-321'; @@ -50,11 +58,18 @@ describe('', () => { ]; const onSearch = jest.fn(); const wrapper = mountWithContexts( - + {}} + collapseListedFiltersBreakpoint="md" + > + + + + ).find('Search'); expect(wrapper.state('isSearchDropdownOpen')).toEqual(false); wrapper.instance().handleDropdownToggle(true); @@ -68,11 +83,18 @@ describe('', () => { ]; const onSearch = jest.fn(); const wrapper = mountWithContexts( - + {}} + collapseListedFiltersBreakpoint="md" + > + + + + ).find('Search'); expect(wrapper.state('searchKey')).toEqual('name'); wrapper diff --git a/awx/ui_next/src/components/Sort/Sort.jsx b/awx/ui_next/src/components/Sort/Sort.jsx index 9c6c67d49a..78b2eb5e1d 100644 --- a/awx/ui_next/src/components/Sort/Sort.jsx +++ b/awx/ui_next/src/components/Sort/Sort.jsx @@ -150,7 +150,7 @@ class Sort extends React.Component { )}