From 6eeb32a447d3e4b5209cc02ce141098fb3590d74 Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Wed, 8 Apr 2020 10:59:09 -0400 Subject: [PATCH] excise withRouter from function components --- .../Inventory/shared/InventoryGroupForm.jsx | 3 +-- .../Organization/shared/OrganizationForm.jsx | 3 +-- .../src/screens/Team/TeamEdit/TeamEdit.jsx | 5 ++--- awx/ui_next/src/screens/Template/Template.jsx | 3 +-- .../NodeTypeStep/InventorySourcesList.jsx | 16 ++++++---------- .../NodeTypeStep/JobTemplatesList.jsx | 17 +++++++---------- .../NodeModals/NodeTypeStep/ProjectsList.jsx | 12 +++++++----- .../NodeTypeStep/WorkflowJobTemplatesList.jsx | 11 ++++++----- .../screens/Template/shared/JobTemplateForm.jsx | 3 +-- .../src/screens/User/UserEdit/UserEdit.jsx | 8 +++++--- 10 files changed, 37 insertions(+), 44 deletions(-) diff --git a/awx/ui_next/src/screens/Inventory/shared/InventoryGroupForm.jsx b/awx/ui_next/src/screens/Inventory/shared/InventoryGroupForm.jsx index daea537311..92859b0162 100644 --- a/awx/ui_next/src/screens/Inventory/shared/InventoryGroupForm.jsx +++ b/awx/ui_next/src/screens/Inventory/shared/InventoryGroupForm.jsx @@ -1,5 +1,4 @@ import React from 'react'; -import { withRouter } from 'react-router-dom'; import { withI18n } from '@lingui/react'; import { Formik } from 'formik'; import { Form, Card } from '@patternfly/react-core'; @@ -67,4 +66,4 @@ function InventoryGroupForm({ ); } -export default withI18n()(withRouter(InventoryGroupForm)); +export default withI18n()(InventoryGroupForm); diff --git a/awx/ui_next/src/screens/Organization/shared/OrganizationForm.jsx b/awx/ui_next/src/screens/Organization/shared/OrganizationForm.jsx index 354877d78e..5618846da5 100644 --- a/awx/ui_next/src/screens/Organization/shared/OrganizationForm.jsx +++ b/awx/ui_next/src/screens/Organization/shared/OrganizationForm.jsx @@ -1,6 +1,5 @@ import React, { useContext, useEffect, useState } from 'react'; import PropTypes from 'prop-types'; -import { withRouter } from 'react-router-dom'; import { Formik, useField } from 'formik'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; @@ -206,4 +205,4 @@ OrganizationForm.contextTypes = { }; export { OrganizationForm as _OrganizationForm }; -export default withI18n()(withRouter(OrganizationForm)); +export default withI18n()(OrganizationForm); diff --git a/awx/ui_next/src/screens/Team/TeamEdit/TeamEdit.jsx b/awx/ui_next/src/screens/Team/TeamEdit/TeamEdit.jsx index 19a6ffe03a..b7d05030af 100644 --- a/awx/ui_next/src/screens/Team/TeamEdit/TeamEdit.jsx +++ b/awx/ui_next/src/screens/Team/TeamEdit/TeamEdit.jsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import PropTypes from 'prop-types'; -import { withRouter, useHistory } from 'react-router-dom'; +import { useHistory } from 'react-router-dom'; import { CardBody } from '@components/Card'; import { TeamsAPI } from '@api'; @@ -50,5 +50,4 @@ TeamEdit.contextTypes = { custom_virtualenvs: PropTypes.arrayOf(PropTypes.string), }; -export { TeamEdit as _TeamEdit }; -export default withRouter(TeamEdit); +export default TeamEdit; diff --git a/awx/ui_next/src/screens/Template/Template.jsx b/awx/ui_next/src/screens/Template/Template.jsx index f68427cb89..4588f1283f 100644 --- a/awx/ui_next/src/screens/Template/Template.jsx +++ b/awx/ui_next/src/screens/Template/Template.jsx @@ -6,7 +6,6 @@ import { Switch, Route, Redirect, - withRouter, Link, useLocation, useParams, @@ -224,4 +223,4 @@ function Template({ i18n, me, setBreadcrumb }) { } export { Template as _Template }; -export default withI18n()(withRouter(Template)); +export default withI18n()(Template); diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/InventorySourcesList.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/InventorySourcesList.jsx index b4394f4e1d..69eb17e5e7 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/InventorySourcesList.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Modals/NodeModals/NodeTypeStep/InventorySourcesList.jsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { withRouter } from 'react-router-dom'; +import { useLocation } from 'react-router-dom'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { func, shape } from 'prop-types'; @@ -15,23 +15,19 @@ const QS_CONFIG = getQSConfig('inventory_sources', { order_by: 'name', }); -function InventorySourcesList({ - history, - i18n, - nodeResource, - onUpdateNodeResource, -}) { +function InventorySourcesList({ i18n, nodeResource, onUpdateNodeResource }) { const [count, setCount] = useState(0); const [error, setError] = useState(null); const [inventorySources, setInventorySources] = useState([]); const [isLoading, setIsLoading] = useState(true); + const location = useLocation(); useEffect(() => { (async () => { setIsLoading(true); setInventorySources([]); setCount(0); - const params = parseQueryString(QS_CONFIG, history.location.search); + const params = parseQueryString(QS_CONFIG, location.search); try { const { data } = await InventorySourcesAPI.read(params); setInventorySources(data.results); @@ -42,7 +38,7 @@ function InventorySourcesList({ setIsLoading(false); } })(); - }, [history.location]); + }, [location]); return ( { (async () => { setIsLoading(true); setJobTemplates([]); setCount(0); - const params = parseQueryString(QS_CONFIG, history.location.search); + const params = parseQueryString(QS_CONFIG, location.search); try { const { data } = await JobTemplatesAPI.read(params, { role_level: 'execute_role', @@ -44,7 +41,7 @@ function JobTemplatesList({ setIsLoading(false); } })(); - }, [history.location]); + }, [location]); return ( { (async () => { setIsLoading(true); setProjects([]); setCount(0); - const params = parseQueryString(QS_CONFIG, history.location.search); + const params = parseQueryString(QS_CONFIG, location.search); try { const { data } = await ProjectsAPI.read(params); setProjects(data.results); @@ -37,7 +39,7 @@ function ProjectsList({ history, i18n, nodeResource, onUpdateNodeResource }) { setIsLoading(false); } })(); - }, [history.location]); + }, [location]); return ( { (async () => { setIsLoading(true); setWorkflowJobTemplates([]); setCount(0); - const params = parseQueryString(QS_CONFIG, history.location.search); + const params = parseQueryString(QS_CONFIG, location.search); try { const { data } = await WorkflowJobTemplatesAPI.read(params, { role_level: 'execute_role', @@ -44,7 +45,7 @@ function WorkflowJobTemplatesList({ setIsLoading(false); } })(); - }, [history.location]); + }, [location]); return ( { setFormSubmitError(null); try { @@ -34,4 +36,4 @@ function UserEdit({ user, history }) { ); } -export default withI18n()(withRouter(UserEdit)); +export default withI18n()(UserEdit);