From ccc8a92c4f993ac98d699ea32c639e5adc4770a7 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 27 May 2026 14:24:59 +0200 Subject: [PATCH] feat(project): hide project sharing actions from non-admins --- .../project/ProjectSharingStrip.tsx | 39 +++++++++++-------- .../project/ProjectUsageAndSharing.tsx | 28 ++++--------- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/echo/frontend/src/components/project/ProjectSharingStrip.tsx b/echo/frontend/src/components/project/ProjectSharingStrip.tsx index 4f3e71cec..13d6ded4f 100644 --- a/echo/frontend/src/components/project/ProjectSharingStrip.tsx +++ b/echo/frontend/src/components/project/ProjectSharingStrip.tsx @@ -11,7 +11,9 @@ import { import { IconLock, IconUsers } from "@tabler/icons-react"; import { useState } from "react"; import { useProjectShares } from "@/hooks/useProjectSharing"; +import { useWorkspace } from "@/hooks/useWorkspace"; import { avatarUrl, memberInitials } from "@/lib/avatar"; +import { isAdminRole } from "@/lib/roles"; import { ProjectSharingModal } from "./ProjectSharingModal"; interface ProjectSharingStripProps { @@ -38,6 +40,7 @@ export function ProjectSharingStrip({ }: ProjectSharingStripProps) { const [modalOpen, setModalOpen] = useState(false); const { data: shares, isLoading } = useProjectShares(projectId); + const { workspace } = useWorkspace(); const isPrivate = visibility === "private"; const shareCount = shares?.length ?? 0; @@ -85,14 +88,16 @@ export function ProjectSharingStrip({ )} )} - + {isAdminRole(workspace?.role) && ( + + )} ) : ( <> @@ -107,14 +112,16 @@ export function ProjectSharingStrip({ Visible to everyone in this workspace )} - + {isAdminRole(workspace?.role) && ( + + )} )} diff --git a/echo/frontend/src/components/project/ProjectUsageAndSharing.tsx b/echo/frontend/src/components/project/ProjectUsageAndSharing.tsx index 1a137452d..9f99f8b42 100644 --- a/echo/frontend/src/components/project/ProjectUsageAndSharing.tsx +++ b/echo/frontend/src/components/project/ProjectUsageAndSharing.tsx @@ -21,7 +21,7 @@ import { useWorkspace } from "@/hooks/useWorkspace"; import { useV2Me } from "@/hooks/useV2Me"; import { useProjectShares } from "@/hooks/useProjectSharing"; import { avatarUrl, memberInitials } from "@/lib/avatar"; -import { displayRole } from "@/lib/roles"; +import { displayRole, isAdminRole } from "@/lib/roles"; import { formatDurationFromHours } from "@/lib/time"; import { ProjectSharingModal } from "./ProjectSharingModal"; import { ProjectSharingStrip } from "./ProjectSharingStrip"; @@ -508,25 +508,13 @@ export function ProjectUsageAndSharing({ projectId, visibility }: Props) { add-share modal. For a workspace-visible project it opens the same modal which surfaces "Make private" as the path to specific-member access. */} - Make private to invite specific members - ) : ( - Share with someone - ) - } - helperText={ - isWorkspaceVisible ? ( - - This project is visible to everyone in the workspace. - - ) : ( - Add a member and pick their access. - ) - } - onClick={() => setInviteOpen(true)} - /> + {!isWorkspaceVisible && isAdminRole(workspace?.role) && ( + Share with someone} + helperText={Add a member and pick their access.} + onClick={() => setInviteOpen(true)} + /> + )} {accessLoading ? (