Skip to content
Merged
Show file tree
Hide file tree
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
39 changes: 23 additions & 16 deletions echo/frontend/src/components/project/ProjectSharingStrip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -85,14 +88,16 @@ export function ProjectSharingStrip({
)}
</>
)}
<Button
variant="subtle"
size="compact-sm"
ml="auto"
onClick={() => setModalOpen(true)}
>
<Trans>Manage</Trans>
</Button>
{isAdminRole(workspace?.role) && (
<Button
variant="subtle"
size="compact-sm"
ml="auto"
onClick={() => setModalOpen(true)}
>
<Trans>Manage</Trans>
</Button>
)}
</>
) : (
<>
Expand All @@ -107,14 +112,16 @@ export function ProjectSharingStrip({
<Trans>Visible to everyone in this workspace</Trans>
)}
</Text>
<Button
variant="subtle"
size="compact-sm"
ml="auto"
onClick={() => setModalOpen(true)}
>
<Trans>Make private</Trans>
</Button>
{isAdminRole(workspace?.role) && (
<Button
variant="subtle"
size="compact-sm"
ml="auto"
onClick={() => setModalOpen(true)}
>
<Trans>Make private</Trans>
</Button>
)}
</>
)}
</Group>
Expand Down
28 changes: 8 additions & 20 deletions echo/frontend/src/components/project/ProjectUsageAndSharing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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. */}
<InviteMemberCard
label={
isWorkspaceVisible ? (
<Trans>Make private to invite specific members</Trans>
) : (
<Trans>Share with someone</Trans>
)
}
helperText={
isWorkspaceVisible ? (
<Trans>
This project is visible to everyone in the workspace.
</Trans>
) : (
<Trans>Add a member and pick their access.</Trans>
)
}
onClick={() => setInviteOpen(true)}
/>
{!isWorkspaceVisible && isAdminRole(workspace?.role) && (
<InviteMemberCard
label={<Trans>Share with someone</Trans>}
helperText={<Trans>Add a member and pick their access.</Trans>}
onClick={() => setInviteOpen(true)}
/>
)}

{accessLoading ? (
<Loader size="xs" />
Expand Down
Loading