/** * @prettier * @flow */ /* eslint react/jsx-max-depth: 0 */ import React, { Component, Fragment } from 'react'; import { withRouter } from 'react-router-dom'; import CardContent from '@material-ui/core/CardContent/index'; import { DetailContextConsumer } from '../../pages/version'; import { CardWrap, Heading, Tags, Tag } from './styles'; import NoItems from '../NoItems'; class DepDetail extends Component { constructor(props: any) { super(props); const { name, version } = this.props; this.state = { name, version, }; } render() { const { name, version } = this.state; const tagText = `${name}@${version}`; return ; } handleOnClick = () => { const { name } = this.state; const { onLoading, history } = this.props; onLoading(); history.push(`/-/web/detail/${name}`); }; } const WrappDepDetail = withRouter(DepDetail); class DependencyBlock extends Component { render() { const { dependencies, title } = this.props; const deps = Object.entries(dependencies); return ( // $FlowFixMe {({ enableLoading }) => { return ( {`${title} (${deps.length})`} {this.renderTags(deps, enableLoading)} ); }} ); } renderTags = (deps: any, enableLoading: any) => deps.map(dep => { const [name, version] = dep; return ; }); } class Dependencies extends Component { state = { tabPosition: 0, }; render() { return ( {packageMeta => { return this.renderDependencies(packageMeta); }} ); } checkDependencyLength(dependency: Object = {}) { return Object.keys(dependency).length > 0; } // $FlowFixMe renderDependencies({ packageMeta }) { const { latest } = packageMeta; const { dependencies, devDependencies, peerDependencies, name } = latest; const dependencyMap = { dependencies, devDependencies, peerDependencies }; const dependencyList = Object.keys(dependencyMap).reduce((result, value, key) => { const selectedDepndency = dependencyMap[value]; if (selectedDepndency && this.checkDependencyLength(selectedDepndency)) { result.push(); } return result; }, []); if (dependencyList.length) { return {dependencyList}; } return ; } } export default Dependencies;