Skip to content
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