File size: 1,562 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
/**
* RepoListItem
*
* Lists the name and the issue count of a repository
*/
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import { FormattedNumber } from 'react-intl';
import { makeSelectCurrentUser } from 'containers/App/selectors';
import ListItem from 'components/ListItem';
import IssueIcon from './IssueIcon';
import IssueLink from './IssueLink';
import RepoLink from './RepoLink';
import Wrapper from './Wrapper';
export function RepoListItem(props) {
const { item } = props;
let nameprefix = '';
// If the repository is owned by a different person than we got the data for
// it's a fork and we should show the name of the owner
if (item.owner.login !== props.currentUser) {
nameprefix = `${item.owner.login}/`;
}
// Put together the content of the repository
const content = (
<Wrapper>
<RepoLink href={item.html_url} target="_blank">
{nameprefix + item.name}
</RepoLink>
<IssueLink href={`${item.html_url}/issues`} target="_blank">
<IssueIcon />
<FormattedNumber value={item.open_issues_count} />
</IssueLink>
</Wrapper>
);
// Render the content into a list item
return <ListItem key={`repo-list-item-${item.full_name}`} item={content} />;
}
RepoListItem.propTypes = {
item: PropTypes.object,
currentUser: PropTypes.string,
};
export default connect(
createStructuredSelector({
currentUser: makeSelectCurrentUser(),
}),
)(RepoListItem);
|