mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Merge pull request #7978 from jakemcdermott/fix-7977
Don't display facts until facts are loaded Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
1a033653ae
@ -11,32 +11,31 @@ import useRequest from '../../../util/useRequest';
|
||||
import { HostsAPI } from '../../../api';
|
||||
|
||||
function InventoryHostFacts({ i18n, host }) {
|
||||
const { result: facts, isLoading, error, request: fetchFacts } = useRequest(
|
||||
const { request, isLoading, error, result } = useRequest(
|
||||
useCallback(async () => {
|
||||
const [{ data: factsObj }] = await Promise.all([
|
||||
HostsAPI.readFacts(host.id),
|
||||
]);
|
||||
return JSON.stringify(factsObj, null, 4);
|
||||
const { data } = await HostsAPI.readFacts(host.id);
|
||||
|
||||
return JSON.stringify(data, null, 4);
|
||||
}, [host]),
|
||||
'{}'
|
||||
null
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
fetchFacts();
|
||||
}, [fetchFacts]);
|
||||
|
||||
if (isLoading) {
|
||||
return <ContentLoading />;
|
||||
}
|
||||
request();
|
||||
}, [request]);
|
||||
|
||||
if (error) {
|
||||
return <ContentError error={error} />;
|
||||
}
|
||||
|
||||
if (isLoading || result === null) {
|
||||
return <ContentLoading />;
|
||||
}
|
||||
|
||||
return (
|
||||
<CardBody>
|
||||
<DetailList gutter="sm">
|
||||
<VariablesDetail label={i18n._(t`Facts`)} fullHeight value={facts} />
|
||||
<VariablesDetail label={i18n._(t`Facts`)} fullHeight value={result} />
|
||||
</DetailList>
|
||||
</CardBody>
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user