Skip to content

Commit dc69341

Browse files
authored
fix: make public menu item selectable (#12484)
1 parent 5e9bf31 commit dc69341

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

site/src/modules/resources/PortForwardButton.tsx

+19-17
Original file line numberDiff line numberDiff line change
@@ -205,21 +205,15 @@ export const PortForwardPopoverView: FC<PortForwardPopoverViewProps> = ({
205205
const canSharePortsPublic =
206206
canSharePorts && template.max_port_share_level === "public";
207207

208-
const publicMenuItem = (
209-
<>
210-
{canSharePortsPublic ? (
211-
<MenuItem value="public">Public</MenuItem>
212-
) : (
213-
<Tooltip title="This workspace template does not allow sharing ports with unauthenticated users.">
214-
{/* Tooltips don't work directly on disabled MenuItem components so you must wrap in div. */}
215-
<div>
216-
<MenuItem value="public" disabled>
217-
Public
218-
</MenuItem>
219-
</div>
220-
</Tooltip>
221-
)}
222-
</>
208+
const disabledPublicMenuItem = (
209+
<Tooltip title="This workspace template does not allow sharing ports with unauthenticated users.">
210+
{/* Tooltips don't work directly on disabled MenuItem components so you must wrap in div. */}
211+
<div>
212+
<MenuItem value="public" disabled>
213+
Public
214+
</MenuItem>
215+
</div>
216+
</Tooltip>
223217
);
224218

225219
return (
@@ -447,7 +441,11 @@ export const PortForwardPopoverView: FC<PortForwardPopoverViewProps> = ({
447441
<MenuItem value="authenticated">
448442
Authenticated
449443
</MenuItem>
450-
{publicMenuItem}
444+
{canSharePortsPublic ? (
445+
<MenuItem value="public">Public</MenuItem>
446+
) : (
447+
disabledPublicMenuItem
448+
)}
451449
</Select>
452450
</FormControl>
453451
<Button
@@ -512,7 +510,11 @@ export const PortForwardPopoverView: FC<PortForwardPopoverViewProps> = ({
512510
label="Sharing Level"
513511
>
514512
<MenuItem value="authenticated">Authenticated</MenuItem>
515-
{publicMenuItem}
513+
{canSharePortsPublic ? (
514+
<MenuItem value="public">Public</MenuItem>
515+
) : (
516+
disabledPublicMenuItem
517+
)}
516518
</TextField>
517519
<LoadingButton
518520
variant="contained"

0 commit comments

Comments
 (0)