Skip to content

Show available target ports in gateways for multi-port apps#51016

Merged
ravicious merged 3 commits intomasterfrom
r7s/show-ports
Jan 16, 2025
Merged

Show available target ports in gateways for multi-port apps#51016
ravicious merged 3 commits intomasterfrom
r7s/show-ports

Conversation

@ravicious
Copy link
Copy Markdown
Member

This PR adds a line under the form with ports with a list of available target ports. The list is fetched before the gateway is created, but only when the tab with the gateway is visible. This is so that if the user reopens a session with many app gateways open, we don't attempt to fetch all apps at once.

It's best to start the review at web/packages/teleterm/src/ui/DocumentGatewayApp/DocumentGatewayApp.tsx and then go deeper.

available-ports

@ravicious ravicious added no-changelog Indicates that a PR does not require a changelog entry backport/branch/v17 labels Jan 14, 2025
@ravicious ravicious requested review from avatus and gzdunek January 14, 2025 10:44
@github-actions github-actions Bot requested a review from flyinghermit January 14, 2025 10:45
@ravicious ravicious removed the request for review from flyinghermit January 14, 2025 10:45
Copy link
Copy Markdown
Contributor

@gzdunek gzdunek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I left a small UX suggestion.

Comment on lines +151 to +152
Available target ports:{' '}
{props.tcpPortsAttempt.data.map(formatPortRange).join(', ')}.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you say for a small UX improvement? We could display the ports as buttons to make it easier to change the target port (plus it would be more obvious what these ports are for):

buttons.mov

Here is the code if you find this worth adding :)

        {props.tcpPortsAttempt.status === 'success' && (
          <Box>
            Available target ports:
            <Flex gap={1} flexWrap="wrap">
              {props.tcpPortsAttempt.data.map(portRange => {
                const formatted = formatPortRange(portRange);
                return (
                  <ButtonSecondary
                    key={formatted}
                    onClick={() => {
                      const port = portRange.port.toString();
                      multiPortFieldRef.current.value = port;
                      changeTargetPort(port);
                    }}
                    size="small"
                  >
                    {formatted}
                  </ButtonSecondary>
                );
              })}
            </Flex>
          </Box>
        )}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great idea, thanks. It didn't even occur to me because I was trying to keep it as simple as possible, since I've already spent too much time on this. ;f

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tweaked it slightly to save space in the "expected" case where there's just a couple of ports.

available-ports

kind="warning"
details={props.tcpPortsAttempt.statusText}
primaryAction={{ content: 'Retry', onClick: props.getTcpPorts }}
>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>
m=0
>

@ravicious ravicious enabled auto-merge January 15, 2025 15:30
@ravicious ravicious added this pull request to the merge queue Jan 16, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 16, 2025
@ravicious ravicious added this pull request to the merge queue Jan 16, 2025
Merged via the queue into master with commit c4d3f18 Jan 16, 2025
@ravicious ravicious deleted the r7s/show-ports branch January 16, 2025 10:20
@public-teleport-github-review-bot
Copy link
Copy Markdown

@ravicious See the table below for backport results.

Branch Result
branch/v17 Failed

mvbrock pushed a commit that referenced this pull request Jan 18, 2025
* Show available target ports

* Use buttons to show available target ports

* Add zero margin to Alert
carloscastrojumo pushed a commit to carloscastrojumo/teleport that referenced this pull request Feb 19, 2025
…ional#51016)

* Show available target ports

* Use buttons to show available target ports

* Add zero margin to Alert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/branch/v17 no-changelog Indicates that a PR does not require a changelog entry size/md ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants