Skip to content

Commit

Permalink
fix: file info bugs (openedx#571)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinAoki authored and snglth committed Jan 9, 2024
1 parent 64a0e05 commit 31635f7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
21 changes: 17 additions & 4 deletions src/files-and-uploads/FileInfo.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { injectIntl, FormattedMessage, intlShape } from '@edx/frontend-platform/i18n';

import {
injectIntl,
FormattedMessage,
FormattedDate,
intlShape,
} from '@edx/frontend-platform/i18n';
import {
ModalDialog,
Stack,
Expand All @@ -13,6 +17,7 @@ import {
CheckboxControl,
} from '@edx/paragon';
import { ContentCopy, InfoOutline } from '@edx/paragon/icons';
import { getUtcDateTime } from './data/utils';
import AssetThumbnail from './FileThumbnail';

import messages from './messages';
Expand All @@ -31,6 +36,7 @@ const FileInfo = ({
setLockedState(locked);
handleLockedAsset(asset.id, locked);
};
const dateAdded = getUtcDateTime(asset.dateAdded);

return (
<ModalDialog
Expand All @@ -48,7 +54,7 @@ const FileInfo = ({
<ModalDialog.Body className="pt-0 x-small">
<hr />
<div className="row flex-nowrap m-0 mt-4">
<div className="col-7 mr-3">
<div className="col-8 mr-3">
<AssetThumbnail
thumbnail={asset.thumbnail}
externalUrl={asset.externalUrl}
Expand All @@ -60,7 +66,14 @@ const FileInfo = ({
<div className="font-weight-bold">
<FormattedMessage {...messages.dateAddedTitle} />
</div>
{asset.dateAdded}
<FormattedDate
value={dateAdded}
year="numeric"
month="short"
day="2-digit"
hour="numeric"
minute="numeric"
/>
<div className="font-weight-bold mt-3">
<FormattedMessage {...messages.fileSizeTitle} />
</div>
Expand Down
14 changes: 11 additions & 3 deletions src/files-and-uploads/FileThumbnail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ const AssetThumbnail = ({
});

return (
<div className="row justify-content-center">
<div className="row justify-content-center align-itmes-center">
{thumbnail ? (
<Image fluid thumbnail src={src} alt={`Thumbnail of ${displayName}`} />
<Image
style={{ width: '503px', height: '281px' }}
className="border rounded p-1"
src={src}
alt={`Thumbnail of ${displayName}`}
/>
) : (
<div className="border rounded p-1">
<div
className="row border justify-content-center align-items-center rounded m-0"
style={{ width: '503px', height: '281px' }}
>
<Icon src={src} style={{ height: '48px', width: '48px' }} />
</div>
)}
Expand Down
6 changes: 6 additions & 0 deletions src/files-and-uploads/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ export const getSrc = ({ thumbnail, wrapperType, externalUrl }) => {
return InsertDriveFile;
}
};

export const getUtcDateTime = (date) => {
const utcDateString = date.replace(/\bat\b/g, '');
const utcDateTime = new Date(utcDateString);
return utcDateTime;
};

0 comments on commit 31635f7

Please sign in to comment.