mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
refactor(edge/stacks): migrate envs table to react [EE-5613] (#9093)
This commit is contained in:
parent
dfc1a7b1d7
commit
11571fd6ea
24 changed files with 652 additions and 281 deletions
|
@ -0,0 +1,40 @@
|
|||
import { useMutation, useQueryClient } from 'react-query';
|
||||
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { withError } from '@/react-tools/react-query';
|
||||
|
||||
import { EdgeStack } from '../../types';
|
||||
|
||||
import { logsStatusQueryKey } from './useLogsStatus';
|
||||
|
||||
export function useDeleteLogsMutation() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation(deleteLogs, {
|
||||
onSuccess(data, variables) {
|
||||
return queryClient.invalidateQueries(
|
||||
logsStatusQueryKey(variables.edgeStackId, variables.environmentId)
|
||||
);
|
||||
},
|
||||
...withError('Unable to delete logs'),
|
||||
});
|
||||
}
|
||||
|
||||
interface DeleteLogs {
|
||||
edgeStackId: EdgeStack['Id'];
|
||||
environmentId: EnvironmentId;
|
||||
}
|
||||
|
||||
async function deleteLogs({ edgeStackId, environmentId }: DeleteLogs) {
|
||||
try {
|
||||
await axios.delete(`/edge_stacks/${edgeStackId}/logs/${environmentId}`, {
|
||||
responseType: 'blob',
|
||||
headers: {
|
||||
Accept: 'text/yaml',
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error, '');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue