mirror of
https://github.com/ansible/awx.git
synced 2026-05-12 11:57:37 -02:30
remove withRouter where not needed
This commit is contained in:
@@ -3,7 +3,7 @@ import React, { Fragment, useState } from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { withRouter } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
ButtonVariant,
|
ButtonVariant,
|
||||||
@@ -36,7 +36,6 @@ function Search({
|
|||||||
onReplaceSearch,
|
onReplaceSearch,
|
||||||
onRemove,
|
onRemove,
|
||||||
qsConfig,
|
qsConfig,
|
||||||
location,
|
|
||||||
searchableKeys,
|
searchableKeys,
|
||||||
relatedSearchableKeys,
|
relatedSearchableKeys,
|
||||||
onShowAdvancedSearch,
|
onShowAdvancedSearch,
|
||||||
@@ -45,6 +44,7 @@ function Search({
|
|||||||
enableNegativeFiltering,
|
enableNegativeFiltering,
|
||||||
enableRelatedFuzzyFiltering,
|
enableRelatedFuzzyFiltering,
|
||||||
}) {
|
}) {
|
||||||
|
const location = useLocation();
|
||||||
const [isSearchDropdownOpen, setIsSearchDropdownOpen] = useState(false);
|
const [isSearchDropdownOpen, setIsSearchDropdownOpen] = useState(false);
|
||||||
const [searchKey, setSearchKey] = useState(
|
const [searchKey, setSearchKey] = useState(
|
||||||
(() => {
|
(() => {
|
||||||
@@ -341,4 +341,4 @@ Search.defaultProps = {
|
|||||||
enableRelatedFuzzyFiltering: true,
|
enableRelatedFuzzyFiltering: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default withRouter(Search);
|
export default Search;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { Fragment, useState } from 'react';
|
import React, { Fragment, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import { useLocation, withRouter } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -147,7 +147,4 @@ Sort.defaultProps = {
|
|||||||
onSort: null,
|
onSort: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
export { Sort as _Sort };
|
export default Sort;
|
||||||
const Wrapped = withRouter(Sort);
|
|
||||||
Wrapped.displayName = 'Sort';
|
|
||||||
export default Wrapped;
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
waitForElement,
|
waitForElement,
|
||||||
} from '../../../testUtils/enzymeHelpers';
|
} from '../../../testUtils/enzymeHelpers';
|
||||||
|
|
||||||
import Sort, { _Sort as SortUnwrapped } from './Sort';
|
import Sort from './Sort';
|
||||||
|
|
||||||
jest.mock('react-router-dom', () => ({
|
jest.mock('react-router-dom', () => ({
|
||||||
...jest.requireActual('react-router-dom'),
|
...jest.requireActual('react-router-dom'),
|
||||||
@@ -167,7 +167,7 @@ describe('<Sort />', () => {
|
|||||||
const numericColumns = [{ name: 'ID', key: 'id' }];
|
const numericColumns = [{ name: 'ID', key: 'id' }];
|
||||||
|
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<SortUnwrapped
|
<Sort
|
||||||
qsConfig={qsConfigNumDown}
|
qsConfig={qsConfigNumDown}
|
||||||
columns={numericColumns}
|
columns={numericColumns}
|
||||||
onSort={jest.fn()}
|
onSort={jest.fn()}
|
||||||
@@ -186,7 +186,7 @@ describe('<Sort />', () => {
|
|||||||
const numericColumns = [{ name: 'ID', key: 'id' }];
|
const numericColumns = [{ name: 'ID', key: 'id' }];
|
||||||
|
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<SortUnwrapped
|
<Sort
|
||||||
qsConfig={qsConfigNumUp}
|
qsConfig={qsConfigNumUp}
|
||||||
columns={numericColumns}
|
columns={numericColumns}
|
||||||
onSort={jest.fn()}
|
onSort={jest.fn()}
|
||||||
@@ -205,7 +205,7 @@ describe('<Sort />', () => {
|
|||||||
const alphaColumns = [{ name: 'Name', key: 'name' }];
|
const alphaColumns = [{ name: 'Name', key: 'name' }];
|
||||||
|
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<SortUnwrapped
|
<Sort
|
||||||
qsConfig={qsConfigAlphaDown}
|
qsConfig={qsConfigAlphaDown}
|
||||||
columns={alphaColumns}
|
columns={alphaColumns}
|
||||||
onSort={jest.fn()}
|
onSort={jest.fn()}
|
||||||
@@ -224,7 +224,7 @@ describe('<Sort />', () => {
|
|||||||
const alphaColumns = [{ name: 'Name', key: 'name' }];
|
const alphaColumns = [{ name: 'Name', key: 'name' }];
|
||||||
|
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<SortUnwrapped
|
<Sort
|
||||||
qsConfig={qsConfigAlphaDown}
|
qsConfig={qsConfigAlphaDown}
|
||||||
columns={alphaColumns}
|
columns={alphaColumns}
|
||||||
onSort={jest.fn()}
|
onSort={jest.fn()}
|
||||||
|
|||||||
@@ -202,13 +202,6 @@ describe('<UserAndTeamAccessAdd/>', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
jest.mock('react-router-dom', () => ({
|
|
||||||
...jest.requireActual('react-router-dom'),
|
|
||||||
useParams: () => ({
|
|
||||||
id: 'a',
|
|
||||||
}),
|
|
||||||
}));
|
|
||||||
|
|
||||||
await act(async () =>
|
await act(async () =>
|
||||||
wrapper.find('SelectableCard[label="Job templates"]').prop('onClick')({
|
wrapper.find('SelectableCard[label="Job templates"]').prop('onClick')({
|
||||||
fetchItems: JobTemplatesAPI.read,
|
fetchItems: JobTemplatesAPI.read,
|
||||||
|
|||||||
Reference in New Issue
Block a user