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

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ravicious
Copy link
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
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
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
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
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
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
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