MCPcopy Index your code
hub / github.com/coder/coder / PortForwardPopoverView

Function PortForwardPopoverView

site/src/modules/resources/PortForwardButton.tsx:142–588  ·  view source on GitHub ↗
({
	host,
	workspace,
	agent,
	template,
	sharedPorts,
	listeningPorts,
	portSharingControlsEnabled,
	refetchSharedPorts,
})

Source from the content-addressed store, hash-verified

140}
141
142export const PortForwardPopoverView: FC<PortForwardPopoverViewProps> = ({
143 host,
144 workspace,
145 agent,
146 template,
147 sharedPorts,
148 listeningPorts,
149 portSharingControlsEnabled,
150 refetchSharedPorts,
151}) => {
152 const theme = useTheme();
153 const [listeningPortProtocol, setListeningPortProtocol] = useState(
154 getWorkspaceListeningPortsProtocol(workspace.id),
155 );
156
157 const upsertSharedPortMutation = useMutation({
158 ...upsertWorkspacePortShare(workspace.id),
159 onSuccess: refetchSharedPorts,
160 });
161
162 const deleteSharedPortMutation = useMutation({
163 ...deleteWorkspacePortShare(workspace.id),
164 onSuccess: refetchSharedPorts,
165 });
166
167 const {
168 mutateAsync: upsertWorkspacePortShareForm,
169 isPending: isSubmitting,
170 error: submitError,
171 } = useMutation({
172 ...upsertWorkspacePortShare(workspace.id),
173 onSuccess: refetchSharedPorts,
174 });
175
176 const form = useFormik({
177 initialValues: {
178 agent_name: agent.name,
179 port: "",
180 protocol: "http",
181 share_level: "authenticated",
182 },
183 validationSchema: openPortSchema(),
184 onSubmit: async (values, { resetForm }) => {
185 resetForm();
186 await upsertWorkspacePortShareForm({
187 agent_name: values.agent_name,
188 port: Number(values.port),
189 share_level: values.share_level as WorkspaceAgentPortShareLevel,
190 protocol: values.protocol as WorkspaceAgentPortShareProtocol,
191 });
192 },
193 });
194 const getFieldHelpers = getFormHelpers(form, submitError);
195
196 // filter out shared ports that are not from this agent
197 const filteredSharedPorts = sharedPorts.filter(
198 (port) => port.agent_name === agent.name,
199 );

Callers

nothing calls this directly

Calls 12

upsertWorkspacePortShareFunction · 0.90
deleteWorkspacePortShareFunction · 0.90
getFormHelpersFunction · 0.90
docsFunction · 0.90
portForwardURLFunction · 0.90
openPortSchemaFunction · 0.85
NumberFunction · 0.85
filterMethod · 0.80
getMethod · 0.80
openMethod · 0.80

Tested by

no test coverage detected