import React from 'react'; import PropTypes from 'prop-types'; import uniqueid from 'lodash/uniqueId'; import { FormattedDate, FormattedMessage } from 'react-intl'; import EditableDescription from './EditableDescription'; import EditableURL from './EditableURL'; import RetentionPolicy from './RetentionPolicy'; import ReadonlyDescription from './ReadonlyDescription'; import messages from './messages'; import './ItemProperties.scss'; const datetimeOptions = { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric', }; const ItemProperties = ({ createdAt, description, descriptionTextareaProps = {}, enterpriseOwner, modifiedAt, onDescriptionChange, onValidURLChange, owner, retentionPolicyProps = {}, size, trashedAt, uploader, url, }) => { const descriptionId = uniqueid('description_'); return (
{description || onDescriptionChange ? ( <> {text =>
{text}
}
{onDescriptionChange ? ( ) : ( )}
) : null} {!!url && ( <>
{onValidURLChange ? : url}
)} {owner ? ( <>
{owner}
) : null} {enterpriseOwner ? ( <>
{enterpriseOwner}
) : null} {uploader ? ( <>
{uploader}
) : null} {createdAt ? ( <>
) : null} {modifiedAt ? ( <>
) : null} {size ? ( <>
{size}
) : null} {trashedAt ? ( <>
) : null}
); }; ItemProperties.propTypes = { /** the datetime this item was created, accepts any value that can be passed to the Date() constructor */ createdAt: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), /** a description for the item */ description: PropTypes.string, /** props for the editable description textarea */ descriptionTextareaProps: PropTypes.object, /** the name of the item's enterprise owner if the item is owned by a different enterprise */ enterpriseOwner: PropTypes.string, /** the datetime this item was last modified, accepts any value that can be passed to the Date() constructor */ modifiedAt: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), /** function called on description textarea blur with the new value to save */ onDescriptionChange: PropTypes.func, /** function called on url input blur with the new value to save */ onValidURLChange: PropTypes.func, /** the name of the item's owner */ owner: PropTypes.string, /** props for the retention policy of this item */ retentionPolicyProps: PropTypes.object, /** use the getFileSize util to get a localized human-readable string from the number of bytes */ size: PropTypes.string, /** the datetime this item was deleted or moved to trash, accepts any value that can be passed to the Date() constructor */ trashedAt: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), /** the name of the user who uploaded this item */ uploader: PropTypes.string, /** the URL for the item when the item is a weblink */ url: PropTypes.string, }; export default ItemProperties;