Skip to content

feat: add port sharing frontend #12119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Feb 20, 2024
Prev Previous commit
Next Next commit
add filter
  • Loading branch information
f0ssel committed Feb 13, 2024
commit 37009c77189c07cb0d7235f61f496ea951fec7f5
21 changes: 19 additions & 2 deletions site/src/modules/resources/PortForwardButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,23 @@ export const PortForwardPopoverView: FC<PortForwardPopoverViewProps> = ({
}) => {
const theme = useTheme();

// we don't want to show listening ports if it's already a shared port
const filteredListeningPorts = listeningPorts?.filter(
(port) => {
if (sharedPorts === undefined) {
return true;
}

for (let i = 0; i < sharedPorts.length; i++) {
if (sharedPorts[i].port === port.port && sharedPorts[i].agent_name === agent.name) {
return false;
}
}

return true;
}
);

return (
<>
<div
Expand All @@ -149,7 +166,7 @@ export const PortForwardPopoverView: FC<PortForwardPopoverViewProps> = ({
</HelpTooltipLink>
</Stack>
<HelpTooltipText css={{ color: theme.palette.text.secondary }}>
{listeningPorts?.length === 0
{filteredListeningPorts?.length === 0
? "No open ports were detected."
: "The listening ports are exclusively accessible to you."}
</HelpTooltipText>
Expand Down Expand Up @@ -204,7 +221,7 @@ export const PortForwardPopoverView: FC<PortForwardPopoverViewProps> = ({
paddingTop: 10,
}}
>
{listeningPorts?.map((port) => {
{filteredListeningPorts?.map((port) => {
const url = portForwardURL(
host,
port.port,
Expand Down