mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 08:19:40 +02:00
refactor(edge): move edge codebase to react (#7781)
This commit is contained in:
parent
75f40fe485
commit
1e4c4e2616
54 changed files with 254 additions and 187 deletions
33
app/react/edge/edge-devices/WaitingRoomView/queries.ts
Normal file
33
app/react/edge/edge-devices/WaitingRoomView/queries.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
import { useMutation, useQueryClient } from 'react-query';
|
||||
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { promiseSequence } from '@/portainer/helpers/promise-utils';
|
||||
|
||||
export function useAssociateDeviceMutation() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation(
|
||||
(ids: EnvironmentId[]) =>
|
||||
promiseSequence(ids.map((id) => () => associateDevice(id))),
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(['environments']);
|
||||
},
|
||||
meta: {
|
||||
error: {
|
||||
title: 'Failure',
|
||||
message: 'Failed to associate devices',
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async function associateDevice(environmentId: EnvironmentId) {
|
||||
try {
|
||||
await axios.post(`/endpoints/${environmentId}/edge/trust`);
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error, 'Failed to associate device');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue