From 8c6ab3db3732f02d75e99595bc6217e7362a4118 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 20 Jan 2022 20:18:28 -0800 Subject: [PATCH] fix: Don't show drag handle on pins when there is only 1 --- app/components/DocumentCard.tsx | 15 +++++++++++---- app/components/PinnedDocuments.tsx | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/components/DocumentCard.tsx b/app/components/DocumentCard.tsx index b3e3eac05..8e61db558 100644 --- a/app/components/DocumentCard.tsx +++ b/app/components/DocumentCard.tsx @@ -18,15 +18,20 @@ import CollectionIcon from "./CollectionIcon"; import Tooltip from "./Tooltip"; type Props = { + /** The pin record */ pin: Pin | undefined; + /** The document related to the pin */ document: Document; + /** Whether the user has permission to delete or reorder the pin */ canUpdatePin?: boolean; + /** Whether this pin can be reordered by dragging */ + isDraggable?: boolean; }; function DocumentCard(props: Props) { const { t } = useTranslation(); const { collections } = useStores(); - const { document, pin, canUpdatePin } = props; + const { document, pin, canUpdatePin, isDraggable } = props; const collection = collections.get(document.collectionId); const { attributes, @@ -105,9 +110,11 @@ function DocumentCard(props: Props) { )} - - ::: - + {isDraggable && ( + + ::: + + )} )} diff --git a/app/components/PinnedDocuments.tsx b/app/components/PinnedDocuments.tsx index 7ef31d01d..ddfff7d13 100644 --- a/app/components/PinnedDocuments.tsx +++ b/app/components/PinnedDocuments.tsx @@ -101,6 +101,7 @@ function PinnedDocuments({ limit, pins, canUpdate, ...rest }: Props) { key={documentId} document={document} canUpdatePin={canUpdate} + isDraggable={items.length > 1} pin={pin} {...rest} />