mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 00:09:40 +02:00
fix(kube): use https when port is 443 in various tables [EE-6592] (#11443)
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
This commit is contained in:
parent
e3a8853212
commit
86c4b3059e
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 '';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue