2019-10-03 15:27:08 +07:00
|
|
|
import React from 'react';
|
|
|
|
import List from '@material-ui/core/List';
|
|
|
|
import Link from '@material-ui/core/Link';
|
|
|
|
import { Link as RouterLink } from 'react-router-dom';
|
|
|
|
|
|
|
|
import { Versions, Time } from '../../../types/packageMeta';
|
|
|
|
import { formatDateDistance } from '../../utils/package';
|
2019-10-13 02:11:23 +07:00
|
|
|
import ListItem from '../../muiComponents/ListItem';
|
2019-10-03 15:27:08 +07:00
|
|
|
|
2019-10-08 03:19:18 +07:00
|
|
|
import { Spacer, ListItemText } from './styles';
|
|
|
|
|
2019-10-03 15:27:08 +07:00
|
|
|
export const NOT_AVAILABLE = 'Not available';
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
versions: Versions;
|
|
|
|
packageName: string;
|
|
|
|
time: Time;
|
|
|
|
}
|
|
|
|
|
|
|
|
const VersionsHistoryList: React.FC<Props> = ({ versions, packageName, time }) => (
|
|
|
|
<List dense={true}>
|
|
|
|
{Object.keys(versions)
|
|
|
|
.reverse()
|
|
|
|
.map(version => (
|
|
|
|
<ListItem className="version-item" key={version}>
|
|
|
|
<Link component={RouterLink} to={`/-/web/detail/${packageName}/v/${version}`}>
|
|
|
|
<ListItemText>{version}</ListItemText>
|
|
|
|
</Link>
|
|
|
|
<Spacer />
|
|
|
|
<ListItemText>{time[version] ? `${formatDateDistance(time[version])} ago` : NOT_AVAILABLE}</ListItemText>
|
|
|
|
</ListItem>
|
|
|
|
))}
|
|
|
|
</List>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default VersionsHistoryList;
|