mirror of
https://github.com/ansible/awx.git
synced 2026-01-17 20:51:21 -03:30
Normalize event callback function names in search and sort components
This commit is contained in:
parent
3596d776fc
commit
fc80470e5d
@ -39,7 +39,7 @@ describe('<Search />', () => {
|
||||
expect(onSearch).toBeCalledWith('test-321');
|
||||
});
|
||||
|
||||
test('onSearchDropdownToggle properly updates state', async () => {
|
||||
test('handleDropdownToggle properly updates state', async () => {
|
||||
const columns = [{ name: 'Name', key: 'name', isSortable: true }];
|
||||
const onSearch = jest.fn();
|
||||
const wrapper = mount(
|
||||
@ -52,11 +52,11 @@ describe('<Search />', () => {
|
||||
</I18nProvider>
|
||||
).find('Search');
|
||||
expect(wrapper.state('isSearchDropdownOpen')).toEqual(false);
|
||||
wrapper.instance().onSearchDropdownToggle(true);
|
||||
wrapper.instance().handleDropdownToggle(true);
|
||||
expect(wrapper.state('isSearchDropdownOpen')).toEqual(true);
|
||||
});
|
||||
|
||||
test('onSearchDropdownSelect properly updates state', async () => {
|
||||
test('handleDropdownSelect properly updates state', async () => {
|
||||
const columns = [
|
||||
{ name: 'Name', key: 'name', isSortable: true },
|
||||
{ name: 'Description', key: 'description', isSortable: true }
|
||||
@ -72,7 +72,7 @@ describe('<Search />', () => {
|
||||
</I18nProvider>
|
||||
).find('Search');
|
||||
expect(wrapper.state('searchKey')).toEqual('name');
|
||||
wrapper.instance().onSearchDropdownSelect({ target: { innerText: 'Description' } });
|
||||
wrapper.instance().handleDropdownSelect({ target: { innerText: 'Description' } });
|
||||
expect(wrapper.state('searchKey')).toEqual('description');
|
||||
});
|
||||
});
|
||||
|
||||
@ -110,7 +110,7 @@ describe('<Sort />', () => {
|
||||
</I18nProvider>
|
||||
).find('Sort');
|
||||
|
||||
wrapper.instance().onSortDropdownSelect({ target: { innerText: 'Bar' } });
|
||||
wrapper.instance().handleDropdownSelect({ target: { innerText: 'Bar' } });
|
||||
expect(onSort).toBeCalledWith('bar', 'ascending');
|
||||
});
|
||||
|
||||
@ -135,7 +135,7 @@ describe('<Sort />', () => {
|
||||
</I18nProvider>
|
||||
).find('Sort');
|
||||
expect(wrapper.state('isSortDropdownOpen')).toEqual(false);
|
||||
wrapper.instance().onSortDropdownToggle(true);
|
||||
wrapper.instance().handleDropdownToggle(true);
|
||||
expect(wrapper.state('isSortDropdownOpen')).toEqual(true);
|
||||
});
|
||||
|
||||
|
||||
@ -23,16 +23,16 @@ class Search extends React.Component {
|
||||
};
|
||||
|
||||
this.handleSearchInputChange = this.handleSearchInputChange.bind(this);
|
||||
this.onSearchDropdownToggle = this.onSearchDropdownToggle.bind(this);
|
||||
this.onSearchDropdownSelect = this.onSearchDropdownSelect.bind(this);
|
||||
this.onSearch = this.onSearch.bind(this);
|
||||
this.handleDropdownToggle = this.handleDropdownToggle.bind(this);
|
||||
this.handleDropdownSelect = this.handleDropdownSelect.bind(this);
|
||||
this.handleSearch = this.handleSearch.bind(this);
|
||||
}
|
||||
|
||||
onSearchDropdownToggle (isSearchDropdownOpen) {
|
||||
handleDropdownToggle (isSearchDropdownOpen) {
|
||||
this.setState({ isSearchDropdownOpen });
|
||||
}
|
||||
|
||||
onSearchDropdownSelect ({ target }) {
|
||||
handleDropdownSelect ({ target }) {
|
||||
const { columns } = this.props;
|
||||
const { innerText } = target;
|
||||
|
||||
@ -40,7 +40,7 @@ class Search extends React.Component {
|
||||
this.setState({ isSearchDropdownOpen: false, searchKey });
|
||||
}
|
||||
|
||||
onSearch () {
|
||||
handleSearch () {
|
||||
const { searchValue } = this.state;
|
||||
const { onSearch } = this.props;
|
||||
|
||||
@ -78,13 +78,13 @@ class Search extends React.Component {
|
||||
<div className="pf-c-input-group">
|
||||
<Dropdown
|
||||
className="searchKeyDropdown"
|
||||
onToggle={this.onSearchDropdownToggle}
|
||||
onSelect={this.onSearchDropdownSelect}
|
||||
onToggle={this.handleDropdownToggle}
|
||||
onSelect={this.handleDropdownSelect}
|
||||
direction={up}
|
||||
isOpen={isSearchDropdownOpen}
|
||||
toggle={(
|
||||
<DropdownToggle
|
||||
onToggle={this.onSearchDropdownToggle}
|
||||
onToggle={this.handleDropdownToggle}
|
||||
>
|
||||
{searchColumnName}
|
||||
</DropdownToggle>
|
||||
@ -101,7 +101,7 @@ class Search extends React.Component {
|
||||
<Button
|
||||
variant="tertiary"
|
||||
aria-label={i18n._(t`Search`)}
|
||||
onClick={this.onSearch}
|
||||
onClick={this.handleSearch}
|
||||
>
|
||||
<i className="fas fa-search" aria-hidden="true" />
|
||||
</Button>
|
||||
|
||||
@ -24,16 +24,16 @@ class Sort extends React.Component {
|
||||
isSortDropdownOpen: false,
|
||||
};
|
||||
|
||||
this.onSortDropdownToggle = this.onSortDropdownToggle.bind(this);
|
||||
this.onSortDropdownSelect = this.onSortDropdownSelect.bind(this);
|
||||
this.onSort = this.onSort.bind(this);
|
||||
this.handleDropdownToggle = this.handleDropdownToggle.bind(this);
|
||||
this.handleDropdownSelect = this.handleDropdownSelect.bind(this);
|
||||
this.handleSort = this.handleSort.bind(this);
|
||||
}
|
||||
|
||||
onSortDropdownToggle (isSortDropdownOpen) {
|
||||
handleDropdownToggle (isSortDropdownOpen) {
|
||||
this.setState({ isSortDropdownOpen });
|
||||
}
|
||||
|
||||
onSortDropdownSelect ({ target }) {
|
||||
handleDropdownSelect ({ target }) {
|
||||
const { columns, onSort, sortOrder } = this.props;
|
||||
const { innerText } = target;
|
||||
|
||||
@ -43,7 +43,7 @@ class Sort extends React.Component {
|
||||
onSort(searchKey, sortOrder);
|
||||
}
|
||||
|
||||
onSort () {
|
||||
handleSort () {
|
||||
const { onSort, sortedColumnKey, sortOrder } = this.props;
|
||||
const newSortOrder = sortOrder === 'ascending' ? 'descending' : 'ascending';
|
||||
|
||||
@ -86,13 +86,13 @@ class Sort extends React.Component {
|
||||
{ sortDropdownItems.length > 1 && (
|
||||
<Dropdown
|
||||
style={{ marginRight: '20px' }}
|
||||
onToggle={this.onSortDropdownToggle}
|
||||
onSelect={this.onSortDropdownSelect}
|
||||
onToggle={this.handleDropdownToggle}
|
||||
onSelect={this.handleDropdownSelect}
|
||||
direction={up}
|
||||
isOpen={isSortDropdownOpen}
|
||||
toggle={(
|
||||
<DropdownToggle
|
||||
onToggle={this.onSortDropdownToggle}
|
||||
onToggle={this.handleDropdownToggle}
|
||||
>
|
||||
{sortedColumnName}
|
||||
</DropdownToggle>
|
||||
@ -101,7 +101,7 @@ class Sort extends React.Component {
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
onClick={this.onSort}
|
||||
onClick={this.handleSort}
|
||||
variant="plain"
|
||||
aria-label={i18n._(t`Sort`)}
|
||||
>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user