diff --git a/src/components/WellShow/AssetPreviewWithOverlay.tsx b/src/components/WellShow/AssetPreviewWithOverlay.tsx index 93be8c0f..42311964 100644 --- a/src/components/WellShow/AssetPreviewWithOverlay.tsx +++ b/src/components/WellShow/AssetPreviewWithOverlay.tsx @@ -24,14 +24,14 @@ const previewStyles = { slideshow: { image: { width: '100%', + height: '100%', maxWidth: '100%', - maxHeight: 400, objectFit: 'contain', display: 'block', }, frame: { width: '100%', - height: 400, + height: '100%', border: 0, bgcolor: 'background.paper', pointerEvents: 'auto', @@ -96,6 +96,8 @@ export const AssetPreviewWithOverlay = ({ variant, refetchAssets, canManageAsset = false, + onViewMore, + slideshowCaption, }: { asset: IAsset variant: 'grid' | 'slideshow' @@ -103,6 +105,8 @@ export const AssetPreviewWithOverlay = ({ QueryObserverResult, HttpError> > canManageAsset?: boolean + onViewMore?: () => void + slideshowCaption?: string }) => { const isSlideshow = variant === 'slideshow' @@ -176,88 +180,225 @@ export const AssetPreviewWithOverlay = ({ sx={{ position: 'relative', width: '100%', + height: isSlideshow ? '100%' : undefined, + display: isSlideshow ? 'flex' : 'block', + flexDirection: isSlideshow ? 'column' : undefined, '&:hover .asset-overlay': { opacity: 1, }, }} > - - - - - {asset.name} - + - event.stopPropagation()} - onMouseDown={(event) => event.stopPropagation()} - onPointerDown={(event) => event.stopPropagation()} - sx={{ - position: 'absolute', - right: 8, - bottom: 8, - opacity: isSlideshow ? 1 : 0, - transition: 'opacity 0.2s ease-in-out', - pointerEvents: 'auto', - display: 'flex', - gap: 1, - alignItems: 'center', - }} - > - {asset.signed_url && ( - - )} + {asset.signed_url && ( + + )} + + {canManageAsset && ( + + )} + + + + {asset.label} + + + ) : ( + + + {asset?.name} + + + {onViewMore && ( + + )} + + )} + + {!isSlideshow && ( + event.stopPropagation()} + onMouseDown={(event) => event.stopPropagation()} + onPointerDown={(event) => event.stopPropagation()} + sx={{ + position: 'absolute', + right: 8, + top: 8, + opacity: isSlideshow ? 1 : 0, + transition: 'opacity 0.2s ease-in-out', + pointerEvents: 'auto', + display: 'flex', + gap: 1, + alignItems: 'center', + }} + > + {asset.signed_url && ( + + )} + + {canManageAsset && ( + + )} + + )} ) diff --git a/src/components/WellShow/Attachments.tsx b/src/components/WellShow/Attachments.tsx index 2981391f..693675ed 100644 --- a/src/components/WellShow/Attachments.tsx +++ b/src/components/WellShow/Attachments.tsx @@ -191,6 +191,7 @@ export const AttachmentsCard = ({ variant="grid" refetchAssets={refetchAssets} canManageAsset={canManageAmp} + onViewMore={() => openSlideshow(idx)} /> ))} @@ -200,10 +201,12 @@ export const AttachmentsCard = ({ sx={{ position: 'relative', borderRadius: 2, - overflow: 'hidden', + overflow: 'auto', boxShadow: 2, bgcolor: 'grey.100', - minHeight: 300, + minHeight: 360, + height: 480, + resize: 'vertical', display: 'flex', alignItems: 'center', justifyContent: 'center', @@ -215,6 +218,9 @@ export const AttachmentsCard = ({ variant="slideshow" refetchAssets={refetchAssets} canManageAsset={canManageAmp} + slideshowCaption={`${slideshowIndex + 1} / ${ + previewAssets.length + }`} /> )} {previewAssets.length > 1 && ( @@ -255,22 +261,6 @@ export const AttachmentsCard = ({ > - - {slideshowIndex + 1} / {previewAssets.length} - )} diff --git a/src/test/components/AssetPreviewWithOverlay.test.tsx b/src/test/components/AssetPreviewWithOverlay.test.tsx index 9d6f7276..77936564 100644 --- a/src/test/components/AssetPreviewWithOverlay.test.tsx +++ b/src/test/components/AssetPreviewWithOverlay.test.tsx @@ -148,4 +148,53 @@ describe('AssetPreviewWithOverlay reassociation dialog', () => { ).toBe(false) expect(mockedMutateAsset).not.toHaveBeenCalled() }) + + it('shows the asset name in grid mode with a view more action', async () => { + const user = userEvent.setup() + const refetchAssets = vi.fn().mockResolvedValue({ data: { data: [asset] } }) + const onViewMore = vi.fn() + + render( + + ) + + expect(screen.getByText('field-photo.jpg')).toBeTruthy() + await user.click(screen.getByRole('button', { name: 'View more' })) + + expect(onViewMore).toHaveBeenCalledTimes(1) + }) + + it('shows the asset label in slideshow mode', () => { + const refetchAssets = vi.fn().mockResolvedValue({ data: { data: [asset] } }) + + render( + + ) + + expect(screen.getByText('Expanded slideshow label')).toBeTruthy() + }) + + it('shows the slideshow caption in the footer', () => { + const refetchAssets = vi.fn().mockResolvedValue({ data: { data: [asset] } }) + + render( + + ) + + expect(screen.getByText('2 / 5')).toBeTruthy() + }) })