mirror of
https://github.com/coder/coder.git
synced 2026-09-21 20:51:01 +08:00
fix: make public menu item selectable (#12484)
This commit is contained in:
@@ -205,21 +205,15 @@ export const PortForwardPopoverView: FC<PortForwardPopoverViewProps> = ({
|
||||
const canSharePortsPublic =
|
||||
canSharePorts && template.max_port_share_level === "public";
|
||||
|
||||
const publicMenuItem = (
|
||||
<>
|
||||
{canSharePortsPublic ? (
|
||||
<MenuItem value="public">Public</MenuItem>
|
||||
) : (
|
||||
<Tooltip title="This workspace template does not allow sharing ports with unauthenticated users.">
|
||||
{/* Tooltips don't work directly on disabled MenuItem components so you must wrap in div. */}
|
||||
<div>
|
||||
<MenuItem value="public" disabled>
|
||||
Public
|
||||
</MenuItem>
|
||||
</div>
|
||||
</Tooltip>
|
||||
)}
|
||||
</>
|
||||
const disabledPublicMenuItem = (
|
||||
<Tooltip title="This workspace template does not allow sharing ports with unauthenticated users.">
|
||||
{/* Tooltips don't work directly on disabled MenuItem components so you must wrap in div. */}
|
||||
<div>
|
||||
<MenuItem value="public" disabled>
|
||||
Public
|
||||
</MenuItem>
|
||||
</div>
|
||||
</Tooltip>
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -447,7 +441,11 @@ export const PortForwardPopoverView: FC<PortForwardPopoverViewProps> = ({
|
||||
<MenuItem value="authenticated">
|
||||
Authenticated
|
||||
</MenuItem>
|
||||
{publicMenuItem}
|
||||
{canSharePortsPublic ? (
|
||||
<MenuItem value="public">Public</MenuItem>
|
||||
) : (
|
||||
disabledPublicMenuItem
|
||||
)}
|
||||
</Select>
|
||||
</FormControl>
|
||||
<Button
|
||||
@@ -512,7 +510,11 @@ export const PortForwardPopoverView: FC<PortForwardPopoverViewProps> = ({
|
||||
label="Sharing Level"
|
||||
>
|
||||
<MenuItem value="authenticated">Authenticated</MenuItem>
|
||||
{publicMenuItem}
|
||||
{canSharePortsPublic ? (
|
||||
<MenuItem value="public">Public</MenuItem>
|
||||
) : (
|
||||
disabledPublicMenuItem
|
||||
)}
|
||||
</TextField>
|
||||
<LoadingButton
|
||||
variant="contained"
|
||||
|
||||
Reference in New Issue
Block a user