2019-10-03 15:27:08 +07:00
|
|
|
import React from 'react';
|
2020-03-08 22:45:07 +07:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2019-10-03 15:27:08 +07:00
|
|
|
|
|
|
|
import { Versions, Time } from '../../../types/packageMeta';
|
|
|
|
import { formatDateDistance } from '../../utils/package';
|
2019-10-13 03:26:56 +07:00
|
|
|
import List from '../../muiComponents/List';
|
2019-10-13 02:11:23 +07:00
|
|
|
import ListItem from '../../muiComponents/ListItem';
|
2019-10-03 15:27:08 +07:00
|
|
|
|
2019-10-31 14:12:18 +07:00
|
|
|
import { Spacer, ListItemText, StyledLink } from './styles';
|
2019-10-08 03:19:18 +07:00
|
|
|
|
2019-10-03 15:27:08 +07:00
|
|
|
interface Props {
|
|
|
|
versions: Versions;
|
|
|
|
packageName: string;
|
|
|
|
time: Time;
|
|
|
|
}
|
|
|
|
|
2020-03-08 22:45:07 +07:00
|
|
|
const VersionsHistoryList: React.FC<Props> = ({ versions, packageName, time }) => {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<List dense={true}>
|
|
|
|
{Object.keys(versions)
|
|
|
|
.reverse()
|
|
|
|
.map(version => (
|
|
|
|
<ListItem className="version-item" key={version}>
|
|
|
|
<StyledLink to={`/-/web/detail/${packageName}/v/${version}`}>
|
|
|
|
<ListItemText>{version}</ListItemText>
|
|
|
|
</StyledLink>
|
|
|
|
<Spacer />
|
|
|
|
<ListItemText>
|
|
|
|
{time[version] ? formatDateDistance(time[version]) : t('versions.not-available')}
|
|
|
|
</ListItemText>
|
|
|
|
</ListItem>
|
|
|
|
))}
|
|
|
|
</List>
|
|
|
|
);
|
|
|
|
};
|
2019-10-03 15:27:08 +07:00
|
|
|
|
|
|
|
export default VersionsHistoryList;
|