forked from sombochea/verdaccio-ui
b56e43846b
* refactor(162): added forwardRef Card * refactor(162): introduced forwardRefDivider * refactor(162): introduced forwardRef MuiComponents * refactor(162): introducing forwardRef * refactor(162): introduced forwardRef * refactor(162): introduced forwardRef * fix(162): fixed link * fix: fixed port number * fix: fixed duplicated id * fix: fixed ref iconbutton * fix: updated snaps * fix: fixed port * fix: fixed eslint errors * fix: the item should be a button * fix: fixed eslint errors
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import React from 'react';
|
|
|
|
import { Versions, Time } from '../../../types/packageMeta';
|
|
import { formatDateDistance } from '../../utils/package';
|
|
import List from '../../muiComponents/List';
|
|
import ListItem from '../../muiComponents/ListItem';
|
|
|
|
import { Spacer, ListItemText, StyledLink } from './styles';
|
|
|
|
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}>
|
|
<StyledLink to={`/-/web/detail/${packageName}/v/${version}`}>
|
|
<ListItemText>{version}</ListItemText>
|
|
</StyledLink>
|
|
<Spacer />
|
|
<ListItemText>{time[version] ? `${formatDateDistance(time[version])} ago` : NOT_AVAILABLE}</ListItemText>
|
|
</ListItem>
|
|
))}
|
|
</List>
|
|
);
|
|
|
|
export default VersionsHistoryList;
|