fix(docker/network): send target nodeName when removing a network on swarm (#12001)

pull/12021/head
LP B 5 months ago committed by GitHub
parent 85bc14e470
commit ac4b129195
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -37,7 +37,9 @@ export function withInvalidate(
return {
onSuccess() {
const promise = Promise.all(
queryKeysToInvalidate.map((keys) => queryClient.invalidateQueries(keys))
queryKeysToInvalidate.map((keys) =>
queryClient.invalidateQueries(keys, { refetchType: 'none' })
)
);
return skipRefresh
? undefined // don't wait for queries to refresh before setting state to success

@ -94,7 +94,7 @@ export function ItemView() {
async function onRemoveNetworkClicked() {
deleteNetworkMutation.mutate(
{ networkId },
{ networkId, nodeName },
{
onSuccess: () => {
notifySuccess('Network successfully removed', networkId);

@ -9,6 +9,7 @@ import { EnvironmentId } from '@/react/portainer/environments/types';
import axios, { parseAxiosError } from '@/portainer/services/axios';
import { buildDockerProxyUrl } from '../../proxy/queries/buildDockerProxyUrl';
import { withAgentTargetHeader } from '../../proxy/queries/utils';
import { NetworkId } from '../types';
import { queryKeys } from './queryKeys';
@ -17,8 +18,8 @@ export function useDeleteNetwork(environmentId: EnvironmentId) {
const queryClient = useQueryClient();
return useMutation(
({ networkId }: { networkId: NetworkId }) =>
deleteNetwork(environmentId, networkId),
({ networkId, nodeName }: { networkId: NetworkId; nodeName?: string }) =>
deleteNetwork(environmentId, networkId, { nodeName }),
mutationOptions(
withInvalidate(queryClient, [queryKeys.base(environmentId)]),
withError('Unable to remove network')
@ -34,11 +35,15 @@ export function useDeleteNetwork(environmentId: EnvironmentId) {
*/
export async function deleteNetwork(
environmentId: EnvironmentId,
networkId: NetworkId
networkId: NetworkId,
{ nodeName }: { nodeName?: string } = {}
) {
try {
await axios.delete(
buildDockerProxyUrl(environmentId, 'networks', networkId)
buildDockerProxyUrl(environmentId, 'networks', networkId),
{
headers: { ...withAgentTargetHeader(nodeName) },
}
);
return networkId;
} catch (err) {

@ -238,5 +238,6 @@
"browserslist": "last 2 versions",
"msw": {
"workerDirectory": ".storybook/public"
}
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}

Loading…
Cancel
Save