mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 15:36:04 -03:30
Don't display facts until facts are loaded
This commit is contained in:
@@ -11,32 +11,31 @@ import useRequest from '../../../util/useRequest';
|
|||||||
import { HostsAPI } from '../../../api';
|
import { HostsAPI } from '../../../api';
|
||||||
|
|
||||||
function InventoryHostFacts({ i18n, host }) {
|
function InventoryHostFacts({ i18n, host }) {
|
||||||
const { result: facts, isLoading, error, request: fetchFacts } = useRequest(
|
const { request, isLoading, error, result } = useRequest(
|
||||||
useCallback(async () => {
|
useCallback(async () => {
|
||||||
const [{ data: factsObj }] = await Promise.all([
|
const { data } = await HostsAPI.readFacts(host.id);
|
||||||
HostsAPI.readFacts(host.id),
|
|
||||||
]);
|
return JSON.stringify(data, null, 4);
|
||||||
return JSON.stringify(factsObj, null, 4);
|
|
||||||
}, [host]),
|
}, [host]),
|
||||||
'{}'
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchFacts();
|
request();
|
||||||
}, [fetchFacts]);
|
}, [request]);
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <ContentLoading />;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return <ContentError error={error} />;
|
return <ContentError error={error} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isLoading || result === null) {
|
||||||
|
return <ContentLoading />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CardBody>
|
<CardBody>
|
||||||
<DetailList gutter="sm">
|
<DetailList gutter="sm">
|
||||||
<VariablesDetail label={i18n._(t`Facts`)} fullHeight value={facts} />
|
<VariablesDetail label={i18n._(t`Facts`)} fullHeight value={result} />
|
||||||
</DetailList>
|
</DetailList>
|
||||||
</CardBody>
|
</CardBody>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user