Skip to content

Commit

Permalink
Fix sharing replays publicly from sharing modal (replayio#4739)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjduffy committed Dec 3, 2021
1 parent 2500465 commit 6bd8985
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/ui/components/Library/RecordingOptionsDropdown.tsx
Expand Up @@ -82,7 +82,7 @@ function RecordingOptionsDropdown({
>
<Dropdown>
<DropdownItem onClick={() => onDeleteRecording(recordingId)}>Delete</DropdownItem>
{isPublicDisabled(workspaces, currentWorkspaceId || "My Library") ? null : (
{isPublicDisabled(workspaces, currentWorkspaceId) ? null : (
<DropdownItem onClick={toggleIsPrivate}>{`Make ${
isPrivate ? "public" : "private"
}`}</DropdownItem>
Expand Down
8 changes: 4 additions & 4 deletions src/ui/components/shared/SharingModal/PrivacyDropdown.tsx
Expand Up @@ -6,6 +6,7 @@ import { Recording, Workspace } from "ui/types";
import hooks from "ui/hooks";
import MaterialIcon from "../MaterialIcon";
import { trackEvent } from "ui/utils/telemetry";
import { isPublicDisabled } from "ui/utils/org";

const WorkspacePrivacySummary = ({ workspace: { name } }: { workspace: Workspace }) => (
<span>
Expand Down Expand Up @@ -37,8 +38,7 @@ export default function PrivacyDropdown({ recording }: { recording: Recording })
const { workspaces } = hooks.useGetNonPendingWorkspaces();
const workspaceId = recording.workspace?.id || null;
const isOwner = hooks.useIsOwner(recording.id || "00000000-0000-0000-0000-000000000000");
const workspace = workspaces.find(w => w.id === workspaceId);
const isPrivate = recording.private || workspace?.settings.features.recording.public === false;
const isPrivate = recording.private;
const toggleIsPrivate = hooks.useToggleIsPrivate(recording.id, isPrivate);

const setPublic = () => {
Expand Down Expand Up @@ -96,13 +96,13 @@ export default function PrivacyDropdown({ recording }: { recording: Recording })
position="bottom-right"
>
<Dropdown menuItemsClassName="z-50 overflow-auto max-h-48" widthClass="w-80">
{workspace?.settings.features.recording.public === true ? (
{isPublicDisabled(workspaces, workspaceId) ? null : (
<DropdownItem onClick={setPublic}>
<DropdownItemContent icon="link" selected={!isPrivate}>
Anyone with the link
</DropdownItemContent>
</DropdownItem>
) : null}
)}
<DropdownItem onClick={() => handleMoveToTeam(null)}>
<DropdownItemContent icon="domain" selected={isPrivate && !workspaceId}>
Only people with access
Expand Down
4 changes: 2 additions & 2 deletions src/ui/utils/org.ts
Expand Up @@ -19,13 +19,13 @@ export function getOrganizationSettings(workspaces: Workspace[]) {
return org?.settings || getDefaultOrganizationSettings();
}

export function isPublicDisabled(workspaces: Workspace[], selectedWorkspaceId: string) {
export function isPublicDisabled(workspaces: Workspace[], selectedWorkspaceId: string | null) {
const workspace = workspaces.find(w => w.id === selectedWorkspaceId);
const publicDisabledMyLibrary = workspaces.some(
w => w.settings.features.recording.public === false
);
return (
(selectedWorkspaceId === "My Library" && publicDisabledMyLibrary) ||
(!selectedWorkspaceId && publicDisabledMyLibrary) ||
workspace?.settings.features.recording.public === false
);
}

0 comments on commit 6bd8985

Please sign in to comment.