Skip to content

fix: make public menu item selectable #12484

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

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions site/src/modules/resources/PortForwardButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down