mirror of
https://github.com/portainer/portainer.git
synced 2025-08-07 14:55:27 +02:00
Some checks failed
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
ci / build_images (map[arch:arm platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:s390x platform:linux version:]) (push) Has been cancelled
/ triage (push) Has been cancelled
Lint / Run linters (push) Has been cancelled
Test / test-client (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:linux]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
Test / test-server (map[arch:arm64 platform:linux]) (push) Has been cancelled
ci / build_manifests (push) Has been cancelled
30 lines
940 B
TypeScript
30 lines
940 B
TypeScript
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
|
|
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
|
import { EnvironmentId } from '@/react/portainer/environments/types';
|
|
import { withInvalidate } from '@/react-tools/react-query';
|
|
|
|
import { EdgeJob } from '../../types';
|
|
|
|
import { buildUrl } from './build-url';
|
|
import { queryKeys } from './query-keys';
|
|
|
|
export function useCollectLogsMutation(id: EdgeJob['Id']) {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (environmentId: EnvironmentId) =>
|
|
collectLogsMutation(id, environmentId),
|
|
...withInvalidate(queryClient, [queryKeys.base(id)]),
|
|
});
|
|
}
|
|
|
|
async function collectLogsMutation(
|
|
id: EdgeJob['Id'],
|
|
environmentId: EnvironmentId
|
|
) {
|
|
try {
|
|
await axios.post(buildUrl({ id, action: 'logs', taskId: environmentId }));
|
|
} catch (err) {
|
|
throw parseAxiosError(err, 'Unable to collect logs');
|
|
}
|
|
}
|