Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion awx/ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions awx/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"react-dom": "17.0.2",
"react-error-boundary": "^3.1.4",
"react-router-dom": "^5.3.3",
"react-router-dom-v5-compat": "^6.30.4",
"react-virtualized": "^9.22.6",
"rrule": "2.8.1",
"styled-components": "5.3.11"
Expand Down
5 changes: 4 additions & 1 deletion awx/ui/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Redirect,
useHistory,
} from 'react-router-dom';
import { CompatRouter } from 'react-router-dom-v5-compat';
import { ErrorBoundary } from 'react-error-boundary';
import locationReplace from 'util/navigation';
import { I18nProvider } from '@lingui/react';
Expand Down Expand Up @@ -215,6 +216,8 @@ function App() {

export default () => (
<HashRouter>
<App />
<CompatRouter>
<App />
</CompatRouter>
</HashRouter>
);
9 changes: 1 addition & 8 deletions awx/ui/src/screens/Inventory/ConstructedInventory.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import React, { useCallback, useEffect } from 'react';
import { useLingui } from '@lingui/react/macro';
import {
Link,
Switch,
Route,
Redirect,
useRouteMatch,
useLocation,
} from 'react-router-dom';
import { Link, Switch, Route, Redirect, useRouteMatch, useLocation } from 'react-router-dom';
import { CaretLeftIcon } from '@patternfly/react-icons';
import { Card, PageSection } from '@patternfly/react-core';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useState } from 'react';
import { useHistory } from 'react-router-dom';
import { useNavigate } from 'react-router-dom-v5-compat';
import { Card, PageSection } from '@patternfly/react-core';
import { ConstructedInventoriesAPI, InventoriesAPI } from 'api';
import useRequest from 'hooks/useRequest';
Expand All @@ -9,7 +9,7 @@ import ContentLoading from 'components/ContentLoading';
import ConstructedInventoryForm from '../shared/ConstructedInventoryForm';

function ConstructedInventoryAdd() {
const history = useHistory();
const navigate = useNavigate();
const [submitError, setSubmitError] = useState(null);

const {
Expand Down Expand Up @@ -39,7 +39,7 @@ function ConstructedInventoryAdd() {
}

const handleCancel = () => {
history.push('/inventories');
navigate('/inventories');
};

const handleSubmit = async (values) => {
Expand All @@ -63,7 +63,7 @@ function ConstructedInventoryAdd() {
}
/* eslint-enable no-await-in-loop, no-restricted-syntax */

history.push(`/inventories/constructed_inventory/${inventoryId}/details`);
navigate(`/inventories/constructed_inventory/${inventoryId}/details`);
} catch (error) {
setSubmitError(error);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useCallback, useEffect } from 'react';
import { Link, useHistory } from 'react-router-dom';
import { Link } from 'react-router-dom';
import { useNavigate } from 'react-router-dom-v5-compat';
import { useLingui } from '@lingui/react/macro';

import {
Expand Down Expand Up @@ -71,7 +72,7 @@ function JobStatusLabel({ job }) {

function ConstructedInventoryDetail({ inventory }) {
const { t } = useLingui();
const history = useHistory();
const navigate = useNavigate();
const helpText = getHelpText(t);

const {
Expand Down Expand Up @@ -126,8 +127,8 @@ function ConstructedInventoryDetail({ inventory }) {
const { request: deleteInventory, error: deleteError } = useRequest(
useCallback(async () => {
await InventoriesAPI.destroy(inventory.id);
history.push(`/inventories`);
}, [inventory.id, history])
navigate(`/inventories`);
}, [inventory.id, navigate])
);

const { error, dismissError } = useDismissableError(deleteError);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Router } from 'react-router-dom';
import { Router as RouterV6 } from 'react-router-dom-v5-compat';
import { InventoriesAPI, ConstructedInventoriesAPI } from 'api';
import {
render,
Expand Down Expand Up @@ -80,7 +81,9 @@ describe('<ConstructedInventoryDetail />', () => {
const Component = (props) => (
<I18nProvider i18n={i18n}>
<Router history={history}>
<RouterV6 location={history.location} navigator={history}>
<ConstructedInventoryDetail inventory={mockInventory} {...props} />
</RouterV6>
</Router>
</I18nProvider>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useCallback, useEffect } from 'react';
import { useHistory } from 'react-router-dom';
import { useNavigate } from 'react-router-dom-v5-compat';
import { ConstructedInventoriesAPI, InventoriesAPI } from 'api';
import useRequest from 'hooks/useRequest';
import { CardBody } from 'components/Card';
Expand All @@ -15,7 +15,7 @@ function isEqual(array1, array2) {
}

function ConstructedInventoryEdit({ inventory }) {
const history = useHistory();
const navigate = useNavigate();
const [submitError, setSubmitError] = useState(null);
const detailsUrl = `/inventories/constructed_inventory/${inventory.id}/details`;
const constructedInventoryId = inventory.id;
Expand Down Expand Up @@ -111,15 +111,15 @@ function ConstructedInventoryEdit({ inventory }) {
}
/* eslint-enable no-await-in-loop, no-restricted-syntax */

history.push(
navigate(
`/inventories/constructed_inventory/${constructedInventoryId}/details`
);
} catch (error) {
setSubmitError(error);
}
};

const handleCancel = () => history.push(detailsUrl);
const handleCancel = () => navigate(detailsUrl);

if (contentError || optionsError) {
return <ContentError error={contentError || optionsError} />;
Expand Down
9 changes: 1 addition & 8 deletions awx/ui/src/screens/Inventory/FederatedInventory.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import React, { useCallback, useEffect } from 'react';
import { useLingui } from '@lingui/react/macro';
import {
Link,
Switch,
Route,
Redirect,
useRouteMatch,
useLocation,
} from 'react-router-dom';
import { Link, Switch, Route, Redirect, useRouteMatch, useLocation } from 'react-router-dom';
import { CaretLeftIcon } from '@patternfly/react-icons';
import { Card, PageSection } from '@patternfly/react-core';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React, { useState } from 'react';
import { useHistory } from 'react-router-dom';
import { useNavigate } from 'react-router-dom-v5-compat';
import { Card, PageSection } from '@patternfly/react-core';
import { FederatedInventoriesAPI, InventoriesAPI } from 'api';
import { CardBody } from 'components/Card';
import FederatedInventoryForm from '../shared/FederatedInventoryForm';

function FederatedInventoryAdd() {
const history = useHistory();
const navigate = useNavigate();
const [submitError, setSubmitError] = useState(null);

const handleCancel = () => {
history.push('/inventories');
navigate('/inventories');
};

const handleSubmit = async (values) => {
Expand All @@ -29,7 +29,7 @@ function FederatedInventoryAdd() {
}
/* eslint-enable no-await-in-loop, no-restricted-syntax */

history.push(`/inventories/federated_inventory/${inventoryId}/details`);
navigate(`/inventories/federated_inventory/${inventoryId}/details`);
} catch (error) {
setSubmitError(error);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useCallback, useEffect } from 'react';
import { Link, useHistory } from 'react-router-dom';
import { Link } from 'react-router-dom';
import { useNavigate } from 'react-router-dom-v5-compat';
import { useLingui } from '@lingui/react/macro';

import {
Expand All @@ -23,7 +24,7 @@ import ErrorDetail from 'components/ErrorDetail';

function FederatedInventoryDetail({ inventory }) {
const { t } = useLingui();
const history = useHistory();
const navigate = useNavigate();

const {
result: { inputInventories, actions },
Expand Down Expand Up @@ -56,8 +57,8 @@ function FederatedInventoryDetail({ inventory }) {
const { request: deleteInventory, error: deleteError } = useRequest(
useCallback(async () => {
await InventoriesAPI.destroy(inventory.id);
history.push(`/inventories`);
}, [inventory.id, history])
navigate(`/inventories`);
}, [inventory.id, navigate])
);

const { error, dismissError } = useDismissableError(deleteError);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useState } from 'react';
import { useHistory } from 'react-router-dom';
import { useNavigate } from 'react-router-dom-v5-compat';
import { Card, PageSection } from '@patternfly/react-core';
import { Inventory } from 'types';
import { FederatedInventoriesAPI, InventoriesAPI } from 'api';
Expand All @@ -10,7 +10,7 @@ import useRequest from 'hooks/useRequest';
import FederatedInventoryForm from '../shared/FederatedInventoryForm';

function FederatedInventoryEdit({ inventory }) {
const history = useHistory();
const navigate = useNavigate();
const [submitError, setSubmitError] = useState(null);

const {
Expand Down Expand Up @@ -38,7 +38,7 @@ function FederatedInventoryEdit({ inventory }) {
}, [fetchRelatedDetails]);

const handleCancel = () => {
history.push(
navigate(
`/inventories/federated_inventory/${inventory.id}/details`
);
};
Expand Down Expand Up @@ -73,7 +73,7 @@ function FederatedInventoryEdit({ inventory }) {
}
/* eslint-enable no-await-in-loop, no-restricted-syntax */

history.push(
navigate(
`/inventories/federated_inventory/${inventory.id}/details`
);
} catch (error) {
Expand Down
9 changes: 1 addition & 8 deletions awx/ui/src/screens/Inventory/Inventory.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import React, { useEffect, useState } from 'react';
import { useLingui } from '@lingui/react/macro';

import {
Switch,
Route,
Redirect,
Link,
useLocation,
useRouteMatch,
} from 'react-router-dom';
import { Switch, Route, Redirect, Link, useLocation, useRouteMatch } from 'react-router-dom';
import { CaretLeftIcon } from '@patternfly/react-icons';
import { Card, PageSection } from '@patternfly/react-core';
import ContentError from 'components/ContentError';
Expand Down
11 changes: 6 additions & 5 deletions awx/ui/src/screens/Inventory/InventoryAdd/InventoryAdd.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { useHistory } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom-v5-compat';
import { PageSection, Card } from '@patternfly/react-core';
import { CardBody } from 'components/Card';

Expand All @@ -8,10 +8,11 @@ import InventoryForm from '../shared/InventoryForm';

function InventoryAdd() {
const [error, setError] = useState(null);
const history = useHistory();
const location = useLocation();
const navigate = useNavigate();

const handleCancel = () => {
history.push('/inventories');
navigate('/inventories');
};

async function submitLabels(inventoryId, orgId, labels = []) {
Expand Down Expand Up @@ -39,13 +40,13 @@ function InventoryAdd() {
await InventoriesAPI.associateInstanceGroup(inventoryId, group.id);
}
/* eslint-enable no-await-in-loop, no-restricted-syntax */
const url = history.location.pathname.startsWith(
const url = location.pathname.startsWith(
'/inventories/smart_inventory'
)
? `/inventories/smart_inventory/${inventoryId}/details`
: `/inventories/inventory/${inventoryId}/details`;

history.push(`${url}`);
navigate(`${url}`);
} catch (err) {
setError(err);
}
Expand Down
Loading