import React from 'react';
import { Link } from 'react-router-dom';
import { truncateCommitId } from '../common/util';

function CoderDepotCatalogue({item , goToSubRoot , owner , projectsId }){
  return(
    <li>
      <span>
        <a onClick={()=>goToSubRoot(item.path,item.type,item.name)}>
          <i className={item.type === 'dir' ? "iconfont icon-wenjianjia1 color-green-file font-15 mr5":"iconfont icon-wenjia color-green-file font-15 mr5"}></i>{item.name}
        </a>
      </span>
      <span title="init project">
        <Link to={`/projects/${owner}/${projectsId}/commits/${truncateCommitId(`${item.commit && item.commit.sha}`)}`} title={item.commit && item.commit.message}>
          {item.commit && item.commit.message}
        </Link>
      </span>
      <span>{item.commit && item.commit.time_from_now}</span>
    </li>
  )
}
export default CoderDepotCatalogue;