mirror of
https://github.com/ansible/awx.git
synced 2026-05-15 05:17:36 -02:30
Fix bug where changing credential field from plugin to string crashed application
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useCallback, useEffect } from 'react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
import { CaretLeftIcon } from '@patternfly/react-icons';
|
import { CaretLeftIcon } from '@patternfly/react-icons';
|
||||||
@@ -12,37 +12,49 @@ import {
|
|||||||
Redirect,
|
Redirect,
|
||||||
Link,
|
Link,
|
||||||
} from 'react-router-dom';
|
} from 'react-router-dom';
|
||||||
|
import useRequest from '../../util/useRequest';
|
||||||
import { ResourceAccessList } from '../../components/ResourceAccessList';
|
import { ResourceAccessList } from '../../components/ResourceAccessList';
|
||||||
import ContentError from '../../components/ContentError';
|
import ContentError from '../../components/ContentError';
|
||||||
|
import ContentLoading from '../../components/ContentLoading';
|
||||||
import RoutedTabs from '../../components/RoutedTabs';
|
import RoutedTabs from '../../components/RoutedTabs';
|
||||||
import CredentialDetail from './CredentialDetail';
|
import CredentialDetail from './CredentialDetail';
|
||||||
import CredentialEdit from './CredentialEdit';
|
import CredentialEdit from './CredentialEdit';
|
||||||
import { CredentialsAPI } from '../../api';
|
import { CredentialsAPI } from '../../api';
|
||||||
|
|
||||||
function Credential({ setBreadcrumb }) {
|
function Credential({ setBreadcrumb }) {
|
||||||
const [credential, setCredential] = useState(null);
|
|
||||||
const [contentError, setContentError] = useState(null);
|
|
||||||
const [hasContentLoading, setHasContentLoading] = useState(true);
|
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
|
|
||||||
const match = useRouteMatch({
|
const match = useRouteMatch({
|
||||||
path: '/credentials/:id',
|
path: '/credentials/:id',
|
||||||
});
|
});
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
|
|
||||||
useEffect(() => {
|
const {
|
||||||
async function fetchData() {
|
request: fetchCredential,
|
||||||
try {
|
result: { credential },
|
||||||
const { data } = await CredentialsAPI.readDetail(id);
|
isLoading: hasContentLoading,
|
||||||
setBreadcrumb(data);
|
error: contentError,
|
||||||
setCredential(data);
|
} = useRequest(
|
||||||
} catch (error) {
|
useCallback(async () => {
|
||||||
setContentError(error);
|
const { data } = await CredentialsAPI.readDetail(id);
|
||||||
} finally {
|
return {
|
||||||
setHasContentLoading(false);
|
credential: data,
|
||||||
}
|
};
|
||||||
|
}, [id]),
|
||||||
|
{
|
||||||
|
credential: null,
|
||||||
}
|
}
|
||||||
fetchData();
|
);
|
||||||
}, [id, pathname, setBreadcrumb]);
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetchCredential();
|
||||||
|
}, [fetchCredential, pathname]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (credential) {
|
||||||
|
setBreadcrumb(credential);
|
||||||
|
}
|
||||||
|
}, [credential, setBreadcrumb]);
|
||||||
|
|
||||||
const tabsArray = [
|
const tabsArray = [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user