From a2fcd2f97a332dd6acbe87ecfb03fa60b978b72d Mon Sep 17 00:00:00 2001 From: Hao Liu Date: Tue, 16 Jan 2024 15:22:01 -0500 Subject: [PATCH] Fix ui-lint error --- awx/ui/src/api/index.js | 2 +- awx/ui/src/api/models/Instances.js | 5 +- .../AddEndpointModal/AddEndpointModal.js | 9 +-- awx/ui/src/screens/Instances/Instance.js | 6 +- .../InstanceEndPointList.js | 60 ++++++++++--------- .../InstanceEndPointListItem.js | 7 +-- .../InstancePeers/InstancePeerList.js | 48 +++++++-------- .../InstancePeers/InstancePeerListItem.js | 1 - 8 files changed, 73 insertions(+), 65 deletions(-) diff --git a/awx/ui/src/api/index.js b/awx/ui/src/api/index.js index 49196e4154..9c78db6e36 100644 --- a/awx/ui/src/api/index.js +++ b/awx/ui/src/api/index.js @@ -80,7 +80,7 @@ const NotificationsAPI = new Notifications(); const OrganizationsAPI = new Organizations(); const ProjectUpdatesAPI = new ProjectUpdates(); const ProjectsAPI = new Projects(); -const ReceptorAPI = new ReceptorAddresses() +const ReceptorAPI = new ReceptorAddresses(); const RolesAPI = new Roles(); const RootAPI = new Root(); const SchedulesAPI = new Schedules(); diff --git a/awx/ui/src/api/models/Instances.js b/awx/ui/src/api/models/Instances.js index 64a7e70c40..7730a31df8 100644 --- a/awx/ui/src/api/models/Instances.js +++ b/awx/ui/src/api/models/Instances.js @@ -33,7 +33,10 @@ class Instances extends Base { } updateReceptorAddresses(instanceId, data) { - return this.http.post(`${this.baseUrl}${instanceId}/receptor_addresses/`, data); + return this.http.post( + `${this.baseUrl}${instanceId}/receptor_addresses/`, + data + ); } deprovisionInstance(instanceId) { diff --git a/awx/ui/src/components/AddEndpointModal/AddEndpointModal.js b/awx/ui/src/components/AddEndpointModal/AddEndpointModal.js index a102b88c92..b88f62fd76 100644 --- a/awx/ui/src/components/AddEndpointModal/AddEndpointModal.js +++ b/awx/ui/src/components/AddEndpointModal/AddEndpointModal.js @@ -5,9 +5,7 @@ import { Form, FormGroup, Modal } from '@patternfly/react-core'; import { InstancesAPI } from 'api'; import { Formik } from 'formik'; import { FormColumnLayout } from 'components/FormLayout'; -import FormField, { - CheckboxField, -} from 'components/FormField'; +import FormField, { CheckboxField } from 'components/FormField'; import FormActionGroup from '../FormActionGroup/FormActionGroup'; function AddEndpointModal({ @@ -17,7 +15,6 @@ function AddEndpointModal({ instance, ouiaId, }) { - const handleClose = () => { onClose(); }; @@ -44,7 +41,7 @@ function AddEndpointModal({ > @@ -94,4 +91,4 @@ function AddEndpointModal({ ); } -export default AddEndpointModal; \ No newline at end of file +export default AddEndpointModal; diff --git a/awx/ui/src/screens/Instances/Instance.js b/awx/ui/src/screens/Instances/Instance.js index 1a0f5fd76d..6de57292c1 100644 --- a/awx/ui/src/screens/Instances/Instance.js +++ b/awx/ui/src/screens/Instances/Instance.js @@ -55,7 +55,11 @@ function Instance({ setBreadcrumb }) { }, [request]); if (isK8s) { - tabsArray.push({ name: t`Endpoints`, link: `${match.url}/endpoints`, id: 1 }); + tabsArray.push({ + name: t`Endpoints`, + link: `${match.url}/endpoints`, + id: 1, + }); tabsArray.push({ name: t`Peers`, link: `${match.url}/peers`, id: 2 }); } if (isLoading) { diff --git a/awx/ui/src/screens/Instances/InstanceEndPointList/InstanceEndPointList.js b/awx/ui/src/screens/Instances/InstanceEndPointList/InstanceEndPointList.js index c90fa1a737..dace4d42fc 100644 --- a/awx/ui/src/screens/Instances/InstanceEndPointList/InstanceEndPointList.js +++ b/awx/ui/src/screens/Instances/InstanceEndPointList/InstanceEndPointList.js @@ -32,7 +32,13 @@ function InstanceEndPointList({ setBreadcrumb }) { isLoading, error: contentError, request: fetchEndpoints, - result: { instance, endpoints, count, relatedSearchableKeys, searchableKeys }, + result: { + instance, + endpoints, + count, + relatedSearchableKeys, + searchableKeys, + }, } = useRequest( useCallback(async () => { const [ @@ -47,15 +53,15 @@ function InstanceEndPointList({ setBreadcrumb }) { InstancesAPI.readOptions(), ]); - const endpoint_list = [] + const endpoint_list = []; - for(let q = 0; q < results.length; q++) { + for (let q = 0; q < results.length; q++) { const receptor = results[q]; - if(receptor.managed === true) continue; - if(id.toString() === receptor.instance.toString()) { + if (receptor.managed === true) continue; + if (id.toString() === receptor.instance.toString()) { receptor.name = detail.hostname; endpoint_list.push(receptor); - console.log(receptor) + console.log(receptor); } } @@ -105,9 +111,7 @@ function InstanceEndPointList({ setBreadcrumb }) { setisAddEndpointModalOpen(true)} - // /> - // ), - // (isExecutionNode || isHopNode) && ( - // handleEndpointDelete()} - // /> - // ), - ]} + additionalControls={ + [ + // (isExecutionNode || isHopNode) && ( + // setisAddEndpointModalOpen(true)} + // /> + // ), + // (isExecutionNode || isHopNode) && ( + // handleEndpointDelete()} + // /> + // ), + ] + } /> )} renderRow={(endpoint, index) => ( diff --git a/awx/ui/src/screens/Instances/InstanceEndPointList/InstanceEndPointListItem.js b/awx/ui/src/screens/Instances/InstanceEndPointList/InstanceEndPointListItem.js index 17d15c275a..920b7aeef9 100644 --- a/awx/ui/src/screens/Instances/InstanceEndPointList/InstanceEndPointListItem.js +++ b/awx/ui/src/screens/Instances/InstanceEndPointList/InstanceEndPointListItem.js @@ -35,17 +35,16 @@ function InstanceEndPointListItem({ /> - {peerEndpoint.address} + {peerEndpoint.address} - {peerEndpoint.port} + {peerEndpoint.port} - {peerEndpoint.canonical.toString()} + {peerEndpoint.canonical.toString()} - ); } diff --git a/awx/ui/src/screens/Instances/InstancePeers/InstancePeerList.js b/awx/ui/src/screens/Instances/InstancePeers/InstancePeerList.js index 0a7acad878..3a7d40d0b1 100644 --- a/awx/ui/src/screens/Instances/InstancePeers/InstancePeerList.js +++ b/awx/ui/src/screens/Instances/InstancePeers/InstancePeerList.js @@ -58,12 +58,14 @@ function InstancePeerList({ setBreadcrumb }) { InstancesAPI.read(), ]); - const address_list = [] + const address_list = []; - for(let q = 0; q < results.length; q++) { + for (let q = 0; q < results.length; q++) { const receptor = results[q]; - if(receptor.managed === true) continue; - const host = instances.data.results.filter((obj) => obj.id === receptor.instance)[0]; + if (receptor.managed === true) continue; + const host = instances.data.results.filter( + (obj) => obj.id === receptor.instance + )[0]; const copy = receptor; copy.hostname = host.hostname; copy.node_type = host.node_type; @@ -106,44 +108,47 @@ function InstancePeerList({ setBreadcrumb }) { const fetchInstancesToAssociate = useCallback( async (params) => { - const address_list = [] + const address_list = []; const instances = await InstancesAPI.read( mergeParams(params, { ...{ not__node_type: ['control', 'hybrid'] }, - })) + }) + ); const receptors = (await ReceptorAPI.read()).data.results; // get instance ids of the current peered receptor ids - const already_peered_instance_ids = [] - for(let h =0; h < instance.peers.length; h++) { + const already_peered_instance_ids = []; + for (let h = 0; h < instance.peers.length; h++) { const matched = receptors.filter((obj) => obj.id === instance.peers[h]); - matched.forEach(element => { + matched.forEach((element) => { already_peered_instance_ids.push(element.instance); }); } - for(let q = 0; q < receptors.length; q++) { + for (let q = 0; q < receptors.length; q++) { const receptor = receptors[q]; - if(already_peered_instance_ids.includes(receptor.instance)) { + if (already_peered_instance_ids.includes(receptor.instance)) { // ignore reverse peers - continue + continue; } - if(instance.peers.includes(receptor.id)) { + if (instance.peers.includes(receptor.id)) { // no links to existing links continue; } - if(instance.id === receptor.instance) { + if (instance.id === receptor.instance) { // no links to thy self continue; } - const host = instances.data.results.filter((obj) => obj.id === receptor.instance)[0]; + const host = instances.data.results.filter( + (obj) => obj.id === receptor.instance + )[0]; - if(host === undefined) { + if (host === undefined) { // no hosts continue; } @@ -151,7 +156,7 @@ function InstancePeerList({ setBreadcrumb }) { const copy = receptor; copy.hostname = host.hostname; copy.node_type = host.node_type; - copy.canonical = copy.canonical.toString() + copy.canonical = copy.canonical.toString(); address_list.push(copy); } @@ -169,14 +174,9 @@ function InstancePeerList({ setBreadcrumb }) { } = useRequest( useCallback( async (instancesPeerToAssociate) => { + const selected_peers = instancesPeerToAssociate.map((obj) => obj.id); - const selected_peers = instancesPeerToAssociate.map( - (obj) => obj.id - ); - - const new_peers = [ - ...new Set([...instance.peers, ...selected_peers]), - ]; + const new_peers = [...new Set([...instance.peers, ...selected_peers])]; await InstancesAPI.update(instance.id, { peers: new_peers }); fetchPeers(); diff --git a/awx/ui/src/screens/Instances/InstancePeers/InstancePeerListItem.js b/awx/ui/src/screens/Instances/InstancePeers/InstancePeerListItem.js index a40109aa6b..e67e9de0bd 100644 --- a/awx/ui/src/screens/Instances/InstancePeers/InstancePeerListItem.js +++ b/awx/ui/src/screens/Instances/InstancePeers/InstancePeerListItem.js @@ -61,7 +61,6 @@ function InstancePeerListItem({ {peerInstance.canonical.toString()} - {!isHopNode && (