mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
Replace loadHost with an IIFE
This commit is contained in:
@@ -39,30 +39,29 @@ function Host({ inventory, i18n, setBreadcrumb }) {
|
|||||||
? '/hosts'
|
? '/hosts'
|
||||||
: `/inventories/inventory/${inventoriesMatch.params.id}/hosts`;
|
: `/inventories/inventory/${inventoriesMatch.params.id}/hosts`;
|
||||||
|
|
||||||
const loadHost = async () => {
|
|
||||||
setContentError(null);
|
|
||||||
setHasContentLoading(true);
|
|
||||||
try {
|
|
||||||
const hostId = hostsMatch
|
|
||||||
? hostsMatch.params.id
|
|
||||||
: inventoriesMatch.params.hostId;
|
|
||||||
const { data } = await HostsAPI.readDetail(hostId);
|
|
||||||
setHost(data);
|
|
||||||
|
|
||||||
if (hostsMatch) {
|
|
||||||
setBreadcrumb(data);
|
|
||||||
} else if (inventoriesMatch) {
|
|
||||||
setBreadcrumb(inventory, data);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
setContentError(error);
|
|
||||||
} finally {
|
|
||||||
setHasContentLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadHost();
|
(async () => {
|
||||||
|
setContentError(null);
|
||||||
|
setHasContentLoading(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const hostId = hostsMatch
|
||||||
|
? hostsMatch.params.id
|
||||||
|
: inventoriesMatch.params.hostId;
|
||||||
|
const { data } = await HostsAPI.readDetail(hostId);
|
||||||
|
setHost(data);
|
||||||
|
|
||||||
|
if (hostsMatch) {
|
||||||
|
setBreadcrumb(data);
|
||||||
|
} else if (inventoriesMatch) {
|
||||||
|
setBreadcrumb(inventory, data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
setContentError(error);
|
||||||
|
} finally {
|
||||||
|
setHasContentLoading(false);
|
||||||
|
}
|
||||||
|
})();
|
||||||
}, [location]); // eslint-disable-line react-hooks/exhaustive-deps
|
}, [location]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
|
||||||
const tabsArray = [
|
const tabsArray = [
|
||||||
|
|||||||
Reference in New Issue
Block a user