mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-03-04 02:02:39 -05:00
Merge branch 'feat-new-detail-page' of github.com:verdaccio/verdaccio into feat-new-detail-page
This commit is contained in:
commit
06ff59c76a
8 changed files with 113 additions and 37 deletions
|
@ -8,11 +8,10 @@
|
||||||
import React, { Component, Fragment } from 'react';
|
import React, { Component, Fragment } from 'react';
|
||||||
import { withRouter } from 'react-router-dom';
|
import { withRouter } from 'react-router-dom';
|
||||||
|
|
||||||
import { DetailContextConsumer } from '../../pages/version/index';
|
import { DetailContextConsumer } from '../../pages/version';
|
||||||
import CardContent from '@material-ui/core/CardContent/index';
|
import Chip from '@material-ui/core/Chip';
|
||||||
import Chip from '@material-ui/core/Chip/index';
|
import { Content, CardWrap, Heading, ListItem, CardContent } from './styles';
|
||||||
import { Content, Tags, Tag, CardWrap } from './styles';
|
import List from '@material-ui/core/List';
|
||||||
import Typography from '@material-ui/core/Typography/index';
|
|
||||||
|
|
||||||
class DepDetail extends Component<any, any> {
|
class DepDetail extends Component<any, any> {
|
||||||
constructor(props: any) {
|
constructor(props: any) {
|
||||||
|
@ -28,11 +27,10 @@ class DepDetail extends Component<any, any> {
|
||||||
render() {
|
render() {
|
||||||
const { name, version } = this.state;
|
const { name, version } = this.state;
|
||||||
const tagText = `${name}@${version}`;
|
const tagText = `${name}@${version}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tag>
|
<ListItem>
|
||||||
<Chip clickable={true} component={'div'} label={tagText} onClick={this.handleOnClick} />
|
<Chip clickable={true} component={'div'} label={tagText} onClick={this.handleOnClick} />
|
||||||
</Tag>
|
</ListItem>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +46,13 @@ class DepDetail extends Component<any, any> {
|
||||||
const WrappDepDetail = withRouter(DepDetail);
|
const WrappDepDetail = withRouter(DepDetail);
|
||||||
|
|
||||||
class DependencyBlock extends Component<any, any> {
|
class DependencyBlock extends Component<any, any> {
|
||||||
|
renderList = (deps: object, enableLoading: boolean) =>
|
||||||
|
deps.map(dep => {
|
||||||
|
const [name, version] = dep;
|
||||||
|
|
||||||
|
return <WrappDepDetail key={name} name={name} onLoading={enableLoading} version={version} />;
|
||||||
|
});
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { dependencies, title } = this.props;
|
const { dependencies, title } = this.props;
|
||||||
const deps = Object.entries(dependencies);
|
const deps = Object.entries(dependencies);
|
||||||
|
@ -59,16 +64,8 @@ class DependencyBlock extends Component<any, any> {
|
||||||
return (
|
return (
|
||||||
<CardWrap>
|
<CardWrap>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<Typography gutterBottom={true} variant={'headline'}>
|
<Heading variant={'subheading'}>{title}</Heading>
|
||||||
{title}
|
<List>{this.renderList(deps, enableLoading)}</List>
|
||||||
</Typography>
|
|
||||||
<Tags>
|
|
||||||
{deps.map(dep => {
|
|
||||||
const [name, version] = dep;
|
|
||||||
|
|
||||||
return <WrappDepDetail key={name} name={name} onLoading={enableLoading} version={version} />;
|
|
||||||
})}
|
|
||||||
</Tags>
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</CardWrap>
|
</CardWrap>
|
||||||
);
|
);
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import styled from 'react-emotion';
|
import styled from 'react-emotion';
|
||||||
import Card from '@material-ui/core/Card/index';
|
import Card from '@material-ui/core/Card';
|
||||||
|
import Typography from '@material-ui/core/Typography';
|
||||||
|
import { default as MuiListItem } from '@material-ui/core/ListItem';
|
||||||
|
import { default as MuiCardContent } from '@material-ui/core/CardContent';
|
||||||
|
|
||||||
export const Content = styled.div`
|
export const Content = styled.div`
|
||||||
&& {
|
&& {
|
||||||
|
@ -12,17 +15,9 @@ export const Content = styled.div`
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Tags = styled.span`
|
export const CardContent = styled(MuiCardContent)`
|
||||||
&& {
|
&& {
|
||||||
display: flex;
|
padding-bottom: 0;
|
||||||
justify-content: start;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const Tag = styled.span`
|
|
||||||
&& {
|
|
||||||
margin: 5px;
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -31,3 +26,16 @@ export const CardWrap = styled(Card)`
|
||||||
margin: 0 0 25px;
|
margin: 0 0 25px;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const Heading = styled(Typography)`
|
||||||
|
&& {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const ListItem = styled(MuiListItem)`
|
||||||
|
&& {
|
||||||
|
padding-left: 0;
|
||||||
|
padding-right: 0;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
|
@ -13,6 +13,7 @@ import Tabs from '@material-ui/core/Tabs/index';
|
||||||
import Tab from '@material-ui/core/Tab/index';
|
import Tab from '@material-ui/core/Tab/index';
|
||||||
import { Content } from './styles';
|
import { Content } from './styles';
|
||||||
import Dependencies from '../Dependencies';
|
import Dependencies from '../Dependencies';
|
||||||
|
import UpLinks from '../UpLinks';
|
||||||
|
|
||||||
class DetailContainer extends Component<any, any> {
|
class DetailContainer extends Component<any, any> {
|
||||||
state = {
|
state = {
|
||||||
|
@ -43,9 +44,9 @@ class DetailContainer extends Component<any, any> {
|
||||||
</Tabs>
|
</Tabs>
|
||||||
<Content>
|
<Content>
|
||||||
{tabPosition === 0 && this.renderReadme(readMe)}
|
{tabPosition === 0 && this.renderReadme(readMe)}
|
||||||
{tabPosition === 1 && this.renderDependencies()}
|
{tabPosition === 1 && <Dependencies />}
|
||||||
{tabPosition === 2 && this.renderVersions()}
|
{tabPosition === 2 && <Versions />}
|
||||||
{tabPosition === 3 && this.renderReadme(readMe)}
|
{tabPosition === 3 && <UpLinks />}
|
||||||
</Content>
|
</Content>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
|
@ -57,10 +58,6 @@ class DetailContainer extends Component<any, any> {
|
||||||
return <Readme description={encodedReadme} />;
|
return <Readme description={encodedReadme} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
renderVersions = () => <Versions />;
|
|
||||||
|
|
||||||
renderDependencies = () => <Dependencies />;
|
|
||||||
|
|
||||||
handleChange = (event: any, tabPosition: number) => {
|
handleChange = (event: any, tabPosition: number) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.setState({ tabPosition });
|
this.setState({ tabPosition });
|
||||||
|
|
43
src/webui/components/UpLinks/index.js
Normal file
43
src/webui/components/UpLinks/index.js
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/**
|
||||||
|
* @prettier
|
||||||
|
* @flow
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { DetailContextConsumer } from '../../pages/version/index';
|
||||||
|
import { Heading, ListItem, CardContent } from './styles';
|
||||||
|
import List from '@material-ui/core/List';
|
||||||
|
import Chip from '@material-ui/core/Chip';
|
||||||
|
import Card from '@material-ui/core/Card';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
class UpLinks extends React.PureComponent {
|
||||||
|
render() {
|
||||||
|
return <DetailContextConsumer>{({ packageMeta }) => this.renderContent(packageMeta._uplinks)}</DetailContextConsumer>;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderList = (uplinks: object) => (
|
||||||
|
<List>
|
||||||
|
{Object.keys(uplinks)
|
||||||
|
.reverse()
|
||||||
|
.map(name => (
|
||||||
|
<ListItem key={name}>
|
||||||
|
<Chip label={name} />
|
||||||
|
</ListItem>
|
||||||
|
))}
|
||||||
|
</List>
|
||||||
|
);
|
||||||
|
|
||||||
|
// $FlowFixMe
|
||||||
|
renderContent = uplinks =>
|
||||||
|
uplinks && (
|
||||||
|
<Card>
|
||||||
|
<CardContent>
|
||||||
|
<Heading variant={'subheading'}>{'UpLinks'}</Heading>
|
||||||
|
{this.renderList(uplinks)}
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default UpLinks;
|
23
src/webui/components/UpLinks/styles.js
Normal file
23
src/webui/components/UpLinks/styles.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import styled from 'react-emotion';
|
||||||
|
import Typography from '@material-ui/core/Typography';
|
||||||
|
import { default as MuiListItem } from '@material-ui/core/ListItem';
|
||||||
|
import { default as MuiCardContent } from '@material-ui/core/CardContent';
|
||||||
|
|
||||||
|
export const Heading = styled(Typography)`
|
||||||
|
&& {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const ListItem = styled(MuiListItem)`
|
||||||
|
&& {
|
||||||
|
padding-left: 0;
|
||||||
|
padding-right: 0;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const CardContent = styled(MuiCardContent)`
|
||||||
|
&& {
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
`;
|
6
src/webui/components/UpLinks/types.js
Normal file
6
src/webui/components/UpLinks/types.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
/**
|
||||||
|
* @prettier
|
||||||
|
* @flow
|
||||||
|
*/
|
||||||
|
|
||||||
|
export interface IProps {}
|
|
@ -3,7 +3,9 @@ import Typography from '@material-ui/core/Typography';
|
||||||
import { default as MuiListItemText } from '@material-ui/core/ListItemText';
|
import { default as MuiListItemText } from '@material-ui/core/ListItemText';
|
||||||
|
|
||||||
export const Heading = styled(Typography)`
|
export const Heading = styled(Typography)`
|
||||||
|
&& {
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Spacer = styled('div')`
|
export const Spacer = styled('div')`
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
:global {
|
:global {
|
||||||
.container {
|
.container {
|
||||||
padding: 0px 15px;
|
padding: 15px;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|
||||||
@include container-size;
|
@include container-size;
|
||||||
|
|
Loading…
Add table
Reference in a new issue