1
0
mirror of https://github.com/SomboChea/ui synced 2024-11-16 19:24:28 +07:00
verdaccio-ui/src/components/Versions/VersionsHistoryList.tsx
Priscila Oliveira 1d705da38c feat: version Component - Replaced classes by func. comp (#129)
* refactor: replaced classes by func comp

* fix: fixed space margin

* refactor: changed display logic

* fix: fixed types

* fix: fixed Version test

* fix: fixed version style
2019-10-03 10:27:08 +02:00

36 lines
1.1 KiB
TypeScript

import React from 'react';
import List from '@material-ui/core/List';
import Link from '@material-ui/core/Link';
import ListItem from '@material-ui/core/ListItem';
import { Link as RouterLink } from 'react-router-dom';
import { Spacer, ListItemText } from './styles';
import { Versions, Time } from '../../../types/packageMeta';
import { formatDateDistance } from '../../utils/package';
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;