mirror of
https://github.com/SomboChea/ui
synced 2026-01-18 00:56:00 +07:00
chore: sync with verdaccio master
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import { DetailContextConsumer } from '../../pages/version/index';
|
||||
import { formatDateDistance } from '../../utils/package';
|
||||
import { Heading, Spacer, ListItemText } from './styles';
|
||||
import List from '@material-ui/core/List/index';
|
||||
import ListItem from '@material-ui/core/ListItem/index';
|
||||
import React from 'react';
|
||||
import { DIST_TAGS } from '../../../lib/constants';
|
||||
|
||||
class Versions extends React.PureComponent<any> {
|
||||
render() {
|
||||
return (
|
||||
// $FlowFixMe
|
||||
<DetailContextConsumer>
|
||||
{({ packageMeta }) => {
|
||||
return this.renderContent(packageMeta);
|
||||
}}
|
||||
</DetailContextConsumer>
|
||||
);
|
||||
}
|
||||
|
||||
renderPackageList = (packages: any, isVersion: boolean = false, timeMap: Object = {}) => {
|
||||
return (
|
||||
<List>
|
||||
{Object.keys(packages)
|
||||
.reverse()
|
||||
.map(version => (
|
||||
<ListItem className={'version-item'} key={version}>
|
||||
<ListItemText>{version}</ListItemText>
|
||||
<Spacer />
|
||||
<ListItemText>{isVersion && timeMap[version] ? `${formatDateDistance(timeMap[version])} ago` : packages[version]}</ListItemText>
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
);
|
||||
};
|
||||
|
||||
// $FlowFixMe
|
||||
renderContent(packageMeta) {
|
||||
const { versions = {}, time: timeMap = {}, [DIST_TAGS]: distTags = {} } = packageMeta;
|
||||
|
||||
return (
|
||||
<>
|
||||
{distTags && (
|
||||
<>
|
||||
<Heading variant={'subheading'}>{'Current Tags'}</Heading>
|
||||
{this.renderPackageList(distTags, false, timeMap)}
|
||||
</>
|
||||
)}
|
||||
{versions && (
|
||||
<>
|
||||
<Heading variant={'subheading'}>{'Version History'}</Heading>
|
||||
{this.renderPackageList(versions, true, timeMap)}
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Versions;
|
||||
@@ -1,25 +0,0 @@
|
||||
import styled from 'react-emotion';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import { default as MuiListItemText } from '@material-ui/core/ListItemText';
|
||||
|
||||
export const Heading = styled(Typography)`
|
||||
&& {
|
||||
font-weight: 700;
|
||||
}
|
||||
`;
|
||||
|
||||
export const Spacer = styled('div')`
|
||||
flex: 1 1 auto;
|
||||
border-bottom: 1px dotted rgba(0, 0, 0, .2);
|
||||
white-space: nowrap;
|
||||
height: 0.5em;
|
||||
`;
|
||||
|
||||
export const ListItemText = styled(MuiListItemText)`
|
||||
&& {
|
||||
flex: none;
|
||||
color: black;
|
||||
opacity: .6;
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
export interface IProps {}
|
||||
Reference in New Issue
Block a user