mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
refactor(namespace): migrate namespace edit to react [r8s-125] (#38)
This commit is contained in:
parent
40c7742e46
commit
ce7e0d8d60
108 changed files with 3183 additions and 2194 deletions
|
@ -3,7 +3,7 @@ import { useQuery } from '@tanstack/react-query';
|
|||
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
import axios from '@/portainer/services/axios';
|
||||
import { withError } from '@/react-tools/react-query';
|
||||
import { withGlobalError } from '@/react-tools/react-query';
|
||||
|
||||
import { parseKubernetesAxiosError } from '../axiosError';
|
||||
|
||||
|
@ -71,7 +71,7 @@ export function useEvents(
|
|||
queryKeys.base(environmentId, { params, namespace }),
|
||||
() => getEvents(environmentId, { params, namespace }),
|
||||
{
|
||||
...withError('Unable to retrieve events'),
|
||||
...withGlobalError('Unable to retrieve events'),
|
||||
refetchInterval() {
|
||||
return queryOptions?.autoRefreshRate ?? false;
|
||||
},
|
||||
|
@ -79,6 +79,17 @@ export function useEvents(
|
|||
);
|
||||
}
|
||||
|
||||
export function useEventWarningsCount(
|
||||
environmentId: EnvironmentId,
|
||||
namespace?: string
|
||||
) {
|
||||
const resourceEventsQuery = useEvents(environmentId, {
|
||||
namespace,
|
||||
});
|
||||
const events = resourceEventsQuery.data || [];
|
||||
return events.filter((e) => e.type === 'Warning').length;
|
||||
}
|
||||
|
||||
function buildUrl(environmentId: EnvironmentId, namespace?: string) {
|
||||
return namespace
|
||||
? `/endpoints/${environmentId}/kubernetes/api/v1/namespaces/${namespace}/events`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue