Files
projectsend/resources/js/components/comments/comments-row-button.tsx
ignacionelson 6e47d76ba6 ProjectSend 2.0.0
Client file sharing, rebuilt from the ground up: a private area per
client, resumable uploads, folders, groups and categories, sharing with
expiry dates and download limits, comments, file versions, an activity
log, a REST API, and sixteen languages.

This repository begins here. ProjectSend 2 was developed privately, and
that development history is not published — the previous generation
remains available, with its own history, at projectsend/legacy.

Free software under the GNU General Public License v2, or (at your
option) any later version.
2026-08-14 01:38:12 -03:00

42 lines
1.8 KiB
TypeScript

import { MessageSquare, MessageSquareWarning } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { useTranslation } from '@/hooks/use-translation';
/**
* The comment affordance on a staff library row: how many comments are on
* the file, whether any of them are waiting for a decision, and a way
* straight into the conversation.
*
* Always rendered while commenting is switched on, even at zero — it is
* how a conversation gets started, not only how an existing one is found.
*
* `pending` is only ever non-zero for a moderator (see
* VisibleCommentScope::pendingCountsFor), so the alert state cannot appear
* to somebody who has no way to clear it. It swaps the icon rather than
* adding a dot beside it: at this size a dot reads as decoration, and
* "somebody is waiting on you" deserves to be legible at a glance.
*
* Staff UI is not themed, so this is a plain shared component with no
* per-theme shell — unlike the portal and public surfaces.
*/
export function CommentsRowButton({ count, pending = 0, onOpen }: { count: number; pending?: number; onOpen: () => void }) {
const { t } = useTranslation();
const waiting = pending > 0;
return (
<Button
variant="ghost"
size="sm"
onClick={onOpen}
className={waiting ? 'gap-1 text-amber-600 hover:text-amber-700 dark:text-amber-500' : 'gap-1'}
title={waiting ? t(':count waiting for approval', { count: pending }) : t(':count comments', { count })}
>
{waiting ? <MessageSquareWarning className="size-4" /> : <MessageSquare className="size-4" />}
{count > 0 && <span className="text-xs tabular-nums">{count}</span>}
<span className="sr-only">{t('Comments')}</span>
</Button>
);
}