diff --git a/src/files-and-uploads/FileThumbnail.jsx b/src/files-and-uploads/FileThumbnail.jsx index 19eedb7957..ca0aeb309c 100644 --- a/src/files-and-uploads/FileThumbnail.jsx +++ b/src/files-and-uploads/FileThumbnail.jsx @@ -4,33 +4,32 @@ import { Icon, Image, } from '@edx/paragon'; -import { - AudioFile, - Terminal, - // FolderZip, - InsertDriveFile, -} from '@edx/paragon/icons'; +import { getSrc } from './data/utils'; const AssetThumbnail = ({ thumbnail, wrapperType, externalUrl, displayName, -}) => ( -
- {thumbnail ? ( - {`Thumbnail - ) : ( -
- {wrapperType === 'documents' && } - {wrapperType === 'code' && } - {wrapperType === 'audio' && } - {wrapperType === 'other' && } -
- )} -
-); +}) => { + const src = getSrc({ + thumbnail, + externalUrl, + wrapperType, + }); + return ( +
+ {thumbnail ? ( + {`Thumbnail + ) : ( +
+ +
+ )} +
+ ); +}; AssetThumbnail.defaultProps = { thumbnail: null, }; diff --git a/src/files-and-uploads/FilesAndUploads.jsx b/src/files-and-uploads/FilesAndUploads.jsx index 4dc007c04a..416866fbbf 100644 --- a/src/files-and-uploads/FilesAndUploads.jsx +++ b/src/files-and-uploads/FilesAndUploads.jsx @@ -39,7 +39,12 @@ const FilesAndUploads = ({ }) => { const dispatch = useDispatch(); const defaultVal = 'card'; - const columnSizes = { xs: 12, sm: 6, lg: 3 }; + const columnSizes = { + xs: 12, + sm: 6, + md: 4, + lg: 2, + }; const [currentView, setCurrentView] = useState(defaultVal); const [isDeleteOpen, setDeleteOpen, setDeleteClose] = useToggle(false); const [isAddOpen, setAddOpen, setAddClose] = useToggle(false); @@ -144,30 +149,29 @@ const FilesAndUploads = ({ return ( -
- - {intl.formatMessage(messages.errorAlertMessage, { message: errorMessages.upload })} - - - {intl.formatMessage(messages.errorAlertMessage, { message: errorMessages.delete })} - - - {intl.formatMessage(messages.errorAlertMessage, { message: errorMessages.lock })} - -
- {intl.formatMessage(messages.subheading)} -
-
- +
+
+ + {intl.formatMessage(messages.errorAlertMessage, { message: errorMessages.upload })} + + + {intl.formatMessage(messages.errorAlertMessage, { message: errorMessages.delete })} + + + {intl.formatMessage(messages.errorAlertMessage, { message: errorMessages.lock })} + +
+ +
- { currentView === 'card' && } + { currentView === 'card' && } { currentView === 'list' && } diff --git a/src/files-and-uploads/data/utils.js b/src/files-and-uploads/data/utils.js index 7236bcbc5b..ffa74fb87d 100644 --- a/src/files-and-uploads/data/utils.js +++ b/src/files-and-uploads/data/utils.js @@ -1,6 +1,11 @@ import { InsertDriveFile, Terminal, AudioFile } from '@edx/paragon/icons'; +import { ensureConfig, getConfig } from '@edx/frontend-platform'; import FILES_AND_UPLOAD_TYPE_FILTERS from './constant'; +ensureConfig([ + 'STUDIO_BASE_URL', +], 'Course Apps API service'); + export const getWrapperType = (assets) => { const assetsWithWraperType = []; assets.forEach(asset => { @@ -19,9 +24,9 @@ export const getWrapperType = (assets) => { return assetsWithWraperType; }; -export const getIcon = ({ thumbnail, wrapperType, externalUrl }) => { +export const getSrc = ({ thumbnail, wrapperType, externalUrl }) => { if (thumbnail) { - return externalUrl; + return externalUrl || `${getConfig().STUDIO_BASE_URL}${thumbnail}`; } switch (wrapperType) { case 'document': diff --git a/src/files-and-uploads/table-components/GalleryCard.jsx b/src/files-and-uploads/table-components/GalleryCard.jsx index d6ca2c637b..7d69de6d52 100644 --- a/src/files-and-uploads/table-components/GalleryCard.jsx +++ b/src/files-and-uploads/table-components/GalleryCard.jsx @@ -7,13 +7,14 @@ import { useToggle, Chip, Truncate, + Image, } from '@edx/paragon'; import { MoreVert, } from '@edx/paragon/icons'; import FileMenu from '../FileMenu'; import FileInfo from '../FileInfo'; -import { getIcon } from '../data/utils'; +import { getSrc } from '../data/utils'; const GalleryCard = ({ className, @@ -29,9 +30,8 @@ const GalleryCard = ({ const { locked } = original; handleLockedAsset(original.id, !locked); }; - const icon = getIcon({ + const src = getSrc({ thumbnail: original.thumbnail, - externalUrl: original.externalUrl, wrapperType: original.wrapperType, }); @@ -55,11 +55,15 @@ const GalleryCard = ({ )} /> - {original.thumbnail ? ( - - ) : ( - - )} +
+ {original.thumbnail ? ( + + ) : ( +
+ +
+ )} +
{original.displayName} diff --git a/src/files-and-uploads/table-components/ListCard.jsx b/src/files-and-uploads/table-components/ListCard.jsx index d9467aa1f3..a2dd0cfab0 100644 --- a/src/files-and-uploads/table-components/ListCard.jsx +++ b/src/files-and-uploads/table-components/ListCard.jsx @@ -7,13 +7,14 @@ import { useToggle, Chip, Truncate, + Image, } from '@edx/paragon'; import { MoreVert, } from '@edx/paragon/icons'; import FileMenu from '../FileMenu'; import FileInfo from '../FileInfo'; -import { getIcon } from '../data/utils'; +import { getSrc } from '../data/utils'; const ListCard = ({ className, @@ -29,9 +30,8 @@ const ListCard = ({ const { locked } = original; handleLockedAsset(original.id, !locked); }; - const icon = getIcon({ + const src = getSrc({ thumbnail: original.thumbnail, - externalUrl: original.externalUrl, wrapperType: original.wrapperType, }); @@ -42,11 +42,13 @@ const ListCard = ({ orientation="horizontal" data-testid={`list-card-${original.id}`} > -
+
{original.thumbnail ? ( - + ) : ( - +
+ +
)}