1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-28 17:59:45 +02:00

fix(docker/container): use nodeName to build links to networks used by containers (#12004)
Some checks failed
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
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
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

This commit is contained in:
LP B 2024-07-17 14:40:10 +02:00 committed by GitHub
parent 20de243299
commit e2830019d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 133 additions and 172 deletions

View file

@ -10,51 +10,54 @@ import { LoadingButton } from '@@/buttons';
import { TableNetwork, isContainerNetworkTableMeta } from './types';
import { columnHelper } from './helper';
export const actions = columnHelper.display({
header: 'Actions',
cell: Cell,
});
export function buildActions({ nodeName }: { nodeName?: string } = {}) {
return columnHelper.display({
header: 'Actions',
cell: Cell,
});
function Cell({
row,
table: {
options: { meta },
},
}: CellContext<TableNetwork, unknown>) {
const router = useRouter();
const environmentId = useEnvironmentId();
const disconnectMutation = useDisconnectContainer();
function Cell({
row,
table: {
options: { meta },
},
}: CellContext<TableNetwork, unknown>) {
const router = useRouter();
const environmentId = useEnvironmentId();
const disconnectMutation = useDisconnectContainer();
return (
<Authorized authorizations="DockerNetworkDisconnect">
<LoadingButton
color="dangerlight"
isLoading={disconnectMutation.isLoading}
loadingText="Leaving network..."
type="button"
onClick={handleSubmit}
>
Leave network
</LoadingButton>
</Authorized>
);
function handleSubmit() {
if (!isContainerNetworkTableMeta(meta)) {
throw new Error('Invalid row meta');
}
disconnectMutation.mutate(
{
environmentId,
networkId: row.original.id,
containerId: meta.containerId,
},
{
onSuccess() {
router.stateService.reload();
},
}
return (
<Authorized authorizations="DockerNetworkDisconnect">
<LoadingButton
color="dangerlight"
isLoading={disconnectMutation.isLoading}
loadingText="Leaving network..."
type="button"
onClick={handleSubmit}
>
Leave network
</LoadingButton>
</Authorized>
);
function handleSubmit() {
if (!isContainerNetworkTableMeta(meta)) {
throw new Error('Invalid row meta');
}
disconnectMutation.mutate(
{
environmentId,
networkId: row.original.id,
containerId: meta.containerId,
nodeName,
},
{
onSuccess() {
router.stateService.reload();
},
}
);
}
}
}