mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
fix(kube): use https when port is 443 in various tables [EE-6592] (#11444)
Some checks failed
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
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
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
Some checks failed
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
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
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:
parent
5fb5ea7ae0
commit
cea9969463
5 changed files with 87 additions and 32 deletions
|
@ -3,6 +3,7 @@ import { ExternalLink } from 'lucide-react';
|
|||
import { CellContext } from '@tanstack/react-table';
|
||||
|
||||
import type { DockerContainer } from '@/react/docker/containers/types';
|
||||
import { getSchemeFromPort } from '@/react/common/network-utils';
|
||||
|
||||
import { Icon } from '@@/Icon';
|
||||
|
||||
|
@ -31,18 +32,46 @@ function Cell({ row }: CellContext<DockerContainer, string>) {
|
|||
return '-';
|
||||
}
|
||||
|
||||
const { PublicURL: publicUrl } = environment;
|
||||
const publicURL = getPublicUrl(environment.PublicURL);
|
||||
|
||||
return _.uniqBy(ports, 'public').map((port) => (
|
||||
<a
|
||||
key={`${port.host}:${port.public}`}
|
||||
className="image-tag"
|
||||
href={`http://${publicUrl || port.host}:${port.public}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<Icon icon={ExternalLink} />
|
||||
{port.public}:{port.private}
|
||||
</a>
|
||||
));
|
||||
return _.uniqBy(ports, 'public').map((port) => {
|
||||
let url = publicURL || port.host || '';
|
||||
if (!url.startsWith('http')) {
|
||||
const scheme = getSchemeFromPort(port.private);
|
||||
url = `${scheme}://${url}`;
|
||||
}
|
||||
url = `${url}:${port.public}`;
|
||||
|
||||
return (
|
||||
<a
|
||||
key={`${port.host}:${port.public}`}
|
||||
className="image-tag"
|
||||
href={url}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<Icon icon={ExternalLink} />
|
||||
{port.public}:{port.private}
|
||||
</a>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function getPublicUrl(url?: string): string {
|
||||
if (!url) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Add protocol if missing
|
||||
const u =
|
||||
url.startsWith('http://') || url.startsWith('https://')
|
||||
? url
|
||||
: `http://${url}`;
|
||||
|
||||
try {
|
||||
const parsedUrl = new URL(u);
|
||||
return `${parsedUrl.protocol}://${parsedUrl.hostname}`;
|
||||
} catch (error) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import { CellContext } from '@tanstack/react-table';
|
|||
|
||||
import { ServiceViewModel } from '@/docker/models/service';
|
||||
import { useCurrentEnvironment } from '@/react/hooks/useCurrentEnvironment';
|
||||
import { getSchemeFromPort } from '@/react/common/network-utils';
|
||||
|
||||
import { Icon } from '@@/Icon';
|
||||
|
||||
|
@ -40,16 +41,20 @@ function Cell({
|
|||
|
||||
return ports
|
||||
.filter((port) => port.PublishedPort)
|
||||
.map((port) => (
|
||||
<a
|
||||
key={`${publicUrl}:${port.PublishedPort}`}
|
||||
className="image-tag vertical-center"
|
||||
href={`http://${publicUrl}:${port.PublishedPort}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<Icon icon={ExternalLink} />
|
||||
{port.PublishedPort}:{port.TargetPort}
|
||||
</a>
|
||||
));
|
||||
.map((port) => {
|
||||
const scheme = getSchemeFromPort(port.TargetPort);
|
||||
|
||||
return (
|
||||
<a
|
||||
key={`${publicUrl}:${port.PublishedPort}`}
|
||||
className="image-tag vertical-center"
|
||||
href={`${scheme}://${publicUrl}:${port.PublishedPort}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<Icon icon={ExternalLink} />
|
||||
{port.PublishedPort}:{port.TargetPort}
|
||||
</a>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue