Skip to content

Commit

Permalink
show thumbnail in picker if available
Browse files Browse the repository at this point in the history
  • Loading branch information
VargaJoe committed Sep 8, 2023
1 parent 21faf9e commit 4484697
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Avatar, DialogActions, DialogContent, LinearProgress } from '@material-ui/core'
import { ODataParams, Repository } from '@sensenet/client-core'
import { PathHelper } from '@sensenet/client-utils'
import { Folder, Image, ReferenceFieldSetting, User } from '@sensenet/default-content-types'
import { GenericContentWithIsParent, Picker, PickerProps } from '@sensenet/pickers-react'
import React, { useMemo } from 'react'
Expand Down Expand Up @@ -63,7 +64,7 @@ export const ReferencePicker: React.FC<ReferencePickerProps<GenericContentWithIs
)
}

if (props.repository.schemas.isContentFromType<Image>(item, 'Image')) {
if (props.repository.schemas.isContentFromType<Image>(item, 'Image') && (!item.PageCount || item.PageCount <= 0)) {
return (
<img
data-test="reference-selection-image"
Expand All @@ -74,6 +75,23 @@ export const ReferencePicker: React.FC<ReferencePickerProps<GenericContentWithIs
)
}

if (props.repository.schemas.isContentFromType<Image>(item, 'Image') && item.PageCount && item.PageCount > 0) {
return (

Check warning on line 79 in packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-picker.tsx

View check run for this annotation

Codecov / codecov/patch

packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-picker.tsx#L78-L79

Added lines #L78 - L79 were not covered by tests
<img
data-test="reference-selection-image"
alt={item.DisplayName}
src={PathHelper.joinPaths(
props.repository.configuration.repositoryUrl,
item.Path,
'/Previews',
item.Version as string,
'thumbnail1.png',
)}
style={{ width: '3em', height: '3em', objectFit: 'scale-down' }}
/>
)
}

if (props.renderIcon) {
return props.renderIcon(item)

Check warning on line 96 in packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-picker.tsx

View check run for this annotation

Codecov / codecov/patch

packages/sn-controls-react/src/fieldcontrols/reference-grid/reference-picker.tsx#L95-L96

Added lines #L95 - L96 were not covered by tests
}
Expand Down

0 comments on commit 4484697

Please sign in to comment.