From 165ec63492679a2144dbe381179f91487fa50f6e Mon Sep 17 00:00:00 2001 From: Bruno Quaresma Date: Fri, 6 Jan 2023 17:43:27 +0000 Subject: [PATCH 1/3] refactor: Do not display port forward button if it is disabled --- .../PortForwardButton/PortForwardButton.tsx | 45 +--------------- site/src/components/Resources/AgentRow.tsx | 2 +- .../NetworkSettingsPage.tsx | 54 ++++++++++++++----- 3 files changed, 43 insertions(+), 58 deletions(-) diff --git a/site/src/components/PortForwardButton/PortForwardButton.tsx b/site/src/components/PortForwardButton/PortForwardButton.tsx index 4a18681f2f836..595a32e651533 100644 --- a/site/src/components/PortForwardButton/PortForwardButton.tsx +++ b/site/src/components/PortForwardButton/PortForwardButton.tsx @@ -4,7 +4,6 @@ import Popover from "@material-ui/core/Popover" import { makeStyles } from "@material-ui/core/styles" import TextField from "@material-ui/core/TextField" import OpenInNewOutlined from "@material-ui/icons/OpenInNewOutlined" -import { ChooseOne, Cond } from "components/Conditionals/ChooseOne" import { Stack } from "components/Stack/Stack" import { useRef, useState, Fragment } from "react" import { colors } from "theme/colors" @@ -42,7 +41,7 @@ const portForwardURL = ( return `${location.protocol}//${host}`.replace("*", subdomain) } -const EnabledView: React.FC = (props) => { +const TooltipView: React.FC = (props) => { const { host, workspaceName, agentName, agentId, username } = props const styles = useStyles() const [port, setPort] = useState("3000") @@ -137,40 +136,7 @@ const EnabledView: React.FC = (props) => { ) } -const DisabledView: React.FC = ({ - workspaceName, - agentName, -}) => { - const cliExample = `coder port-forward ${workspaceName}.${agentName} --tcp 3000` - const styles = useStyles() - - return ( - <> - - - Your deployment does not have web port forwarding enabled. - {" "} - See the docs for more details. - - - - You can use the Coder CLI to forward ports from your workspace to your - local machine, as shown below. - - - - - - - Learn more about web port forwarding - - - - ) -} - export const PortForwardButton: React.FC = (props) => { - const { host } = props const anchorRef = useRef(null) const [isOpen, setIsOpen] = useState(false) const id = isOpen ? "schedule-popover" : undefined @@ -208,14 +174,7 @@ export const PortForwardButton: React.FC = (props) => { }} > Port forward - - - - - - - - + ) diff --git a/site/src/components/Resources/AgentRow.tsx b/site/src/components/Resources/AgentRow.tsx index d0fbc112fbb44..553761233b39c 100644 --- a/site/src/components/Resources/AgentRow.tsx +++ b/site/src/components/Resources/AgentRow.tsx @@ -105,7 +105,7 @@ export const AgentRow: FC = ({ agentName={agent.name} /> )} - {applicationsHost !== undefined && ( + {applicationsHost !== undefined && applicationsHost !== "" && ( { Codestin Search App -
+ +
+
+ +
- +
+
+ + + {deploymentConfig.wildcard_access_url.value !== "" ? ( + + ) : ( + + )} + +
+
) } From 0ed5e51c5b716b689a98973da0dd6bee45be7202 Mon Sep 17 00:00:00 2001 From: Bruno Quaresma Date: Mon, 9 Jan 2023 14:02:21 +0000 Subject: [PATCH 2/3] Fix storybook --- .../NetworkSettingsPage/NetworkSettingsPageView.stories.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/site/src/pages/DeploySettingsPage/NetworkSettingsPage/NetworkSettingsPageView.stories.tsx b/site/src/pages/DeploySettingsPage/NetworkSettingsPage/NetworkSettingsPageView.stories.tsx index 5d6d78990cca8..7f2d30b68ca03 100644 --- a/site/src/pages/DeploySettingsPage/NetworkSettingsPage/NetworkSettingsPageView.stories.tsx +++ b/site/src/pages/DeploySettingsPage/NetworkSettingsPage/NetworkSettingsPageView.stories.tsx @@ -39,6 +39,9 @@ export default { }, }, }, + wildcard_access_url: { + value: "https://coder.com", + }, }, }, }, From 84babab7ba89bd288891b361b50f473b08ec07e5 Mon Sep 17 00:00:00 2001 From: Bruno Quaresma Date: Mon, 9 Jan 2023 16:19:29 +0000 Subject: [PATCH 3/3] Add port forwarding --- site/src/components/Resources/AgentRow.stories.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/site/src/components/Resources/AgentRow.stories.tsx b/site/src/components/Resources/AgentRow.stories.tsx index e3bc358d13771..a289c3d1bf19f 100644 --- a/site/src/components/Resources/AgentRow.stories.tsx +++ b/site/src/components/Resources/AgentRow.stories.tsx @@ -76,3 +76,11 @@ Timeout.args = { applicationsHost: "", showApps: true, } + +export const ShowingPortForward = Template.bind({}) +ShowingPortForward.args = { + agent: MockWorkspaceAgent, + workspace: MockWorkspace, + applicationsHost: "https://coder.com", + showApps: true, +}