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

const typeIco = {
  "submodule":"icon-file-submodule font-17",
  "file":'icon-wenjia font-15',
  "dir":"icon-wenjianjia1 font-15"
}

function CoderDepotCatalogue({item , goToSubRoot , owner , projectsId }){
  return(
    <li>
      <span>
        <a onClick={()=>goToSubRoot(item.path,item.type,item.name)} className={item.type === "submodule" && "submoduleStyle"}>
          <i className={`iconfont ${typeIco[`${item.type}`]} color-green-file 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;