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

feat: add listening ports protocol selector #12915

Merged
merged 6 commits into from
Apr 15, 2024
Merged

Conversation

f0ssel
Copy link
Contributor

@f0ssel f0ssel commented Apr 9, 2024

Relies on #12908 to be merged first.
Closes #12902
Screenshot 2024-04-10 at 12 38 39 PM
Screenshot 2024-04-10 at 12 38 29 PM
Screenshot 2024-04-10 at 12 38 08 PM

Notes:

  • The selector applies to all listening port links
  • The selector also decides the protocol when sharing a listening port with the "Share" button
  • The selector value is saved in localstorage by workspaceID
  • I moved the no detected ports text to a more reactive position and updated helper text

@f0ssel f0ssel marked this pull request as ready for review April 10, 2024 16:41
@f0ssel f0ssel requested review from aslilac and removed request for BrunoQuaresma April 11, 2024 16:51
</Stack>
{filteredListeningPorts.length === 0 && (
<HelpTooltipText css={styles.noPortText}>
{"No open ports were detected."}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{"No open ports were detected."}
No open ports were detected.

Comment on lines 256 to 258
{
"The listening ports are exclusively accessible to you. Selecting HTTP/S will change the protocol for all listening ports."
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{
"The listening ports are exclusively accessible to you. Selecting HTTP/S will change the protocol for all listening ports."
}
The listening ports are exclusively accessible to you. This option will change the protocol for all listening ports.

Comment on lines 199 to 209
const filteredListeningPorts = (listeningPorts ? listeningPorts : []).filter(
(port) => {
for (let i = 0; i < filteredSharedPorts.length; i++) {
if (filteredSharedPorts[i].port === port.port) {
return false;
}
}
}

return true;
});
return true;
},
);
Copy link
Member

@aslilac aslilac Apr 11, 2024

Choose a reason for hiding this comment

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

Suggested change
const filteredListeningPorts = (listeningPorts ? listeningPorts : []).filter(
(port) => {
for (let i = 0; i < filteredSharedPorts.length; i++) {
if (filteredSharedPorts[i].port === port.port) {
return false;
}
}
}
return true;
});
return true;
},
);
const filteredListeningPorts = (listeningPorts ?? []).filter(
(port) => filteredSharedPorts.every((sharedPort) => sharedPort.port !== port.port),
);

Comment on lines +69 to +85
export const saveWorkspaceListeningPortsProtocol = (
workspaceID: string,
protocol: WorkspaceAgentPortShareProtocol,
) => {
localStorage.setItem(
`listening-ports-protocol-workspace-${workspaceID}`,
protocol,
);
};

export const getWorkspaceListeningPortsProtocol = (
workspaceID: string,
): WorkspaceAgentPortShareProtocol => {
return (localStorage.getItem(
`listening-ports-protocol-workspace-${workspaceID}`,
) || "http") as WorkspaceAgentPortShareProtocol;
};
Copy link
Member

Choose a reason for hiding this comment

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

I'm always wary of using localStorage for stuff like this. Can you share some of your rationale?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am too. We have had many group discussions (dean, jon, kyle, ben) around a few of the PRs coming out of Shared Ports about these protocol selection features. I've suggested keeping this state and other UX state in the DB in the past, but the group thought that putting this button in local storage is better than making a new table to track this stuff. We want an MVP that is feature complete, but can still iterate on later as we get customer feedback, and this was the solution we landed on for now.

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha. If it changes the protocol of all ports though, is it really "UI state"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I promise you I have brought up many different discussions about doing things with this on the backend but the conclusion the group came to was client side storage for now and that we can iterate on the design once we get feedback.

@f0ssel f0ssel merged commit 3ab5a51 into main Apr 15, 2024
25 checks passed
@f0ssel f0ssel deleted the f0ssel/listening-protocol branch April 15, 2024 19:00
@github-actions github-actions bot locked and limited conversation to collaborators Apr 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add http/https button for listening ports
2 participants