mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Fix ui-lint error
This commit is contained in:
parent
c394ffdd19
commit
a2fcd2f97a
@ -80,7 +80,7 @@ const NotificationsAPI = new Notifications();
|
|||||||
const OrganizationsAPI = new Organizations();
|
const OrganizationsAPI = new Organizations();
|
||||||
const ProjectUpdatesAPI = new ProjectUpdates();
|
const ProjectUpdatesAPI = new ProjectUpdates();
|
||||||
const ProjectsAPI = new Projects();
|
const ProjectsAPI = new Projects();
|
||||||
const ReceptorAPI = new ReceptorAddresses()
|
const ReceptorAPI = new ReceptorAddresses();
|
||||||
const RolesAPI = new Roles();
|
const RolesAPI = new Roles();
|
||||||
const RootAPI = new Root();
|
const RootAPI = new Root();
|
||||||
const SchedulesAPI = new Schedules();
|
const SchedulesAPI = new Schedules();
|
||||||
|
|||||||
@ -33,7 +33,10 @@ class Instances extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateReceptorAddresses(instanceId, data) {
|
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) {
|
deprovisionInstance(instanceId) {
|
||||||
|
|||||||
@ -5,9 +5,7 @@ import { Form, FormGroup, Modal } from '@patternfly/react-core';
|
|||||||
import { InstancesAPI } from 'api';
|
import { InstancesAPI } from 'api';
|
||||||
import { Formik } from 'formik';
|
import { Formik } from 'formik';
|
||||||
import { FormColumnLayout } from 'components/FormLayout';
|
import { FormColumnLayout } from 'components/FormLayout';
|
||||||
import FormField, {
|
import FormField, { CheckboxField } from 'components/FormField';
|
||||||
CheckboxField,
|
|
||||||
} from 'components/FormField';
|
|
||||||
import FormActionGroup from '../FormActionGroup/FormActionGroup';
|
import FormActionGroup from '../FormActionGroup/FormActionGroup';
|
||||||
|
|
||||||
function AddEndpointModal({
|
function AddEndpointModal({
|
||||||
@ -17,7 +15,6 @@ function AddEndpointModal({
|
|||||||
instance,
|
instance,
|
||||||
ouiaId,
|
ouiaId,
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
@ -44,7 +41,7 @@ function AddEndpointModal({
|
|||||||
>
|
>
|
||||||
<Formik
|
<Formik
|
||||||
initialValues={{
|
initialValues={{
|
||||||
listener_port: 1001
|
listener_port: 1001,
|
||||||
}}
|
}}
|
||||||
onSubmit={handleEndpointAdd}
|
onSubmit={handleEndpointAdd}
|
||||||
>
|
>
|
||||||
@ -94,4 +91,4 @@ function AddEndpointModal({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AddEndpointModal;
|
export default AddEndpointModal;
|
||||||
|
|||||||
@ -55,7 +55,11 @@ function Instance({ setBreadcrumb }) {
|
|||||||
}, [request]);
|
}, [request]);
|
||||||
|
|
||||||
if (isK8s) {
|
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 });
|
tabsArray.push({ name: t`Peers`, link: `${match.url}/peers`, id: 2 });
|
||||||
}
|
}
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
|
|||||||
@ -32,7 +32,13 @@ function InstanceEndPointList({ setBreadcrumb }) {
|
|||||||
isLoading,
|
isLoading,
|
||||||
error: contentError,
|
error: contentError,
|
||||||
request: fetchEndpoints,
|
request: fetchEndpoints,
|
||||||
result: { instance, endpoints, count, relatedSearchableKeys, searchableKeys },
|
result: {
|
||||||
|
instance,
|
||||||
|
endpoints,
|
||||||
|
count,
|
||||||
|
relatedSearchableKeys,
|
||||||
|
searchableKeys,
|
||||||
|
},
|
||||||
} = useRequest(
|
} = useRequest(
|
||||||
useCallback(async () => {
|
useCallback(async () => {
|
||||||
const [
|
const [
|
||||||
@ -47,15 +53,15 @@ function InstanceEndPointList({ setBreadcrumb }) {
|
|||||||
InstancesAPI.readOptions(),
|
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];
|
const receptor = results[q];
|
||||||
if(receptor.managed === true) continue;
|
if (receptor.managed === true) continue;
|
||||||
if(id.toString() === receptor.instance.toString()) {
|
if (id.toString() === receptor.instance.toString()) {
|
||||||
receptor.name = detail.hostname;
|
receptor.name = detail.hostname;
|
||||||
endpoint_list.push(receptor);
|
endpoint_list.push(receptor);
|
||||||
console.log(receptor)
|
console.log(receptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,9 +111,7 @@ function InstanceEndPointList({ setBreadcrumb }) {
|
|||||||
<CardBody>
|
<CardBody>
|
||||||
<PaginatedTable
|
<PaginatedTable
|
||||||
contentError={contentError}
|
contentError={contentError}
|
||||||
hasContentLoading={
|
hasContentLoading={isLoading}
|
||||||
isLoading
|
|
||||||
}
|
|
||||||
items={endpoints}
|
items={endpoints}
|
||||||
itemCount={count}
|
itemCount={count}
|
||||||
pluralizedItemName={t`Endpoints`}
|
pluralizedItemName={t`Endpoints`}
|
||||||
@ -144,24 +148,26 @@ function InstanceEndPointList({ setBreadcrumb }) {
|
|||||||
isAllExpanded={isAllExpanded}
|
isAllExpanded={isAllExpanded}
|
||||||
onExpandAll={expandAll}
|
onExpandAll={expandAll}
|
||||||
qsConfig={QS_CONFIG}
|
qsConfig={QS_CONFIG}
|
||||||
additionalControls={[
|
additionalControls={
|
||||||
// (isExecutionNode || isHopNode) && (
|
[
|
||||||
// <ToolbarAddButton
|
// (isExecutionNode || isHopNode) && (
|
||||||
// ouiaId="add-endpoint-button"
|
// <ToolbarAddButton
|
||||||
// key="add-endpoint"
|
// ouiaId="add-endpoint-button"
|
||||||
// defaultLabel={t`Add`}
|
// key="add-endpoint"
|
||||||
// onClick={() => setisAddEndpointModalOpen(true)}
|
// defaultLabel={t`Add`}
|
||||||
// />
|
// onClick={() => setisAddEndpointModalOpen(true)}
|
||||||
// ),
|
// />
|
||||||
// (isExecutionNode || isHopNode) && (
|
// ),
|
||||||
// <ToolbarAddButton
|
// (isExecutionNode || isHopNode) && (
|
||||||
// ouiaId="delete-endpoint-button"
|
// <ToolbarAddButton
|
||||||
// key="delete-endpoint"
|
// ouiaId="delete-endpoint-button"
|
||||||
// defaultLabel={t`Delete`}
|
// key="delete-endpoint"
|
||||||
// onClick={() => handleEndpointDelete()}
|
// defaultLabel={t`Delete`}
|
||||||
// />
|
// onClick={() => handleEndpointDelete()}
|
||||||
// ),
|
// />
|
||||||
]}
|
// ),
|
||||||
|
]
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
renderRow={(endpoint, index) => (
|
renderRow={(endpoint, index) => (
|
||||||
|
|||||||
@ -35,17 +35,16 @@ function InstanceEndPointListItem({
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<Td id={labelId} dataLabel={t`Address`}>
|
<Td id={labelId} dataLabel={t`Address`}>
|
||||||
{peerEndpoint.address}
|
{peerEndpoint.address}
|
||||||
</Td>
|
</Td>
|
||||||
|
|
||||||
<Td id={labelId} dataLabel={t`Port`}>
|
<Td id={labelId} dataLabel={t`Port`}>
|
||||||
{peerEndpoint.port}
|
{peerEndpoint.port}
|
||||||
</Td>
|
</Td>
|
||||||
|
|
||||||
<Td id={labelId} dataLabel={t`Canonical`}>
|
<Td id={labelId} dataLabel={t`Canonical`}>
|
||||||
{peerEndpoint.canonical.toString()}
|
{peerEndpoint.canonical.toString()}
|
||||||
</Td>
|
</Td>
|
||||||
|
|
||||||
</Tr>
|
</Tr>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,12 +58,14 @@ function InstancePeerList({ setBreadcrumb }) {
|
|||||||
InstancesAPI.read(),
|
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];
|
const receptor = results[q];
|
||||||
if(receptor.managed === true) continue;
|
if (receptor.managed === true) 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];
|
||||||
const copy = receptor;
|
const copy = receptor;
|
||||||
copy.hostname = host.hostname;
|
copy.hostname = host.hostname;
|
||||||
copy.node_type = host.node_type;
|
copy.node_type = host.node_type;
|
||||||
@ -106,44 +108,47 @@ function InstancePeerList({ setBreadcrumb }) {
|
|||||||
|
|
||||||
const fetchInstancesToAssociate = useCallback(
|
const fetchInstancesToAssociate = useCallback(
|
||||||
async (params) => {
|
async (params) => {
|
||||||
const address_list = []
|
const address_list = [];
|
||||||
|
|
||||||
const instances = await InstancesAPI.read(
|
const instances = await InstancesAPI.read(
|
||||||
mergeParams(params, {
|
mergeParams(params, {
|
||||||
...{ not__node_type: ['control', 'hybrid'] },
|
...{ not__node_type: ['control', 'hybrid'] },
|
||||||
}))
|
})
|
||||||
|
);
|
||||||
const receptors = (await ReceptorAPI.read()).data.results;
|
const receptors = (await ReceptorAPI.read()).data.results;
|
||||||
|
|
||||||
// get instance ids of the current peered receptor ids
|
// get instance ids of the current peered receptor ids
|
||||||
const already_peered_instance_ids = []
|
const already_peered_instance_ids = [];
|
||||||
for(let h =0; h < instance.peers.length; h++) {
|
for (let h = 0; h < instance.peers.length; h++) {
|
||||||
const matched = receptors.filter((obj) => obj.id === instance.peers[h]);
|
const matched = receptors.filter((obj) => obj.id === instance.peers[h]);
|
||||||
matched.forEach(element => {
|
matched.forEach((element) => {
|
||||||
already_peered_instance_ids.push(element.instance);
|
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];
|
const receptor = receptors[q];
|
||||||
|
|
||||||
if(already_peered_instance_ids.includes(receptor.instance)) {
|
if (already_peered_instance_ids.includes(receptor.instance)) {
|
||||||
// ignore reverse peers
|
// ignore reverse peers
|
||||||
continue
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(instance.peers.includes(receptor.id)) {
|
if (instance.peers.includes(receptor.id)) {
|
||||||
// no links to existing links
|
// no links to existing links
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(instance.id === receptor.instance) {
|
if (instance.id === receptor.instance) {
|
||||||
// no links to thy self
|
// no links to thy self
|
||||||
continue;
|
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
|
// no hosts
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -151,7 +156,7 @@ function InstancePeerList({ setBreadcrumb }) {
|
|||||||
const copy = receptor;
|
const copy = receptor;
|
||||||
copy.hostname = host.hostname;
|
copy.hostname = host.hostname;
|
||||||
copy.node_type = host.node_type;
|
copy.node_type = host.node_type;
|
||||||
copy.canonical = copy.canonical.toString()
|
copy.canonical = copy.canonical.toString();
|
||||||
address_list.push(copy);
|
address_list.push(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,14 +174,9 @@ function InstancePeerList({ setBreadcrumb }) {
|
|||||||
} = useRequest(
|
} = useRequest(
|
||||||
useCallback(
|
useCallback(
|
||||||
async (instancesPeerToAssociate) => {
|
async (instancesPeerToAssociate) => {
|
||||||
|
const selected_peers = instancesPeerToAssociate.map((obj) => obj.id);
|
||||||
|
|
||||||
const selected_peers = instancesPeerToAssociate.map(
|
const new_peers = [...new Set([...instance.peers, ...selected_peers])];
|
||||||
(obj) => obj.id
|
|
||||||
);
|
|
||||||
|
|
||||||
const new_peers = [
|
|
||||||
...new Set([...instance.peers, ...selected_peers]),
|
|
||||||
];
|
|
||||||
await InstancesAPI.update(instance.id, { peers: new_peers });
|
await InstancesAPI.update(instance.id, { peers: new_peers });
|
||||||
|
|
||||||
fetchPeers();
|
fetchPeers();
|
||||||
|
|||||||
@ -61,7 +61,6 @@ function InstancePeerListItem({
|
|||||||
<Td id={labelId} dataLabel={t`Canonical`}>
|
<Td id={labelId} dataLabel={t`Canonical`}>
|
||||||
{peerInstance.canonical.toString()}
|
{peerInstance.canonical.toString()}
|
||||||
</Td>
|
</Td>
|
||||||
|
|
||||||
</Tr>
|
</Tr>
|
||||||
{!isHopNode && (
|
{!isHopNode && (
|
||||||
<Tr
|
<Tr
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user