mirror of https://github.com/portainer/portainer
fix(docker/network): send target nodeName when removing a network on swarm (#12001)
parent
85bc14e470
commit
ac4b129195
|
@ -37,7 +37,9 @@ export function withInvalidate(
|
||||||
return {
|
return {
|
||||||
onSuccess() {
|
onSuccess() {
|
||||||
const promise = Promise.all(
|
const promise = Promise.all(
|
||||||
queryKeysToInvalidate.map((keys) => queryClient.invalidateQueries(keys))
|
queryKeysToInvalidate.map((keys) =>
|
||||||
|
queryClient.invalidateQueries(keys, { refetchType: 'none' })
|
||||||
|
)
|
||||||
);
|
);
|
||||||
return skipRefresh
|
return skipRefresh
|
||||||
? undefined // don't wait for queries to refresh before setting state to success
|
? undefined // don't wait for queries to refresh before setting state to success
|
||||||
|
|
|
@ -94,7 +94,7 @@ export function ItemView() {
|
||||||
|
|
||||||
async function onRemoveNetworkClicked() {
|
async function onRemoveNetworkClicked() {
|
||||||
deleteNetworkMutation.mutate(
|
deleteNetworkMutation.mutate(
|
||||||
{ networkId },
|
{ networkId, nodeName },
|
||||||
{
|
{
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
notifySuccess('Network successfully removed', networkId);
|
notifySuccess('Network successfully removed', networkId);
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||||
|
|
||||||
import { buildDockerProxyUrl } from '../../proxy/queries/buildDockerProxyUrl';
|
import { buildDockerProxyUrl } from '../../proxy/queries/buildDockerProxyUrl';
|
||||||
|
import { withAgentTargetHeader } from '../../proxy/queries/utils';
|
||||||
import { NetworkId } from '../types';
|
import { NetworkId } from '../types';
|
||||||
|
|
||||||
import { queryKeys } from './queryKeys';
|
import { queryKeys } from './queryKeys';
|
||||||
|
@ -17,8 +18,8 @@ export function useDeleteNetwork(environmentId: EnvironmentId) {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation(
|
||||||
({ networkId }: { networkId: NetworkId }) =>
|
({ networkId, nodeName }: { networkId: NetworkId; nodeName?: string }) =>
|
||||||
deleteNetwork(environmentId, networkId),
|
deleteNetwork(environmentId, networkId, { nodeName }),
|
||||||
mutationOptions(
|
mutationOptions(
|
||||||
withInvalidate(queryClient, [queryKeys.base(environmentId)]),
|
withInvalidate(queryClient, [queryKeys.base(environmentId)]),
|
||||||
withError('Unable to remove network')
|
withError('Unable to remove network')
|
||||||
|
@ -34,11 +35,15 @@ export function useDeleteNetwork(environmentId: EnvironmentId) {
|
||||||
*/
|
*/
|
||||||
export async function deleteNetwork(
|
export async function deleteNetwork(
|
||||||
environmentId: EnvironmentId,
|
environmentId: EnvironmentId,
|
||||||
networkId: NetworkId
|
networkId: NetworkId,
|
||||||
|
{ nodeName }: { nodeName?: string } = {}
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
await axios.delete(
|
await axios.delete(
|
||||||
buildDockerProxyUrl(environmentId, 'networks', networkId)
|
buildDockerProxyUrl(environmentId, 'networks', networkId),
|
||||||
|
{
|
||||||
|
headers: { ...withAgentTargetHeader(nodeName) },
|
||||||
|
}
|
||||||
);
|
);
|
||||||
return networkId;
|
return networkId;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -238,5 +238,6 @@
|
||||||
"browserslist": "last 2 versions",
|
"browserslist": "last 2 versions",
|
||||||
"msw": {
|
"msw": {
|
||||||
"workerDirectory": ".storybook/public"
|
"workerDirectory": ".storybook/public"
|
||||||
}
|
},
|
||||||
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue