1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-20 13:59:40 +02:00

refactor(cluster): migrate nodes datatable to react [EE-4962] (#10459)

Co-authored-by: testa113 <testa113>
This commit is contained in:
Ali 2023-10-16 21:19:08 +01:00 committed by GitHub
parent b346fd7f39
commit 0e47f22c0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 448 additions and 219 deletions

View file

@ -0,0 +1,29 @@
import { EndpointsList } from 'kubernetes-types/core/v1';
import { useQuery } from 'react-query';
import axios from '@/portainer/services/axios';
import { EnvironmentId } from '@/react/portainer/environments/types';
import { withError } from '@/react-tools/react-query';
async function getKubernetesEndpoints(environmentId: EnvironmentId) {
const { data: endpointsList } = await axios.get<EndpointsList>(
`/endpoints/${environmentId}/kubernetes/api/v1/endpoints`
);
return endpointsList.items;
}
export function useKubernetesEndpointsQuery(
environmentId: EnvironmentId,
options?: { autoRefreshRate?: number }
) {
return useQuery(
['environments', environmentId, 'kubernetes', 'endpoints'],
() => getKubernetesEndpoints(environmentId),
{
...withError('Unable to retrieve Kubernetes endpoints'),
refetchInterval() {
return options?.autoRefreshRate ?? false;
},
}
);
}